3
votes

I'm to trying to test my push notifications while utilizing TestFlight.

I can successfully receive a push notification on a device when I deploy directly to it from Xcode. However when I deploy the app to the device via TestFlight (as an external tester) I get "BadDeviceToken".

I have created a "Universal Push Notification Client SSL Certificate" and followed these apple instructions to the letter (I think). As per link:

"The client SSL certificate that is generated is a universal certificate that allows your app to connect to both the development and production environments."

Has anyone got any ideas?

Thanks

FYI:

Relevant Application Service:

enter image description here

iOS Certificates:

enter image description here

2
how do you send notifications? What gives you 'BadDeviceToken' error?paiv
For testing purposes I am sending notifications via a unit test. I am using pushy. I copy the token that is returned post app install into the test.Hurricane

2 Answers

1
votes

ok, this was my silly error. I am using Pushy.

You specify the environment like so:

apnsClient.connect(ApnsClient.PRODUCTION_APNS_HOST);

Unfortunately I had specified DEVELOPMENT_APNS_HOST before. It would seem that when you use TestFlight you have to specify the production apns host.

Thanks for everyone that looked over the question and answered.

0
votes

You should try to re-create the certificates from scratch. Make sure that the certificates are production/distribution and not using APNS sandbox. Also, make sure it's on an actual approved device and not a simulator.

From the APNS Docs:

The specified device token was bad. Verify that the request contains a valid token and that the token matches the environment

Also, check out these two links (first one is old):

iPhone APNS Device Tokens in sandbox vs. production

https://salesforce.stackexchange.com/questions/119615/send-push-notifications-to-ios-using-apns