When install build from xcode push notification is working but when install ipa it is not working

北城余情 提交于 2019-12-01 18:05:17

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.

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:

  1. Create both developer and production certificate in developer center (what you already have)
  2. Download this simple push app
  3. Read your deviceToken for development env and check if it's working
  4. 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");
}
  1. Check out the device log and read the production token
  2. 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.

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.

upload .p12 for production on parse to get notifications on ipa.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!