Reputation: 97
Developing an app with push notifications, I need to know when user tap one of two button (Don't allow, allow) during push notifications authorization.
Is there any delegate to do that?
Upvotes: 1
Views: 879
Reputation: 2875
The callback will be made upon calling -[UIApplication registerUserNotificationSettings:]
. The settings the user has granted to the application will be passed in as the second argument.
If you want to see if the user declined the option you can check if !notification.types
as such:
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
// Make sure we check for user permission for location
UIUserNotificationSettings *notificationTypes = [[UIApplication sharedApplication] currentUserNotificationSettings];
if (!notificationTypes.types) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"You need to enable notifications for this functionality to work." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}
Upvotes: 2