0

I set up everything (creates certificates) and figured out to get the device token in development environment.

When I call:

[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];

I get the device token here:

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

But with apple entreprise, when I export the app and download it on an iPhone, the application:didRegisterForRemoteNotificationsWithDeviceToken is never called!

I've created :

  • an IOS Distribution certificate (with the right App ID)

  • an APNS Production certificate (with the right App ID)

  • a provisioning profile allowing APN (with the right App ID)

I have the same for the development , and as I said, when I launch the app from xcode, I get the device token. Why not in the exported app?!

Eran
  • 387,369
  • 54
  • 702
  • 768
Damien Romito
  • 9,801
  • 13
  • 66
  • 84
  • 1
    Have you checked reason for failing in `-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error` ? – Jakub Vano Mar 26 '15 at 09:29
  • Did you updated the right pem (generated from APNS Production certificate) file to your server to send notification? – Ajumal Mar 26 '15 at 09:40
  • @JakubVano I check by posting the device token to my server and I double check with an UIAlert. – Damien Romito Mar 26 '15 at 10:08
  • @Aju I did, but this is the next step, I need first to get the device token – Damien Romito Mar 26 '15 at 10:09
  • @DamienRomito I meant: when registration fails, then `didFailToRegister` delegate method is called. Have you checked `error` passed there? – Jakub Vano Mar 26 '15 at 10:20
  • @JakubVano, no the method isn't called, I added an UIAlert to check it. – Damien Romito Mar 26 '15 at 10:23
  • 1
    one thing i want to clear here, i am using APNS with enterprise App. so there is no issue with enterprise app. issue may be in your `pem` or `ipa` file . – M Zubair Shamshad Mar 26 '15 at 10:57

1 Answers1

1

I had face the similar issue before, Mine was an issue with provision file issue, Xcode wrongly pick XC Ad Hoc provisioning or some times Wildcard app provision while generating build see the image belowenter image description here.

With Wildcard app provision push notification will not work. From Xcode 6 has this problem and there is no option to select the right provision from here. But i found another solution for this. Right click the archive from Organizer and select show in finder ->

Right click the archive file and select show package content ->

choose product -> Applications .

Here you can see a file with your app name. copy it to a folder somewhere name the folder Payload , then compress it, so you have Payload.zip.

Then rename it to Payload.ipa. hope it will help you.

Ajumal
  • 1,048
  • 11
  • 33
  • This doesn't work and I don't understand why it should works. the app i export is not for Ah Hoc deployment but for Entreprise Deployment. The default provisioning profile selected enable "Push Notifications", it should works... weird – Damien Romito Mar 26 '15 at 10:57
  • 1
    I suggest you to recheck every place showing right provision including in Organizer , In my case Wildcard provision was selected, By doing those steps it worked. – Ajumal Mar 26 '15 at 11:12
  • 1
    You was right, The default App ID of my provisioning profile was the auto created "Xcode iOS Wildcard App ID". Your method didn't work for me , but I deleted this wildcard app Id and set mine. – Damien Romito Mar 27 '15 at 07:49