YogevSitton
YogevSitton

Reputation: 10108

Knowing if push notifications permission prompt on iOS has been shown in the past

I want to write some new logic around how my app is requesting users for Push Notifications permissions.

This includes showing the user a new screen before actually asking the permission.

Also - I want to make sure old users that updated their app and already saw the system prompt will not see this new screen.

How can I check if a user already saw the push notifications permission prompt?

Upvotes: 3

Views: 996

Answers (2)

Robert Wagstaff
Robert Wagstaff

Reputation: 2674

As of iOS 10 this is now possible

 UNUserNotificationCenter.current().getNotificationSettings { (notificationSettings:UNNotificationSettings) in 
if notificationSettings.authorizationStatus != .notDetermined {
    // push notifications permission prompt on iOS has been shown in the past

}

Upvotes: 2

Nik Yekimov
Nik Yekimov

Reputation: 2697

With iOS SDK you can only check whether push notifications are already enabled. Prior ios 8

UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types != UIRemoteNotificationTypeNone){ has enabled notifications} 

from ios 8

[[UIApplication sharedApplication] isRegisteredForRemoteNotifications]

It is no way to check, whether push notifications prompt was shown once and user declined it.

Upvotes: 0

Related Questions