Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AdHoc build receives no push notifications

I am developing push notifications for an app of mine, I wrote the provider in PHP and it works fine. I was previously testing the push notifications with my dev builds and the sandbox server from Apple and everything worked fine, now I am trying to get it to work with an AdHoc build but I never receive any messages on the phone. Here is what I did:

  • Enable production push notifications for the App, create the certificate, download it, create the PEM following the instructions here and upload it to my server. Configured my PHP Script to use gateway.push.apple.com and port 2195 for the connection and test it, the connection to the server works as expected.
  • The Layout of the payload is the same as with the dev and writing to the stream works
  • After activating Production APN I recreated my AdHoc provisioning profile and verified after the build that in the entitlements aps-environment is set to "production" (which it is)
  • Installed the App through AdHoc on a device which has not run the app before, I get asked whether to allow PNs, click yes and my server receives the token just as it should.
  • Tried to send a message (which should get send to 3 devices) through the production environment. There is no error when connecting to Apple or sending the data but I do not receive a push notification on any of the devices.

I am really out of ideas what could be wrong, does anybody have an idea? Thanks a lot!

like image 683
Robin Avatar asked Sep 29 '10 10:09

Robin


People also ask

Can we receive push notifications in AdHoc certified test build?

AdHoc build receives no push notifications.

Why do I not receive push notifications?

Do Not Disturb or Airplane Mode is on. Either system or app notifications are disabled. Power or data settings are preventing apps from retrieving notification alerts. Outdated apps or OS software can cause apps to freeze or crash and not deliver notifications.


2 Answers

I finally figured this out, the issue is that if you open a connection to the APNS and send over more than one push notification AND one of the tokens you submit is not a token valid for this certificate (eg. you send over a token that belongs to a dev instance whilst being connected with the production certificate) the APNS cancels the delivery of all the PNs that you sent in this batch. At least that is what I experienced so far, so make sure you always keep your dev and production tokens nicely separated :)

like image 104
Robin Avatar answered Sep 23 '22 16:09

Robin


Push certificates for production and development are different. And to make more difficult device tokens for production and sandbox are different for the same device. Cross check if these are correct and Im sure you must have faltered in this. To get device token in Production mode, write an alertview in AppDelegate didreceivenotifications event.

Once you get this token, you will know that it is different from dev token that we are generating which is why you were not able to send notification on PROD

like image 21
Ravindra Naik Avatar answered Sep 22 '22 16:09

Ravindra Naik