Trying to work around a few corner cases for when push notifications are denied in the app and I have two questions:
1) Is there a way to reset whether the user has seen the notification request pop up?
2) Is there any way to determine if the user has said no to the notification request?
1) No, unless there's some private API that does that, but that's not allowed by Apple
2) The first time your app is started, after calling registerForRemoteNotificationTypes, you can check if didRegisterForRemoteNotificationsWithDeviceToken is called. If it's not, the user said "No thanks".
You can always check the status of the permissions if the user changes them, you can check them on applicationDidBecomeActive
- (void)applicationDidBecomeActive:(UIApplication *)application
{
if ([[UIApplication sharedApplication] respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) {
if ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications]){
NSLog(@"Notifications Enabled ios 8");
} else {
NSLog(@"Notifications not Enabled ios 8");
}
} else {
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types & UIRemoteNotificationTypeAlert)
{
NSLog(@"Notifications Enabled");
}
else
{
NSLog(@"Notifications not Enabled");
}
}
}
updated to make it work on iOS 8 too
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