Push notifications not received via TestFlight - ios

My app is currently being tested by testers via TestFlight. The problem is that they don’t receive any push notifications sent. It’s working on my own device when connecting it to my mac and running the app directly from x-code.
I feel like I’ve tried almost everything, from changing certificate from dev to production to recreating a new production APNS certificate and build using a new profile referencing it, etc.
I know this question has been discussed on other topics but I never found the right answer in my case. I can't post images here because I don't have enough reputation but I have relevant screenshots.
Any help is welcome :)
Elements to help diagnostic :
It’s working on my device when I run the app directly from x-code.
The testers are asked properly if they want to authorize push notifications on their devices (at least the first install, after if they want to get asked again they have to do what’s described in Reset push notification settings for app)
The registering is working because I can see their devices tokens in the logs (but I have the feeling that the token is always the same, no matter if the app is built with the production or the dev certificate, not sure if it’s normal).
I have an APNS Production certificate.
I have a distribution profile, with “push notification” enabled. It’s linked with my “full” appID (and not the generic one with “*”).
I’m signin the build in release mode with the distribution certificate (not in debug mode), and I’m using the provisionning profile described above (the distribution one, linked with my app id)
And when I check in the "binary & entitlements" window just before submitting the build I see the the provisionning profile is correct and that "aps-environment" is set to "production".
Server-side : The APNS call is made by using javapns (https://code.google.com/p/javapns/) from a google app engine server. Like I said the notification are correctly received on my own device so I guess this call is working. We have a .p12 file generated from the APNS developpement certificate and a .p12 file from the APNS production certificate, and I've tried to make the call with both and it's not working. The server-side code hasn't change from the previous version and it was working in production with the app on the store. The problem is really focused on testing with testflight.
Thank you all !

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:

Related

Xcode: push notifications to build on device work but not to TestFlight/App Store install on same device

I've realized that I can test push notifications in development and prod builds on local devices- but they don't work with real installs from TestFlight/App Store.
I think this has to do with Xcode's signing of builds vs. archives, but I cannot figure out what to do to fix my current configuration. I use the Xcode auto signing, FYI.
I use Mixpanel for event tracking and notifications, which also lets me confirm the device token is being retrieved successfully. I have my production push certificate uploaded there.
If I have a build running on my device, I can grab the token from a log message and send a push to it (using my prod push certificate) with a different utility called Pusher- this works perfectly.
However, if I download my app from TestFlight or the App Store, start it, get the resulting token from Mixpanel, and send another notification via Mixpanel, it never shows up. Going back to Pusher, if I attempt a push with the token from Mixpanel, I get an APN invalid token error.
Both of these tokens were grabbed the same way- immediately after the user agrees to notifications or the push plugin finishes setup. They were also grabbed on the same code- but one from a running Xcode build, the other from an archive on the TestFlight.
Project setup- I have the Push switch set to on in the Xcode Capabilities menu, and I've generated push certs for dev and production (well, 2 for prod by accident. I figured it was fine):
I also have the Distribution and Dev provisioning profiles created. This is where my question lies- I read that Xcode doesn't use the Distribution profile you create until archiving, and uses it's own until then if you have Automatic Signing selected in the code signing settings.
Is that why I have 2 profiles here? The one I created shows as Active & also lists Push Notifications under services if I expand the entry below:
The cert my production provisioning profile is signed with is an iOS Distribution certificate that matches the team I have selected for signing:
While writing this up I realized that maybe my release build settings, specifically signing, were wrong. I though they should also be using my Iphone Distribution: MyCompany Inc (USA) certificate (instead of the default iOS Developer identity), since my Distribution provisioning profile is signed with that same certificate. Unfortunately this doesn't seem to work either.
If my build settings look like this (or if I select the generic iOS Distribution from the dropdown for Release identity):
I can't actually build- I get an error that there are conflicting provisioning settings. If I use the iPhone Distribution: MyCompany Inc (USA) certificate just in the Release line (not the Any iOS SDK line), I can create an archive, but I see the same behavior.
I thought for sure this was it, since I've been using my MyCompany Inc (USA) development team for provisioning when validating/uploading archives.
I also tried turning off automatic signing and setting the debug and release profiles to the dev and prod provisioning profiles I made in the Apple Developer site. No luck there either.
Just to come full circle- this is the archive summary information I see when using automatic signing:
This is correct, right? The identity listed was used to sign the selected provisioning profile, so that should be all I need as far as proper signing, right? Given the other setup, of course.
I'm completely stumped at this point- how am I supposed to configure signing for archives?
This didn't end up being a signing issue after all- while I'm still a little bewildered on exactly what I need to do for signing release builds, it seems the Xcode automatic process handles it properly, given that the correct provisioning profile has been created in your Apple Developer account.
There were 2 issues here:
The Pusher utility I was using to send pushes to test devices has an option called "Should use sandbox environment" that's checked by default. Once I unchecked it, I could send pushes to devices that had downloaded TestFlight/App Store builds. I didn't realize the production push certificate could be used both ways.
At the same time, I was still having issues sending notifications from Mixpanel. It turns out that, for some reason, some of the devices I try to push to (even with Pusher) don't seem to get a notification with a certain priority level. By adding "priority": 10 to the custom data of a Mixpanel test notification, I am able to successfully send/receive them. I figured this out by playing with the dropdown in the screenshot of Pusher below:
My own device would receive pushes with any of these 3 levels selected, but other devices would only receive pushes with the "Immediately" level or "Priority: None" level selected. Why? I have no idea.

Push notifications don't work in Apple Beta Testing (TestFlight)

Push notifications worked fine with a Development provisioning profile, but once I tried putting the app on the Beta testing programme (TestFlight), they don't.
I tried following all the required steps when switching to a Production profile, but it still doesn't work. Here's what I have.
In the Member Center:
Certificate of type iOS Distribution.
App ID. Named (not wildcard). Push notifications enabled for both Development and Distribution - green lights - with all SSL certificates generated and uploaded.
iOS Distribution Provisioning Profile, that uses the above mentioned Certificate and App ID as well as lists Push Notifications among enabled services.
In XCode. Target > Build Settings > Code Signing:
Provisioning profile - iOS Distribution, same as in Member Center.
Code signing identity (both Debug and Release) - iPhone Distribution.
Am I missing something (not so) obvious? Any help would be greatly appreciated.
Everything seems correct. Maybe you should precise what is not working :
App not registering to APNS token at all
App correctly registering but push not received
Process to the following checks
App not registering to APNS token at all
Mobile Provision
Make sure you refresh your mobileprovisions through XCode after enabling push to be sure those includes the correct entitlements. You can check this by opening the mobile provision in an editor and look for the aps-environment key?
Registration to APNS
make sure the code to register to APNS does not depend on any personal settings (like a Push Id for some SaaS push service that is missing)
.
App correctly registering but push not received
Check that the pushToken received is sent to the correct environment of your server (the one that connect to APNS)
Check that your server is using the Production APNS Certificate
As it happens, I failed to provide full context in my question. I use Parse.com to handle my backend as well as push notifications. So what I was missing was a production certificate on Parse.com, not just a development one. So, if anyone else is using Parse and ran into a similar problem, I hope this is helpful.

APN works in development not in distribution

We have an iPhone app that uses APN, the testing was perfect on sandbox, now the problem we are seeing is that APN is not reaching the phone on production, is this a known issue on the iPhone? Our app was just approved two days ago.
We checked everything mentioned here,
I understand this question is very hard to answer and I guess what I'm looking for is any hints.
This is what I made sure of:
I am using different APN token for production than development
The provisioning profile has Push Notifications enabled
Apple APN service responds successfully without and don't report any issue.
Certificates seems to be fine. And when I unzip the ipa I see aps-environment refers to production in the distribution ipa.
Downloaded the Store ipa and unpacked it, yet to find that it also has the aps-environment set to production.
UPDATE:
I removed all the certificates and provisioning profiles and created a new Production/Distribution certificate with Push Notification support.
Now, when I installed the store version, the APN didn't work still. However, I used the latest Ad-Hoc built I have locally and the APN is working fine. I decided to replace the Ad-Hoc with the Store version, and behold, the APN started to work. I am not sure what's the issue, I'll have to check on other phones to see if it really works. Have anyone had similar scenario?
Old question, but I had the same troubles.
Just found this link: iPhone iOS push notifications apns on production not sending
For production you need a different URL to push your notifications:
ssl://gateway.sandbox.push.apple.com:2195 Development
ssl://gateway.push.apple.com:2195 Production
This fixed it for me.

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

Not receiving Apple push notifications / Possible provisioning profile issue?

I've been trying to debug push notifications, but they fail silently so it's been difficult. As far as I can tell, I've correctly followed Apple's instructions, so I was wondering if anyone else sees any issues with my setup:
It used to be working, using a development certificate and a Debug build of my app. When I created the AdHoc build to start testing with others, that's when the problems started. I created a production certificate, which I'm using now on the server. I also changed the APNS destination from sandbox to production. I updated the provisioning profile (and <key>aps-environment</key><string>production</string> is present as required), and rebuilt and packaged the app as an IPA (using the new profile) which I distributed to my testers through TestFlight. I can tell that it was definitely packaged with the new provisioning profile, since I added a new tester at the same time, and TestFlight shows the new tester.
I got the testers' new device tokens and sent them all a simple alert notification: {"aps":{"alert":"hello"}}, but no success. Any tips?
One thing I found weird: I thought device tokens were supposed to change when you have a new provisioning profile? But for all my testers it seemed that the device tokens were the same ones as before. I thought that maybe the provisioning profile wasn't getting updated on their phones for some reason, so I asked one of them to delete the profile from his phone settings (by the way, there turned out to be two of them for the app, with the same name), and re-install the app using TestFlight. But, his device token actually still stayed the same. Any tips? Thanks in advance!
In case anyone else is having this problem, here's the solution: It seems to be caching the device token, so try just creating a new app in the dev center for your AdHoc build.

Resources