'INVALID_TOKEN' When Sending Push Notifications
-
Okay - the two symptoms:
#1 - You say you never got that push from the pushtry tool. I assume your app wasn't running at the time? Apple hides push notifications from apps if the app is currently running. Try again?
#2 - When you say you can't send notifications, you mean they aren't received - just like #1, correct?
Talking to one of our devs now. He mentions that you need to ensure that the app that's running on the device is built with the correct "entitlements". He's gonna provide more info...
Stay tuned...
Paul.
-
Can you confirm that the cert that you made was for Production? AND! that the apps entitlement was set correctly.
https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment https://developer.apple.com/documentation/usernotifications/registering_your_app_with_apns
By default when building from xcode, the default Push Notification Entitlement is development, ensure this is set to production.
Have you confirmed you received the Push notification from pushtry.com on your device ?
-
And note, if you change the entitlement, after rebuilding, you'll need to re-run the app on your device - which I believe will cause it to register a new, updated device token... You'll want to use that one for your tests...
Do I have that right Steve?
-
Correct! @Paul-Winterhalder Keep us updated @Joseph-Wiemer
-
#1 - My app was not running at the time, and I tried again.
#2 - That's correct. And I'm still getting the same INVALID_TOKEN error in "Recent Errors".My app does have the correct "production" entitlement, yes.
-
@Steve-Jones Yes to both. My cert is for distribution and my app entitlement is set to "production". No, the notification from pushtry.com never appeared on my device, despite the service claiming to have been successful.
-
Dumb question - do you have any other devices that you can load your app on and try with? It's certainly suspicious that pushtry isn't working for you.
At this point I'd be removing the app from the device, re-installing, re-running (to register what I believe would be a new device token), and retrying the send - both from pushtry and brainCloud.
If both pushtry and brainCloud don't work - the common denominators are your app's configuration, the device itself, and Apple's servers...
-
@Paul-Winterhalder Yes, I do have other devices I could try. I realize this probably isn't a brainCloud problem, so I appreciate all the help you guys have given me, here. Thank you, and I'll keep trying to figure it out.
-
@Joseph-Wiemer No worries - good luck! And keep us posted!
-
Ok guys, I've solved it! It was some godforsaken problem with my .p12 file.
- Tried creating a .p12 file by exporting both the private key and the cert. FAILED.
- Tried creating a .p12 file by exporting just the private key. FAILED.
- Tried creating a .p12 file by exporting just the cert. SUCCESS.
So, notifications are now working for me. Not sure how to mark this question as solved, but it's solved. Thanks for all your help!
-
Awesome - glad to hear it!
I'll mark it resolved for you.
Cheers!
Paul.
-
I just got our iOS Push Notifications working with brainCloud and would like to add a few tips to this thread.
- For the less Mac-Savvy developers like me, here's what it looks like when you only have your certificate with no private key to export as a P12 file:
Notice the selected category is [My Certificates]. Certificates in the [Certificates] category have the P12 export option greyed out.
- I am using Unity as a development platform and for some reason my device would only receive Development Push Notifications even when running in Release in Xcode. It's only after uploading to TestFlight that my Production Push Notifications started working.