我想写一些关于我的应用程序如何请求用户推送通知权限的新逻辑。
这包括在实际请求权限之前向用户显示一个新屏幕。
也-我想确保老用户更新了他们的应用程序,已经看到了系统提示不会看到这个新的屏幕。
如何检查用户是否已经看到推送通知权限提示?
从iOS 10开始,这是可以实现的
UNUserNotificationCenter.current().getNotificationSettings { (notificationSettings:UNNotificationSettings) in
if notificationSettings.authorizationStatus != .notDetermined {
// push notifications permission prompt on iOS has been shown in the past
}
使用iOS SDK,您只能检查是否已启用推送通知。新版ios 8
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types != UIRemoteNotificationTypeNone){ has enabled notifications}
from ios 8
[[UIApplication sharedApplication] isRegisteredForRemoteNotifications]
无法检查推送通知提示是否显示过一次,用户是否拒绝了