[英]Can an app receive a token from a push server even if the user has declined the app to receive push notifications?
[英]Find out if user has accepted to receive Push Notifications?
我正在使用這段代碼來查找用戶是否已接受接收遠程通知UIApplication.sharedApplication().isRegisteredForRemoteNotifications()
-但是,即使我點擊了“不允許”,也要在我的設備上對其進行測試- true
,而且我還獲得了設備令牌?
另一方面,在“設置”應用=>“通知”中,該應用被設置為不接收任何通知...
那么,有沒有一種正確的方法來找出用戶是否必須不允許該應用接收APN?
您可以使用currentUserNotificationSettings獲取當前的通知設置:
let notificationSettings = UIApplication.sharedApplication().currentUserNotificationSettings()
print("Notification types allowed by user is: \(notificationSettings.types).")
如果用戶禁用了通知,則類型將為None
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.