Push notification is not working in production certificates - ios

I am facing issue during push notifications when app is installed on IOS(8.3) device(iPhone and iPad).
Its working locally(in development). But when I configure the same in production( upload app to app store ). It is not working.
These are the configurations that I have done:
* In Xcode, in entitlement file, for "APS environment" key i have given value as "production".
* While creating the SSL certificate i have created the production SSL certificate.
* In code i have used "withProductionDestination()" method while pushing the notification to APNS.
I am not geting any error or exceptions while sending the notification payload with token to APNS(both in production and development).
I have verified that the notifications feature is active in my account for both development and production. I have also verified the certificates and they are correct.
Can you please let me know what steps I might have missed or doing wrong?

Device token for Production (distribution) and Sandbox (developer) are different for same device.
I was also facing the same issue that push notifications were not coming in production and problem was that I was still using device id which I received in developer mode. So, I generated device id again with production certificate and notifications started to come again.
Also, make sure that you access the production environment at this URL gateway.push.apple.com with port 2195.

If you use production certificate for push notifications, you need to remove .sandbox in the apns server address and if you install the app by using Xcode, generally by using run option, then the mode will be set to development and the push notifications from production environment won't be received. You need to install the app by generating the .ipa file and install in from iTunes.

I had the same issue. PN's were working on development, but couldn't get them on production.
What helped me: Adding APNS for Distribution Certificate to Firebase.

Related

If push notification can be sent successfully on development device, why the app can't receive the push notification when installed ad-hoc?

I'm developing an app that uses push notification. When tested on development device (e.g. installed using cable connected to the Mac), it can receive push notification correctly. But when it's installed using ad-hoc means, no push notification received.
But, the app can obtain the device id on both development and ad hoc scenario. This is evident by the device id received and recorded on the server. The server receives device id on both development and ad hoc scenario. But even then, if the app is installed using ad hoc means, it's not receiving any push notification from the server.
PS:
I'm using Xcode 8.2.1 and Swift 3.
I have created the certificate using SSL push notification for distribution and development, and have included (double click) the certificate on the Xcode.
I have made sure that the capabilities for push notification is ON. Both steps on push notification are also has ticks.
I archived the app using Xcode automatically manage sign in. Xcode is supposed to linked in all the correct certificates for me, including the certificates for SSL push notification for distribution and development... right?
What is your thought on what's wrong with this, and the solution for this? Thanks.
EDIT:
When I tried to use manual code signing, here's what I got:
I can't resolve the status issue. I know that the debug is supposed to have different provisioning. But for now, that's not the main issue. If I can solve the status issue, I also can solve the different profile.
You need to make sure if the certificates for the push notification in adhoc environment are created fine. Secondly, the UDID is getting saved on server properly or not.
Firstly, you should check your uuid of mobile provision in ipa is correct by running command security cms -D -i yourprovisionname.mobileprovision in bash.
the trailing lines
<key>UUID</key>
<string>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</string>
you can unzip your .ipa file and find embedded.mobileprovision in your Payload/App
If mobileprovision is correct, you should check your certifications.
Note that The certification of production environment is different than sandbox.
After checking the certification, you can check the server side. When we push to a sandbox(development), we push to address gateway.sandbox.push.apple.com, and in the distributed environment, we push to gateway.push.apple.com(no sandbox).

Testflight - Universal Push Notification Client SSL Certificate - BadDeviceToken

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:
iOS Certificates:
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.
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

Push notification is not working with iOS9 and above

I have tried these bellow ways:
I noticed was the Device Token gets changed for every fresh install which is kind of weird as we have to update the server for every new instance. Now i have fixed with save UUID in keychains.
I have created development provision and check. But not getting any luck.
I have created Adhoc provision and check. But still not getting PN.
Depending on how you distribute your app you may either be on the sandbox or the production server. Your token will only work for the server that the app is provisioned for.
Additionally, the machine that you're sending push notifications from will need to have the correct certificate and key to interaction with the APNS servers.
One thing to watch out for is using the same Certificate Signing Request for both the development and production APNS certs, some services won't properly send if they detect the wrong certificates in a .p12 file and keychain access will export more than two items if you used the same CSR.

iOS Push Notifications not working with Development certificate

Situation: we have PROD and DEV APN certificates installed on different backend URLs. PRODUCTION certificate works!: pushes are delivered.
DEV certificate does not work, apple servers return error code 7 (invalid token). I have already checked all the stuff but may be I'm still missing something.
app id is correct (same used for prod)
i use right backend (with DEV certificate installed)
I start the app from XCode in DEBUG mode (corresponds to DEV environment)
I use proper app development certificate, from the same account
I use proper dev profile (pushes are supported in it)
Should actually work, right?
In case of IOS 9, please send notifications from Apple Production Push notification certificate, it will work.
Make pem file from Production APS certificate, and use this file both in development as well as production mode.
Moreover, use gateway of production in both cases which is "gateway.push.apple.com:2195"
Don't use "gateway.sandbox.push.apple.com:2195" even if you are sending notifications in development mode.
The device token returned by the phone for push notifications is different in production and development. Make sure that your server uses an actual development device token (I'm not talking about the certificate but about the device identifier) when making a request to APNS.
If your device already run the production build of your app, the production token may be in your database and your server may try to use it. Depends on how you handled your user accounts though.

Push notifications not coming when we download the build from testflight or diawi iOS

I have successfully created the .pem and .p12 file by
http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
Tutorial.
We are using java as a server so I also exported my .p12 key using this link as there was an error of directly exporting the .p12 file
Cannot send push notifications using Javapns/Javaapns SSL handshake failure.
Everything is working great in debug mode. Whenever I install a build by xcode I receive the push notifications successfully everytime. But after archiving and uploading the build on testflight or diawi and then installing it on the device I didn't get any push notifications. I am successfully getting the device token from apns server. On debugging at server side we found that the device token they receive and send the notifications is invalid. This response is sent by the apns server to our java server. . I am using Xcode 6.0 or later and my app is compatible with ios7.0 or later. And yes I have made checks in registering for remote notifications for ios 8 and 7.Has anyone has faced this issue because earlier in xcode 5 series this hasn't happen. Please help
Any help will be appreciated. Thanks
If you followed Ray Wenderlich's tutorial and you made everything work in development mode, the issue most likely comes the fact that you now need to create a new .pem-file for production mode.
So, you need to perform exactly the same steps that you did with the development certificate (i.e. the .p12-file) you downloaded once more with the production certificate which you can obtain in the iOS dev center as well:
Here is the quote from the tutorial that you probably overread:
If you’re ready to release your app to the public, you will have to
repeat this process to make an Ad Hoc or App Store distribution
profile.
1.)Check if the pem file you have stored on your server is created by using a development certificate or distribution certificate, for push notifications to work through ttestflight you need to create a pem file in the distribution mode,
2.) also check if the gateway you are delivering to is gateway.push.apple.com:2195, and not the sandbox one,
3.)the notification tokens are also different for development and distribution profile, check all these scenarios and see
In order for push to work you have to use the exact same AppID for both creating APNs cert and Provisioning Profile. Wildcard profiles cannot be used for push notifications. May this be your problem(using wildcard or just different AppID for TestFlight/diawi)?

Resources