Can't get device token when distribution - ios

When in development, it works well, I can push notification to device.
but when distribution I can't get notification.
After debug I found the reason is that my server didn't receive device token from app.
I'm sure I used the correct provisioning and enabled the apps for both development and production.
anybody knows what's the reason that app can't get device token?

Related

iOS Push device tokens getting always BadDeviceToken

I hope I find a person who can help me. I have a iOS App in the App Store and the push device tokens I get, are wrong. Over the APNS Server (production and sandbox) I always get the answer: BadDeviceToken.
The app is developed with cordova, ionic and I use the phonegap push plugin.
When I deploy the app in debug mode directly to my iPhone, I get a token that is valid in sandbox and production.
But all tokens I actually get from iOS are all wrong.

will push notifications with Production-SSL certificate work when I'm still testing my app? How can I know it will work?

My push notifications are working fine with the sandbox model. I just verified that the production ssl certificate is working both with direct SSL-connection and with AWS SNS. However, my device is still producing the same push token as it produced for the sandbox, and this token is not working for production-level push notifications (rejected as invalid token by Apple server). Is it supposed to work? How can I make sure push notifications are working/will work for users who download the app from the app store?
Create a provisioning profile for "Ad Hoc" distribution, using your production certificate. Sign your app with that and install. Make sure your SSL connection to APNS knows which certificate to use, depending on whether client is production or dev.

Not getting push notifications with ADHoc certificates

I am testing push notifications with production.pem with ADHoc provisioning certificates. From server side sending successfully but device is not getting notifications. Please help me
Thank you
The Server will show success means the problem is at your side, Check the below three scenarios for this
1.) The gateway should be gateway.push.apple.com:2195
2.) You have refreshed your provisioning profile after creating APNS certificate
3.)Your Device Token is correct corresponding to the Distribution Provisioning profile
N.B If all the above things are correct,then make sure your app is in background, If your App is in foreground, then you will receive push notification, but wont be able to see it
Keep in mind that the Ad hoc testing of push notifications only works if the app was installed on a device without using xcode+usb cable to install the app on the device. The app has to be delivered to the phone with either TestFlight (or similar) or something else like diawi.com
You can check in server side.
List<PushedNotification> notifications = Push.alert("TEST TEST",keystorePath,"test", ***true***, devices); => For Distribution
For development => List<PushedNotification> notifications = Push.alert("TEST TEST",keystorePath,"test", ***False***, devices)
Check your device token. There are two device tokens. First one is when you run app with development other one is run app with production. These are difference. Use Ad-hoc device token.

Regenerating iOS APNS Certificate; Device Tokens Affected?

My iOS APNS certificate expired and we (our iOS developer and I) ended up revoking the old certificate through iTunes Connect and completely starting over after having some issues. Everything is working now and I was able to send test notifications to our devices.
However, we had to regenerate the device token before any notifications came through. I believe this issue was because our devices were previously on a development version of the application (different tokens), and we were attempting to use the production token.
Does anyone know (and can back up with documentation) if device tokens will persist through the revoking/recreation of our APNS certificates? If not, I will have to delete all of the existing tokens and wait for users to re-open the app.
As you said, you had to regenerate the device tokens only because the same device gets a different device token for the sandbox env and the production env.
Creating a new certificate doesn't change the device tokens (and pre-iOS7, all the apps on the same device had the same device token, so changing the certificate of one app couldn't affect the device token). I've never seen this documented, but this is the behavior I experienced, and it makes sense, since the push certificate is not part of the deployment of the app (it's only used in the server side), and therefore changing it can have no effect on the device token (which is received by the app).

Apple push notifications only working on one device

I have push notifications working on my main development device... but it is not working for my test device (using the same application). Does the test device also need to be set up as a development device? The app works.. it just does not populate the device token up to the server. I need to be able to send the app to testers and have push notifications work for everyone.
Beware that an app built with a development provision profile, must be notified trough the sandbox-version of the PNS-service with a development push certificate. If your application is built with a distribution sertificate ( either ad hoc or App store), you must use the production PNS-service with a production push certificate.
Hope this helps:)

Resources