After selecting "Cancel" in the "Notification Permissions" dialog box, the settings indicate that notification notifications are enabled

Please note that this question refers to iOS 6, which was the highest production version of iOS at the time I asked the question. I did not test subsequent tests in later versions of iOS, and everything could change. If you observe the same behavior in later versions of the OS, comment!

My application registers for push notifications. The Permissions dialog box opens ("MyApp would like to send you Push Notifications"). There are two possible streams:

a) The user selects OK. Settings-> Notifications-> MyApp then shows full permissions for alerts, as I expected.

or

b) THIS ERROR The user selects Cancel. I would expect Settings-> Notifications-> MyApp to show the application, and not in the Notification Center, with all permissions disabled. However, the converse is also true: there is no difference when they are OK in the dialog box!

In addition to my statement, I found that BBC News and Ap Mobile are showing the same error, while Viber is not working (it works exactly as I expected). Ap Mobile has a variant of this error - if I reject Push Notifications, only icons are turned on, not sounds and signals.

I am updating the state of the push settings, restoring the backup made before the application started , according to TN2265 .

+4
source share
1 answer

After infinity of recovery and testing, I discovered the following.

If the user selects "Cancel" in "xxx wants to send you push notifications", then notifications will be disabled in "Settings-> Notifications-> Application Name", if

a) A call to cancelAllLocalNotifications was made before registerForRemoteNotificationTypes :, in which case all warnings will be included. This is similar to an Apple bug.

or b) A call to setApplicationIconBadgeNumber: 0 (did not try other numbers) was made before the ForRemoteNotificationTypes register was created: in this case, only the icons will be included. It might be wise to include the icons if we really set the icon number, so it’s not at all obvious that this is an error, not a (undocumented) function.

The workaround for this error / function is to verify that the press is turned on before touching.

// If remote notifications are already enabled, then clear any existing. if([[UIApplication sharedApplication] enabledRemoteNotificationTypes] != UIRemoteNotificationTypeNone) { [[UIApplication sharedApplication] cancelAllLocalNotifications]; [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; } 
+2
source

Source: https://habr.com/ru/post/1501113/


All Articles