Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delayed push notifications and checking if user enabled it

I develop an app, which builds itself around push notifications. The app requests notification permissions only when the user reaches certain point of the registration process. I have already managed to do the following:

  • the app maintains an NSUserDefaults variable, which indicates if it is required to register for push at launch or not (by default: not)
  • when the registration reaches that point, I flip the variable and call -registerForRemoteNotificationTypes: on iOS 7 and -registerUserNotificationSettings: on iOS 8

This works fine unless the user has already enabled push notifications and then disabled them later in the Settings. In this case I try to reregister Push at launch, which does not call either -application:didRegisterForRemoteNotificationsWithDeviceToken nor -application:didFailToRegisterForRemoteNotificationsWithError.

Additional information, that iOS 8's -isRegisteredForRemoteNotifications also returns YES. (I did not test but suppose that -enabledNotificationTypes works upto iOS 7.)

How can I detect this scenario and present the user a requester which asks him to reenable notifications in the Settings?

like image 520
gklka Avatar asked Jul 29 '14 14:07

gklka


People also ask

What causes delayed notifications?

Remote images and icons, adding an image to your notification could cause the notification to be delayed as it has to wait to download the full image(s) first. Try omitting your image(s) temporarily to rule this factor out. Doze Mode can delay notifications even when sending with the highest priority.

What does notification delay mean?

Notification Delay will allow you to set a period of time that we'll wait before we send you notifications about issues. If an issue is resolved during that delay period, the notification will be discarded and you won't receive any emails from us.


1 Answers

[[UIApplication sharedApplication] isRegisteredForRemoteNotifications];

Returns a Boolean indicating whether the app is currently registered for remote notifications.

Declaration SWIFT func isRegisteredForRemoteNotifications() -> Bool OBJECTIVE-C - (BOOL)isRegisteredForRemoteNotifications 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.

Discussion This method reflects only the successful completion of the remote registration process that begins when you call the registerForRemoteNotifications method. This method does not reflect whether push notifications are actually available due to connectivity issues. The value returned by this method takes into account the user’s preferences for receiving push notifications.

Availability Available in iOS 8.0 and later.

Link to Apple Doc's

I would file a bug report at Apple.

like image 120
Jasper Avatar answered Oct 21 '22 04:10

Jasper