有没有办法记录用户拒绝权限的日期?

Is there any way to record the date when user denies permission?

如果用户拒绝推送通知的权限,我们可以在他拒绝时记录 date/time 并将其记录在 UserDefaults 中。

尝试在 application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool

中调用它
    func requestAuthorization(application: UIApplication) {
        if #available(iOS 10.0, *) {
             let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
            UNUserNotificationCenter.current().requestAuthorization(options: authOptions) { (permmitted, error) in
                if !permmitted {
                    // User denied, save your date
                    //----------
                }
            }
        }else {
            let settings: UIUserNotificationSettings =
                UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
            application.registerUserNotificationSettings(settings)
            if application.!isRegisteredForRemoteNotifications {
                // User denied, save your date.

            }

        }

    }