2016-07-28 70 views
0

突然我的應用程序無法生成設備令牌。 我創建了一個應用程序來接收遠程推送通知,應用程序運行良好,但今天我的應用程序不生成設備令牌,我在xcode上運行代碼並且不生成令牌。沒有委託方法調用。 我不改變任何東西,不工作更多。函數didRegisterForRemoteNotificationsWithDeviceToken不工作。看:我的應用程序無法生成設備令牌

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) { 
    print(deviceToken) 
} 

不打印什麼

這個函數什麼也不做:

func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) { 
    print(error) 
} 
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool 
{ 
    // Override point for customization after application launch. 

    let types:UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound] 


    application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: types, categories: [newsCategory])) 

    return true 
} 

爲什麼這個問題呢?我該如何解決它?

回答

0

註冊設置後,您還需要撥打application.registerForRemoteNotifications()application:didFinishLaunchingWithOptions

相關問題