Reputation: 11786
I've successfully implemented Push Notifications on React Native, by pushing messages via my device token. In production, when the app is in the store, what's the optimal method for obtaining device tokens from users who download our app and enabled push notifications. Should we have the app push a unique identifier + device token to our server when opening the app? Or is there a more efficient approach?
Upvotes: 1
Views: 870
Reputation: 2355
1- You need paid apple developer account
2- You need to generate .pem
file to use in server side from here
3- In appdelegate.m
use
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
//here you call your web service to record device token to server
}
4- prepare your server side from here
5- you will need two .pem
file one to development mode and another for production mode
Upvotes: 0
Reputation: 37600
Obtain the token every time the app becomes active, cache it within the app and send it to the server (via http push for example) Next time the app obtains the token compare it with the cached version, if they differ send the new one to the server and cache the new old.
If you also send a unique id depends upon your push requirements, there's no use for it if you are broadcasting pushes to all devices. If you send pushes to specific handsets then obviously some identifier is needed to identify the user/device.
Upvotes: 1