How do I check if an iOS distribution provisioning profile has push notifications enabled?

I have an app which was supposed to have push notifications enabled, but for some reason doesn't have them. I've seen other people download and install the app, and it doesn't even prompt them for permission to send push notifications. As expected, this app doesn't appear in their Settings > Notifications.

However, on my iPad, I am able to receive push notifications from this app, and it does show up on my Settings > Notifications. I have deleted and reinstalled the app to make sure I had the same thing everyone else has (and not a development version), and I'm still able to get notifications.

Now, this app was written for a client who sent me all the provisioning profiles (dev, adhoc, distribution) as well as the files needed to be able to send push notifications, so I can't know for sure that everything was properly created.

My theory right now is that:

  • the adhoc profile I received was "properly created" (i.e. generated after setting up APNs on the app's App ID in the Provisioning Portal)
  • the distribution profile I received was generated before setting up APNs for this app (and thus, it's not "push enabled")
  • the reason I'm able to receive push notifications on my device is because during development I installed an adhoc version, which prompted me for permissions to receive push notifications, and even though I've deleted this adhoc version and downloaded the version from the store, the device has "cached" the fact that I'm willing to receive notifications and no longer prompts me for it. I've checked with other apps and indeed, after I delete and reinstall them, they won't prompt me again for permissions to receive push notifications.

So my questions are:

  • Does this theory make sense?
  • If it does, this means I'll have to ask the client to generate a new distribution provisioning profile. How can I verify that this profile is "push enabled"? (i.e. considering that I can't just install an app compiled with it)

Answers


Ok, I may have found a way to verify whether or not the profiles have push enabled.

If I open the .mobileprovision file as a text file, there is a bit of XML there (a plist apparently) which I'm guessing for a distribution profile should have this:

<key>aps-environment</key>
<string>production</string>

And indeed, the adhoc profile had this and the distribution profile didn't, so... I'm guessing this was the problem.

Still, any feedback would be helpful :)


Slightly different, but still useful: when you upload an app to iTunes connect, you can check whether it has Push notifications (or any other entitlements) enabled.

To do this, go to Manage your Applications, select the application, then go to "View Details" for the version you want to check.

From there, go to the "Binary details" page - there's an Entitlements field that shows what the entitlements the binary has. If Push Notifications are enabled, you'll see a "aps-environment: production" line in there.


Make sure that the distribution provisioning profile is generated after creating aps_certificate. High changes the profile may miss out aps-environment


I added the following to AppDelegate.m so I could see exactly what settings were enabled in debug

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  UIRemoteNotificationType enabledTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
NSLog(@"Receiving Notification Types: %lu", (long)enabledTypes); //0=none 1=badge 2=sound 4=alert 8=NewsStandContantAvailability

I got this from a Very inclusive and useful link: Apple Push Notification Service Tutorial - Part 1 it was extremely helpful for me.


Need Your Help

Symfony2 - creating own vendor bundle - project and git strategy

php git symfony bundle

We're considering creating our own common bundle for entity mapping and services for use within few separate apps. A bundle should be easy to modify, run, include and test. I know about Best Practi...