48

Until now I used development push certificate and the push notifications worked great.

Now I want to submit my app to Apple so I created a production certificate and set it under "code signing identity" -> "Release"

I also placed the .p12 file in my production server.
But the push now does not work.

Is it suppose to work when I run from xcode? or will it just work when downloading the app from App Store? If so how can I test it?

Mat
  • 202,337
  • 40
  • 393
  • 406
Eyal
  • 10,777
  • 18
  • 78
  • 130
  • possible duplicate of [iPhone: Push Notification Testing on Production Certificate](http://stackoverflow.com/questions/6413188/iphone-push-notification-testing-on-production-certificate) – Maen Aug 18 '14 at 16:20
  • Use TestFlight to share your app and follow this answer---> https://stackoverflow.com/a/48890938/2564702 – Md Rais Mar 16 '18 at 13:33

5 Answers5

51

You can test APNS production environment building an AdHoc version of your App. The app will be using the production certificates and servers and it's purpose is exactly to test BEFORE you send it to AppleStore.

Take a looke at this link: what kind of certificate do I need to test apns using ad-hoc distribution?

Community
  • 1
  • 1
Trinca
  • 1,606
  • 1
  • 15
  • 17
  • To be clear, you don't *build* an Ad Hoc version of your app. You build a release version of your app, and you **distribute** an Ad Hoc version. It is the distribution that changes the entitlement aps-environment to `production`. – Ben Butterworth Aug 28 '21 at 19:59
35

The production push will work when you download the app from the App Store.

UPDATE:
You can also test the production push with an AdHoc build of the app; see Trinca's answer.

UPDATE:
Now, the easiest solution is to use Apple's TestFlight. (In TestFlight, it is easy to add new remote users, sending them an email invitation, they then download on whatever device they choose.)

Community
  • 1
  • 1
FrediWeber
  • 1,099
  • 1
  • 10
  • 21
  • No. you can test it with the dev push certificate. – FrediWeber Sep 20 '12 at 19:11
  • 9
    It's wrong. You can test the APNS production environment with AdHoc distribution. Answer below. – Trinca Dec 20 '12 at 15:13
  • 2
    It seems that this has finally changed with iOS 10 - I just stumped into this. Even with adhoc and/or testflight (distribution certificate builds), the apps only receive dev pushes, and never production certificate pushes. Production pushes might basically only work with apps downloaded from app store? I'll look for some info on this. – Jonny May 07 '17 at 02:36
  • 1
    @Jonny, No, it didn't change. As of iOS 10 DEBUG builds gets Sandbox APNS and RELEASE builds (either app store, testflight or ad-hoc) get production APNS. Check your setup because there should be an error around. – Hernán Pentimalli Sep 08 '17 at 13:48
  • Ok not sure what happened but you are right if by release you mean distribution certificate builds. – Jonny Sep 10 '17 at 00:32
13

Create an Adhoc distribution profile for your app in provisioning profile. Download profile and install. Choose the Adhoc dist profile to code sign your app. Archive ipa and save for adhoc distribution. Copy ipa to your device and test push. It will use production push certs as opposed to development cert. Hope this helps.

Alex McPherson
  • 3,185
  • 3
  • 30
  • 41
  • do we need any code change in php code while testing in development and production? – hardik hadwani Nov 20 '14 at 06:41
  • 3
    You need to change the Apple URL to point to the non-sandbox URL... ssl://gateway.sandbox.push.apple.com:2195 to ssl://gateway.push.apple.com:2195 – eharo2 May 04 '15 at 02:51
2

Testing production notifications (without releasing the build) is possible when the app is installed via Apple TestFlight.

This way the production notifications will be delivered to the app.

(If the exactly same build is installed via HockeyApp or by other means, the production notifications won't be delivered.)

Just set the build to internal testing after the build has finished processing in iTunes Connect.

Peter Lamberg
  • 8,151
  • 3
  • 55
  • 69
1

If you want to test Push Notification on production environment, you need to take care of few things:-

  1. Production push notifications can only be tested on ipa. You need to create ipa from AdHoc Distribution profile.
  2. You need to replace the Push certificate on your Push API server. APNS Distribution certificate is to be used in this case.
  3. If your API is in DOTNET then you need to change the boolean value to true.
  4. Change Code Signing Identity to distribution on both Projects and Targets
Arun
  • 483
  • 6
  • 20