2016-11-08 73 views
0

我的应用程序需要这些权限如何推迟[权限请求警报]?

  • 通知
  • 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

1.您在AppDelegate中注册的通知主叫,所以它肯定会要求启动许可。 – Wolverine

+1

2.对于GPS,当您尝试获取位置时,它会询问该许可。如果你在考虑第二个控制器的位置,那么它可以完成,但如果你在AppDelegate中获得位置,恐怕它会在应用程序启动时提出要求。 – Wolverine

+1

尝试在AppDelegate中创建一个方法。并调用该方法当你想显示权限警告 – Wolverine

回答

0

感谢,这解决了对我来说,...

从应用委托

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)