Summary
User permission has no effect on remote push notifications, and thus APNs registration (i.e., token retrieval) is not affected. Therefore, your server-side push notification logic does not need to feel the impact of a user denying your application permission to present user-facing push notifications. You will continue to receive your remote push notifications even when the user does not consent to seeing them. The difference is that with a lack of permission, your push notifications are considered background remote notifications. Continue reading for further explanation.
Remote Push Notifications vs. User Notifications
APNs is a service that has the ability to remotely send a payload to a particular device, as identified by the app-device-specific token provided when registering for remote notifications. Push notifications seen by the user are not necessarily the same as a plain remote push notification. Remote notifications do not need explicit permission to be granted by the user. However, if the push notification is to be displayed to the user, only then is permission required.
User Permission & Server-Side of Push Notifications
To more directly answer your question: When your application launches you should register for remote notifications. That call will fetch an app-device token from APNs and then return it to you. If something prevented the registration from succeeding, another delegate method is called. Once you've registered for remote notifications, only then should you request user permission to display notifications to them. The user permission is only to display the notifications, so APNs will still work as intended without any change on the server-side. The only difference is how the device presents the information.
- (void)applicationDidFinishLaunching:(UIApplication *)app {
// Configure the user interactions first.
[self configureUserInteractions];
// Register for remote notifications.
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
// Handle remote notification registration.
- (void)application:(UIApplication *)app
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
// Forward the token to your provider, using a custom method.
// Setup user notifications.
[self enableRemoteNotificationFeatures];
[self forwardTokenToServer:devTokenBytes];
}
- (void)application:(UIApplication *)app
didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
// The token is not currently available.
NSLog(@"Remote notification support is unavailable due to error: %@", err);
[self disableRemoteNotificationFeatures];
}
References:
Local and Remote Notification Programming Guide – Configuring Remote Notification Support
Experience from using solely remote notifications (i.e., background) and user notifications.