3
votes

I am successfully using APN with my app in developer mode, but I cannot get it to work in adhoc distribution mode.

i've followed faithfully the tutorial http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12 and I've read all the other posts on this issue that i could find on SO and elsewhere.

in developer mode I create the cer and p12 pem files and combine them: when i try: openssl s_client -connect gateway.push.apple.com:2195 -cert aps_production.cer.pem -key MyPrivateKey.p12.pem, I get:

depth=1 /C=US/O=Entrust, Inc./OU=www.entrust.net/rpa is incorporated by reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C
verify error:num=20:unable to get local issuer certificate
verify return:0

-----BEGIN CERTIFICATE-----
(certificate deleted)
-----END CERTIFICATE-----
subject=/C=US/ST=California/L=Cupertino/O=Apple Inc./OU=iTMS Engineering/CN=gateway.push.apple.com
issuer=/C=US/O=Entrust, Inc./OU=www.entrust.net/rpa is incorporated by reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C
---
No client certificate CA names sent
---
SSL handshake has read 2723 bytes and written 2140 bytes
---
New, TLSv1/SSLv3, Cipher is AES256-SHA
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : AES256-SHA
    Session-ID: 
    Session-ID-ctx: 
    Master-Key: (deleted)
    Key-Arg   : None
    Start Time: 1348332242
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)

I don't know what the "verify error:num=20:unable to get local issuer certificate" means or if it is important. I get the very same thing when I use gateway.sandbox.push.apple.com:2195 with my developer cer and key, but it works fine.

when i then use simplepush.php with a developer version of app on phone. notifications work perfectly. when i use the same with adhoc distribution, and a adhoc distribution version of app on phone, i get nothing despite simplepush.php returning: "Delivered Message to APNS"

i've queried the feedback service, and there are no errors reported.

Others have suggested that APNS doesn't work for adhoc mode if the app hasn't been approved by apple. Is that the problem? Our app is still under review.

Thanks for your help.

1
I have had push notifications working for both ad-hoc dist builds and appstore dist builds, as well as dev builds. You must be using the wrong file somewhere or something is missing. I would advise you to start over with the instructions on Ray's site and check what you are doing several times, same goes for the contents of simplepush.php and server names that you connect to. (eg sandbox.push etc, or not)Luke
i was finally able to get this to work. even thought i had done this more than once, i started over. wiped out certificates, redownloaded, reconverted to pem, etc. created a new archive of app. Now it works. I have no idea which step made the difference. if it helps others note that even on success testing against gateway.push.apple.com:2195 getting the "verify error:num=20:unable to get local issuer certificate" did not seem to be important.mflac
Which is correct for adhoc builds, gateway.push.apple.com:2195 or gateway.sandbox.push.apple.com:2195 ?Jonny

1 Answers

0
votes
  • Any in-house distribution profile gives out a same tokenID, how ever this tokenID varies across different devices.
  • Make sure that the distribution provisioning profile is generated after creating aps_certificate. High changes the profile may miss out aps-environment key in the distribution certificate.
  • Other only issue could be only with the ProductionURL.
  • I have also notices that the push notification reception is delayed sometimes, mostly when used with production URL.