更新时间: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
}