Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting 'unknown token' using GCM on iOS

I have installed GCM in iOS app and everything works fine in Development, I was abel to get push notification. But when I published it to the app store no push notification are coming to the device (works fine in Android).

I installed PersistentConnectionLogging.mobileconfig file on my iOS device to see the logs and here is what I saw:

Received incoming push notification for topic: com.bundle.id but for a completely unknown token XYZ

here are the exact output messages

Jun 24 11:45:35 iPhone apsd[103] <Notice>: 2016-06-24 11:45:35 -0700 apsd[103]: Received incoming push notification for topic: com.bundle.id but for a completely unknown token <95af08c3 c74a13bf 6b6fb270 c486f2b3 58989f44 dfe69bc0f 95u410e1 2431b8dc>
Jun 24 11:45:35 iPhone apsd[103] <Notice>: 2016-06-24 11:45:35 -0700 apsd[103]: <APSCourier: 0x137d035e0>: Responding with REMOVED status for message received with topic: 'com.bundle.id' to device token (instead of per-app token)

Any idea why this is happening? Why is the token "unknown"? To whom does it belong then?

like image 941
Maksim Avatar asked Nov 09 '22 13:11

Maksim


1 Answers

Have you tried testing your push certification? Houston on GitHub is often used for certificate testing. Basically if the pushes don't work with the third party then you'll need to re-create your certificates.

Using Houston in Cli:

apn push "<5e8f5cc0 be283f88 cc4ebb7d b6091499 80f51631 5ebf4928 b59a2a62 198d20d0>" -c -out "apple_push_notification.pem" -m "Hello from the command line!"

*Houston says, * We recommend that you upload development cert, production, and any ad-hoc certs. Layer will automatically determine which cert to use.

Other potential causes:

  • Are you correctly calling [layerClient updateRemoteNotificationDeviceToken...]?

  • Are you calling inside didRegisterForRemoteNotificationsWithDeviceToken to send Layer the device token?

You can also check to see if the app is failing to register by implementing didFailToRegisterForRemoteNotificationsWithError. If you look at the error you should be able to figure out why you're not seeing pushes.

Example Obj-C error check:

- (void) application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSLog(@"PUSH ERROR: %@", error);
}

Example Swift error check:

func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError!) {
print("PUSH ERROR: \(error)")
}

Potential Xcode/Certificate problem causes:

  • Provisioning profiles are not up-to-date. The device info is stored in the certificates so any time you add a new device to the profile you will need to re-create the profile and certificates.
  • Make sure that your XCode Project Settings is pointing the correct Certificate and Provisioning profile.
  • When inside the Keychain Access app make sure you are exporting the key AND the certificate.
like image 102
Edison Avatar answered Nov 15 '22 11:11

Edison