I want to tell if a user selected to disable push notifications on my app.
I call:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound];
every time the app is launched. However, I want to send some info back to the server in the case where a user has disallowed my application from sending push notifications.
I was thinking about putting that logic in this callback:
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
However, I am unsure if this callback is fired when the user has disabled the app from receiving push notifs or if simply an an error case (connection error, etc). If so, what is the error that I should be looking for?
Check below code it will help you:
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types == UIRemoteNotificationTypeNone) {
// send info to the server that this user has disallowed push notifications
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With