如何推迟[权限请求提醒]?

时间:2016-11-08 12:45:02

标签: ios swift push-notification

我的应用需要这些权限

  • 通知
  • GPS
  • 照片

当用户打开图库时会请求照片权限,但前两个权限会显示应用启动时的应用,我可以将GPS作为第一个要求的权限,但我想将通知对话推迟到另一个屏幕,该怎么做?

library似乎不允许这样做 有什么建议吗?

let notificationTypes : UIUserNotificationType = [UIUserNotificationType.Alert,UIUserNotificationType.Badge,UIUserNotificationType.Sound]
let notificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)

application.registerForRemoteNotifications()
application.registerUserNotificationSettings(notificationSettings)

1 个答案:

答案 0 :(得分:0)

谢谢,这解决了我,...

从app delegate调用

    let notificationTypes : UIUserNotificationType = [UIUserNotificationType.Alert,UIUserNotificationType.Badge,UIUserNotificationType.Sound]
    let notificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
    application.registerForRemoteNotifications()
    application.registerUserNotificationSettings(notificationSettings)

从另一个班级打电话

    let notificationTypes : UIUserNotificationType = [UIUserNotificationType.Alert,UIUserNotificationType.Badge,UIUserNotificationType.Sound]
    let notificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
    UIApplication.sharedApplication().registerForRemoteNotifications()
    UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings)
相关问题