Push Notification Issue in Adhoc Distribution
As I posted yesterday as answer to the same question: (prev. answer)
I've similar problems. After making some test I reached the following conclusions:
If app (that was compiled with
development provision profile
) is installed than such device hasdevelopment token
and you should sent pushes to such device usingdevelopment certificate
.If app (that was compiled with
distribution provision profile
) is installed than such device hasproduction token
and you should sent pushes to such device usingproduction certificate
.
And, If your app is not yet published, I think that APNS
will not accept production certificate
, so probably you won't be able to send push to your ad-hoc apps.
What you can do? For example, sent app to your testers that compiled with development certificate
.
UPDATED:I've learned this question one more time and found some interesting information:
- Download your
Ad-hoc provision profile
. - Open provision profile from 1. with text editor.
- Search for lines
<key>aps-environment</key> <string>production</string>
- Check the value of the key
aps-environment
. Is it equal toproduction?
If yes then you should send to your ad-hoc apps push notification with
production certificate
.If the value is
development
then you should send to your ad-hoc apps push notification withdevelopment certificate
.- Now open iOS Provisioning Portal -> App IDs. Select your app.
- Check if
Production Push SSL Certificate
is enabled.
If this didn't help you then try to update your ad-hoc provisioning profile.
There are severeral checklist that one should keep in mind while testing pushnotification for development environment. Most of them are already mentioned above. But this is one thing THAT SOLVED MY PROBLEM and i would like to share. I hope it helps someone. And that is:
Please be aware of the device token-ID, which is different for the development && Production environment .
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { NSString *deviceTokenStr = [[[[deviceToken description] stringByReplacingOccurrencesOfString: @"<" withString: @""] stringByReplacingOccurrencesOfString: @">" withString: @""] stringByReplacingOccurrencesOfString: @" " withString: @""]; UIAlertView *alert= [[UIAlertView alloc]initWithTitle:deviceTokenStr message:Nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show];}
Push notifications are a headache sometimes and are made up of many elements. If you miss something on the way, your PNS won't work and it will be very difficult to understand why. As a rule of thumb, view the following checklist:
- Push certificate and private key were generated correctly with the correct App ID (the same one that the provisioning profile is attached to).
- Both the certificate and private key are taken from the same, downloaded PNS certificate.
- Both files were correctly concatenated into a .pem file.
- Your application handles push notifications as they come in, while the app is active.
In any case, I recommend following a good tutorial, such as this: http://mobiforge.com/developing/story/programming-apple-push-notification-services word for word. Good luck!