I implemented push notification in my app and it is working when i install build from xcode but not working when i install app via a link generated by diawi.com why this is happening?
问题:
回答1:
Push apns certificates are different for Development & production
if you install from xcode - It uses development certificate
if install from diawi.com - It uses production certificate
on parse,com i think you have uploaded .p12 file generated from development certificate.
you have to upload .p12 file of production certificate & then check.
回答2:
As @sadiqxs notice there are two types of certs, and in a comment you can find excelent simplePush code (http://d1xzuxjlafny7l.cloudfront.net/downloads/SimplePush.zip).
BUT one often forgotten thing!
Your deviceToken
changed (!!!) while you compile to production (ad-hoc) and deploy from Xcode. What i suggest you to do is:
- Create both developer and production certificate in developer center (what you already have)
- Download this simple push app
- Read your deviceToken for development env and check if it's working
NSLog
the token in method:-(void)application:didRegisterForRemoteNotificationsWithDeviceToken:
sample:
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
NSString *dt = [[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
dt = [dt stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"%@",dt");
}
- Check out the device log and read the production token
- Try with simple push if push got to device
6a) If yes, problem solved
6b) If no, and you receive the push for dev env for sure you have an issue with certificates and regenerate them
While you using SimplePush script remember to change url to production (gateway.push.apple.com) from sandbox one.
回答3:
The site install IPA with ad-hoc distribution.
For ad-hoc push notification, you need to use Apple's production push server, which is gateway.push.apple.com.
I think you are using sandbox push server when you install it from Xcode.
回答4:
upload .p12 for production on parse to get notifications on ipa.
回答5:
Late to this question, but had a similar troubled experienced so thought I'd share. As @sadiqxs noted:
• if you install from xcode - It uses development certificate
• if install from diawi.com - It uses production certificate
This forms a big problem when you try to debug remote notifications. However, there is a simple workaround! The trick is to install an AdHoc build once, which will register the phone using the productions certificate. Then add the following block around your register method (the place in the code where you decided to register a user for notfications).
#ifndef DEBUG
//your code to register for notifications, something along the lines of
UIApplication* application = [UIApplication sharedApplication];
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
#endif
What this will do, is skip the register statement when you run the app on consecutive builds through XCode and thus keep production notifications from coming in!
Hope this helps