In iOS 9, is there a system level callback I can read which tells me whether the user has tapped on 'Don't allow' on the push notification request?
I prompt the user with a custom screen informing them about push notifications and the value it has in my app.
They have two choices, yes or no. If they select Yes, I request the operating system for push notification and they see a pop up like the image below.
Now, if the user taps on YES, then there is a function called didRegisterForRemoteNotificationsWithDeviceToken
which tells me the this device has been registered for push notifications. I can use this to move ahead to the next screen (and take them into the first screen after signing up)
However, how do I detect if the user taps on DON'T allow? I need to know that so I can accordingly move the user to the next screen (and take them into the first screen after signing up). The function didFailToRegisterForRemoteNotificationsWithError
is not called if the user taps on 'Don't Allow'.
This question is not a duplicate because the answer accepted for that question is specific to iOS 7, where as my question is specific is iOS 9.
Silent mode: Android devices have a “do not disturb” mode and a “no distractions” mode. If you have enabled either of these, you won't receive any notifications.
Go to Settings and tap Notifications. Select an app under Notification Style. Under Alerts, choose the alert style that you want. If you turn on Allow Notifications, choose when you want the notifications delivered — immediately or in the scheduled notification summary.
As of iOS 8, the notification registration process changed and moved away from the user having to grant permission to just remote notifications.
You can now technically register for remote notifications without having to get permission from the user. What you do need permission for is the user notification settings (alerts, sounds and badges). These are now generic to both local and remote notifications making the other answers technically incorrect.
You request permission via the -[UIApplication registerUserNotificationSettings:]
method on UIApplication
and as per the documentation, you get a callback to the -[UIApplicationDelegate application: didRegisterUserNotificationSettings:]
delegate method.
In the header, there is a comment saying the following:
// This 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.
This means that if the user did not grant permissions for notifications (both local and remote) then the second parameter won't contain any values.
-[UIApplication isRegisteredForRemoteNotifications]
will just tell you if the applicaiton has actually registered with Apple's push servers and has received a device token:
Return Value
YES if the app is registered for remote notifications and received its device token or NO if registration has not occurred, has failed, or has been denied by the user.
It's worth reading the UIApplication
documentation as it has all the info you need.
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/#//apple_ref/occ/instm/UIApplication
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