4

From what I understand, if there are multiple apps with different App ID installed on a device, the tokens for push notification generated for each apps should be unique one to another.

In my case, I have several apps compiled with different provisioning profiles and each of them is based on different App IDs (though some of them has same Bundle Seed ID, some don't).

For each app I generated development push notification SSL and export the SSL to generate PEM. Next I download the provisioning profile and applied it to XCode.

When I tried to run it on my device, what I get from :

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken

on ALL apps are a single same device Token. I wonder why is that?

And when I tried to push a notification via my server, there was no error message received. But the notification never delivered to installed devices.

Please give me suggestions on the problem. Thanks in advance.

Willy
  • 9,681
  • 5
  • 26
  • 25
  • 2
    The single device token is correct. I developed several apps that uses the same server for push and get there message correct even if there are on the same device. I think it's a kind of magic.... – AlexVogel Sep 29 '11 at 09:10

2 Answers2

21

The device token is not unique for each application, no matter if it is the production or development environment. You might be wondering, if the device token is the same for all apps then how is it possible that push notifications are routed to the right devices and the right applications? The answer is the app's unique bundle id. Each and every application on the App Store has a unique identifier, e.g.: com.mycompanyname.dummyapp. When an application registers itself for push notifications both the app bundle id and the device token are registered on Apple's servers.

Willy, one last thing that you might want to check, the very first step when configuring Push notifications is the creation of a CertificateSigningRequest.certSigningRequest file from the Keychain manager. If you have 2 apps you have to do this step twice so you end up with 2 different files that will be used in Apple's portal to create the SSL.cer file. Your problem might be that you used the same .certSigningRequest to create the different SSL.cer files instead of using a different one.

Ivan Sanchez
  • 539
  • 4
  • 8
  • 3
    We had issues with a deployment where one project generated multiple targets, each with it's own unique app ID and push notification certificates. Yet certain targets received all push notifications whereas others received none. After a lot of head scratching, we realised the same certificate signing request was used to generate all push notification certificates. Recreating all files with unique certificate signing requests did the trick. Excellent answer @Ivan Sanchez – Thomas Verbeek Apr 09 '14 at 05:12
  • ios 7 handles device tokens differently (they are unique per app): https://stackoverflow.com/a/20111644/289319 – user24957 Oct 16 '17 at 20:40
4

For development provisioning profiles, the device token will be the same for all other apps on that device using a development provisioning profile.

In production (the App Store), the device token will be unique for each application as far as I know. But I'm not 100% certain.

As for why the push notification wasn't delivered to your devices, that's hard to answer without more detail.

August Lilleaas
  • 54,010
  • 13
  • 102
  • 111
  • on my server I received replied message from apple server such as {"aps":{"alert":"message","badge":0,"sound":"default"}}. Isn't that mean the message has been successfully sent to the device? – Willy Sep 29 '11 at 09:17
  • If you use version 2 of the APS format, Apple will deliver a payload with an error code before closing the connection. You can read more about it in Apple's developer documentation. – August Lilleaas Sep 29 '11 at 12:09
  • 3
    The token is not necessarily unique for each app. See http://stackoverflow.com/questions/2338267/is-the-apn-device-token-unique-to-each-individual-app – malonso Jan 11 '12 at 20:12