How can I display the push notification user permission dialog only when it is needed?
I have implemented registering push notification in my AppDelegate file. As soon as my app launches, it will popup a dialog immediately asking the user to allow permission.
Problem is, user may not understand why it is needed at this time. In order to prevent the user from selecting “Don’t Allow”, I want to show this popup later in a specific ViewController and possibly explain why this is needed to the user.
Is there a way to do so?
The reason the dialog appears immediately is because you’re telling it to appear immediately!
To avoid having the dialog displayed as soon as the app is launched, take your call to
registerUserNotificationSettings: and put it somewhere where it isn’t called the first time the app launches.