APNS device token in production phase on iOS9 from device that is enabled for testing

Hi,


Since upgrading to iOS9, my team has found what appears to be a bug related to the token generated from the Apple Push Notification Server in apps that are in the production environment when using a device with a UDID that is also registered as a test device in the Certificates, Identifiers and Profiles settings in the developer member center. So far we've only tested this on TestFlight


We've found that when building apps using an App Store provisioning profile for distribution and the entitlement: "aps-environment: production", the device that is also enabled for testing will always get a development certificate from the APN-server. Thus we receive an error code 8 (Invalid token) server-side when we try to transmit a notification to the device. We had a total of 3 devices registered and had the problem on all 3 of them. We removed 2 of the 3 devices from the Certificates, Identifiers and Profiles settings and published a new build on TestFlight. The 2 devices then received production tokens and the notifications were delivered correctly. The 3rd device, still enabled for testing, still gets the development token.


This problem has happened after building the app with the iOS 9 SDK Framework.

Thanks for bringing this up, I just spent a long time trying to figure out why I was no longer receiving pushes in my development environment and came across this thread. Evidently, I'm seeing somewhat opposite behavior. I've got an iOS 9 UDID registered in the Devices section of the member center, running my app in Debug deployed via Xcode, and am receiving a production push token. Running Xcode, 7.0.1 (7A1001), iOS 9.0.1 (13A405).


May I ask how you knew the token was for the wrong environment? The only way I was able to tell was by pushing with a production certificate rather than development and then successfully receiving the message. If I could tell from the token itself, then at least I could still support both the "broken" and "expected" versions of my app simultaneously.

I have the same issue after update to xcode 7.0.1.


I dont know how to test push notifications in production enviroment now, i have 2 devices and both are getting development token.

Also getting this issue. We have a device that will only get a development(sandbox) token, and another device that will only get a production token.


We mistakenly sent a development build to the store and users installed it. So now we've basically got to try both prod and dev for each token and store which one didn't get an error 8.

Use the following methods to test this:


Quick(er) method - uses "Ad Hoc" profile:

1. Make sure the device is registered in the Apple developer console.

2. Create an Ad-Hoc profile that includes this device.

3. Download and install the profile on your development Mac.

4. Disable the device in the Apple developer console - this will invalidate the Ad-Hoc profile created in step #2, but it is already downloaded and installed, so that's not a problem.

5. Archive a build of your app and distribute it e.g. via Crashlytics or HockeyApp.

6. Install the build on the device.

7. Test push notifications - they should now work because the correct "production" token will have been generated.


Slower (but possibly simpler) method - uses "App Store" profile:

1. Make sure the device is either not registered in the Apple developer console, or is disabled there.
2. Archive a build of the app, and upload to Apple.
3. Distribute the app via either the "Internal-Tester" (quickest) or "External-Tester" (requires beta review) Testflight.

4. Install the app via TestFlight.

5. Test push notifications - they should now work because the correct "production" token will have been generated.


I've just used the first method and have successfully generated a production token on a device that wasn't previously receiving production push notifications (and was causing "invalid token" responses).

I am also having this problem -- I have double and triple checked and regenerated my profiles and certificates.


The problem is when I run a development build with a development provisioning profile on my device, and I log the device token returned when I register for push, I cannot push to that device token using the sandbox enviroment.


I AM able to push to that device using the production environment. This should not be possible.

Hey, we're facing the same issue. What helped us is that we removed the provisioning profiles from the devices. It is worth a try.

Did anyone figure this one out? I'm having the same issue as described by cells.

APNS device token in production phase on iOS9 from device that is enabled for testing
 
 
Q