2016-11-08 10 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.別のクラスから呼び出すアプリデリゲート

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

から呼び出して...、私のためにそれを解決しますそれで、それは間違いなくLaunchの許可を求めるでしょう。 – Wolverine

+1

2. GPSの場合は、場所を取得しようとしているときにその許可を求めます。 2番目のコントローラを考慮して場所を取得している場合は、それを行うことができますが、AppDelegateで場所を取得している場合は、アプリの起動時に尋ねられます。 – Wolverine

+1

AppDelegateでメソッドを作成してみてください。そしてその方法を呼び出す許可の警告を表示したいとき – Wolverine

答えて

0

おかげで、これは

あなたはAppDelegateで通知を登録

let notificationTypes : UIUserNotificationType = [UIUserNotificationType.Alert,UIUserNotificationType.Badge,UIUserNotificationType.Sound] 
    let notificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil) 
    UIApplication.sharedApplication().registerForRemoteNotifications() 
    UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings) 
関連する問題