如何在用户更改通知设置时保存应用中的设置?

时间:2017-03-06 05:26:55

标签: ios notifications swift3

我在FCM的AppDelegate.swift类中实现了推送通知。通知很棒,但如何在用户更改通知设置时保存应用中的设置?

1 个答案:

答案 0 :(得分:0)

您可以通过调用通知委托方法

来检查通知设置
 let notificationCenter = AppDelegate().getNotificationCenter()
    notificationCenter.getNotificationSettings(completionHandler: { (setting) in
          if(setting.authorizationStatus == .denied){
       })
     }

获取通知的公共类。

public static var badge: UNAuthorizationOptions { get }

public static var sound: UNAuthorizationOptions { get }

public static var alert: UNAuthorizationOptions { get }

public static var carPlay: UNAuthorizationOptions { get }

了解更多:https://developer.apple.com/reference/usernotifications/unauthorizationoptions

让我知道它是否有用?