且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Swift ios检查ios9和ios10中是否启用了远程推送通知

更新时间:2022-06-05 01:48:37

这个答案已过时且不支持iOS 10,你可以查看答案。

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

使用此代码

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