Swift ios check if remote push notifications are enabled in ios9 and ios10

后端 未结 11 1325
悲哀的现实
悲哀的现实 2020-12-01 02:26

How can I check if the user has enabled remote notifications on ios 9 or ios 10?

If the user has not allowed or clicked No I want to toggle a message asking if they

11条回答
  •  不知归路
    2020-12-01 03:04

    This answer is outdated and doesn't support on iOS 10, you can check this answer.


    Use this code

    let isRegisteredForRemoteNotifications = UIApplication.shared.isRegisteredForRemoteNotifications
    if isRegisteredForRemoteNotifications {
         // User is registered for notification
    } else {
         // Show alert user is not registered for notification
    }
    

提交回复
热议问题