Swift ios检查ios9和ios10中是否启用了远程推送通知 [英] Swift ios check if remote push notifications are enabled in ios9 and ios10

查看:111
本文介绍了Swift ios检查ios9和ios10中是否启用了远程推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查用户是否在ios 9或ios 10上启用了远程通知?

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

如果用户未允许或点击否我想要切换a询问是否要启用通知的消息。

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

推荐答案

这个答案已过时且不支持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
}

这篇关于Swift ios检查ios9和ios10中是否启用了远程推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆