2016-11-19 6 views
0

알림 권한이 주어 졌을 때만 didRegisterForRemoteNotificationsWithDeviceToken이 호출되었다는 것을 사용자가 알게 될 때까지 사용자가 알림 권한을 부여했는지 여부를 확인해야하지만 일부 장치에서는 권한에 관계없이 호출됩니다 주어진 또는 아닙니다. 누군가가 허가 상태를 확인하는 방법에 대해 나를 도울 수 있습니까?iOS Swift, didRegisterForRemoteNotificationsWithDeviceToken

didRegisterForRemoteNotificationsWithDeviceToken 내가 알림 액세스 권한을 거부 할 때도 호출되고 있습니다.

답변

0

스위프트 3.0 엑스 코드 (8)

UNUserNotificationCenter.current().delegate = self 

UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert], completionHandler: { (granted, error) in 
          if (granted) 
          { 
           UIApplication.shared.registerForRemoteNotifications() 
           //Allow Push Notification 

          } 
          else 
          { 
           //Don't Allow Push Notification 
          } 
         })