IOS - delegate method when manually turning on Push Push user in settings

We know that when a user requests a system dialogue in the application with a request for Push Notification permission, if he clicks "YES", then he will be called application:didRegisterForRemoteNotificationsWithDeviceToken:if he clicks "NO", then he application:didFailToRegisterForRemoteNotificationsWithError:will be called.

What should I do if the user clicks “NO” and then goes to “Settings” and manually enables push notifications? Upon returning to the application, a specific delegate method will be launched? I would like to execute a code block as soon as the user turns on push notifications in the settings, what is the best way to detect this without trying to register with applicationDidBecomeActive each time?

+4
source share
2 answers

If the user rejects your request for notifications, then didFailToRegisterForRemoteNotificationsWithError:it is not called because the registration did not work - he did not even try.

If the user changes the permissions in the settings application, you will receive a call didRegisterForRemoteNotificationsWithDeviceToken:either the next time you start the application, or when your application returns to the foreground, if it is in the background.

, - , didRegisterUserNotificationSettings:, , , , didRegisterForRemoteNotificationsWithDeviceToken:

+3

, push-, .

func application(_ application: UIApplication, didRegister notificationSettings: UIUserNotificationSettings) {
}
0

All Articles