0

私はiOSアプリケーションを設定するためにGoogle Firebaseのルールに従います。私が使用されていないFirebaseコンソールデバイスID(トークン)に与える場合は、通知が私のアプリでキャッチ、しかしのUserInfoは空です:/* HERE */コメントに伴い、アプリのFirebaseメッセージングiOS:usersInfoが空であるか、通知されません

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], 
        fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) { 
    // If you are receiving a notification message while your app is in the background, 
    // this callback will not be fired till the user taps on the notification launching the application. 
    // TODO: Handle data of notification 

    // Print message ID. 
    print("Message ID: \(userInfo["gcm.message_id"]!)") /* HERE */ 

    // Print full message. 
    print("%@", userInfo) 
} 

userInfoがnilであるためクラッシュします。

Firebaseコンソールから別の通知をもう一度やり直すと、通知はキャッチされず、何も追加されません(受信通知機能にブレークポイントがあります)。

どういうところが間違っていますか?

答えて

0

このエラーを引き起こしたデバイストークンではなく、生成されたFirebaseトークンを使用していることを確認してください。

print(FIRInstanceID.instanceID().token()) 

私はこのコードの内部に置く:

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {} 
をあなたが必要とするトークンを得るためにあなたのコードでこれを配置する必要があります
関連する問題