jaredsinclair
jaredsinclair

Reputation: 12687

Can UNUserNotificationCenter.current().requestAuthorization() be called more than once?

Can UNUserNotificationCenter.current().requestAuthorization() be called more than once?

Upvotes: 3

Views: 1533

Answers (1)

jaredsinclair
jaredsinclair

Reputation: 12687

Answer: yes and no.

  • You can call it more than once ever, but you cannot call it more than once concurrently or else all but one of the concurrent requests will fail without an error (i.e. granted = false but error = nil). Concurrent requests can happen if your app logic has multiple events that can trigger an authorization request, as opposed to the simple happy path of doing it once inside appDidFinishLaunching.

  • Worse, concurrent requests will also trigger the notification permissions to become turned off even though the user had already authorized them during a previous app run. The bug report for such a scenario will look like this: "APN Permissions are Turning Themselves Off." Which, like all bugs, seems impossible at first.

Upvotes: 5

Related Questions