4

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

Community
  • 1
  • 1
Rajan Maheshwari
  • 14,465
  • 6
  • 64
  • 98

3 Answers3

10

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: enter image description here

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.

nburk
  • 22,409
  • 18
  • 87
  • 132
  • we are not creating build for production. We are creating build for testing by uploading on diawi/testflight. We have followed ray's tutorial exactly same."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." If i have made any mistake then the notifications should not come in debug mode also. But they are coming – Rajan Maheshwari Dec 16 '14 at 11:39
  • When you upload a build to Testflight this automatically is a **production build**. There are 2 kinds of production builds: 1. App Store and 2. Ad Hoc, you are using an Ad Hoc build and an Ad Hoc build requires a production APNS certificate – nburk Dec 16 '14 at 11:41
  • we are not creating build for production. We are creating build for testing by uploading on diawi/testflight. For this purpose also we need to create the .pem for distribution ?please confirm this.. – Rajan Maheshwari Dec 16 '14 at 11:43
  • yes, this indeed correct! i guess you are using an **Ad Hoc provisioning profile**, right? this means what you are building is a _production build_ in the sense that it is not run from Xcode, and as a consequence to this you need to provide an APNS production certificate. – nburk Dec 16 '14 at 11:44
  • Oh God..It worked...Earlier this was not the procedure. But now in distribution we have to set the adhoc and then only push notifications can come.. Thanks all.. It worked – Rajan Maheshwari Dec 16 '14 at 12:34
  • @Rajan please consider marking my answer, as I provided the answer first and my suggestion actually was correct :) – nburk Dec 16 '14 at 12:58
3

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

Geet
  • 2,427
  • 2
  • 21
  • 39
  • we are not creating build for production. We are creating build for testing by uploading on diawi/testflight. For this purpose also we need to create the .pem for distribution ?please confirm this.. – Rajan Maheshwari Dec 16 '14 at 11:42
  • Yes, you do need to create a distribution profile and a distribution pem file, because an app in adhoc mode corresponds to the distribution environment. – Geet Dec 16 '14 at 11:43
  • Oh God..It worked...Earlier this was not the procedure. But now in distribution we have to set the adhoc and then only push notifications can come.. Thanks all.. It worked – Rajan Maheshwari Dec 16 '14 at 12:34
  • @nburk Thanks a lot to you too also...Can accept only one answer.. but voted you up. explanation was good – Rajan Maheshwari Dec 16 '14 at 13:29
0

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)?

hris.to
  • 6,235
  • 3
  • 46
  • 55
  • 1
    i am using exactly the same app id..same provisioning profile....and no wild card. This issue is not going.. xcode 6. I have followed Ray's tutorial exactly the same. The push notifications are coming whenever i make a build with xcode.But when uploaded to diawi or testflight..they never come – Rajan Maheshwari Dec 16 '14 at 10:43
  • You should check profile for TestFlight/diawi. Make sure push notifications are enabled and type of the certificate is iOS development(http://gyazo.com/bc47b72c3ff017bd9f44ff7710817b33). – hris.to Dec 16 '14 at 10:50
  • yes.. push notifications are enabled....certificate is of type iOS.Its been now 48 hours involved in this issue.. – Rajan Maheshwari Dec 16 '14 at 10:53