ios - 如何推迟【权限请求提醒】?

标签 ios swift push-notification

我的应用需要这些权限

  • 通知
  • 全局定位系统
  • 照片

当用户打开图库时请求照片权限,但前两个权限显示应用程序启动,我可以将 GPS 作为第一个请求权限,但我想将通知对话框推迟到另一个屏幕,如何做到这一点?

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

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

application.registerForRemoteNotifications()
application.registerUserNotificationSettings(notificationSettings)

最佳答案

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

从应用委托(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)

关于ios - 如何推迟【权限请求提醒】?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40487318/

相关文章:

ios - 计算总行驶距离 iOS Swift

ios - 是否可以为iOS编写新的辅助功能服务?

swift - 使用 swift 1.2 设置 AVAudioPlayer?

javascript - 仅限内部应用程序的基于“Web”的推送通知

ios - 如何在 iOS 中获取 One Signal 用户的唯一玩家 ID?

android - 每天使用 Parse.com 发送推送通知

ios - 将 iOS 应用程序的部署限制为仅某些应用程序

ios - NSTask 不适用于具有特殊字符的文件路径

ios - 对两个项目目标进行相同的单元/UI 测试?

ios - 当设备连接到 Internet 连接时未收到所有通知