-1

In my application, user can use notifications sent from the app. At first launch, there is an alert with refuse or allow notifications made in the appdelegate. If I accept notifications, all is OK. I made a screen / viewcontroller in which user can accept or no notification with a switch. If user refused notifications at first launch, how can I access to the controls in appdelegate like if I was at first launch ?

Thanks

Mister Fisher
  • 83
  • 1
  • 9

1 Answers1

1

According to Apple's Developer Documentation and this answer (for clarification), push notifications permissions can only be requested once. iOS stores the user's decision after it has been made and there is no way to request again. Do prepare for the fact that some users might not want notifications, you can always check the status of the permission your app received:

let center = UNUserNotificationCenter.current()
center.getNotificationSettings { settings in
    guard settings.authorizationStatus == .authorized else { return }

    if settings.alertSetting == .enabled {
        // Schedule an alert-only notification.
    } else {
        // Schedule a notification with a badge and sound.
    }
}
Nico
  • 24
  • 3