我在我的应用中使用了Apple推送通知,它在Adhoc Distribution中运行良好。我已将我的应用程序提交到AppStore,但推送通知对我的应用程序无效,并收到“Apple拒绝您的设备令牌”等消息。我使用单独的.p12文件进行开发和生产构建,并上传到Urban Airship。
注意:
但我使用相同的应用程序密钥和应用程序主密钥进行开发和生产。因此它不适用于推送通知。如果我创建一个单独的密钥用于分发,并且必须将这些密钥用于我的分发版本。这样它就能解决问题。当在城市飞艇中创建应用程序键时,我会得到应用程序密钥,应用程序密钥和应用程序主密钥等三个密钥。我在我的应用程序中使用了应用程序密钥和主密钥。它是否正确?所以请指导我。
由于
的问候,
Pugal
答案 0 :(得分:3)
你需要:
我使用以下代码在编译时根据宏设置Urban Airship Keys:
- (void)urbanAirshipTakeoffWithLaunchOptions:(NSDictionary *)launchOptions {
// Init Airship launch options
NSMutableDictionary *takeOffOptions = [[NSMutableDictionary alloc] init];
[takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];
// Build the Urban Airship TakeOffOptions
// Create Airship singleton that's used to talk to Urban Airship servers.
NSMutableDictionary *airshipConfigOptions = [[NSMutableDictionary alloc] init];
//Set up the Push keys
NSLog(@"Appdelegate_Pad:didFinishLaunchingWithOptions - TARGET_1");
[airshipConfigOptions setValue:@"xxx" forKey:@"DEVELOPMENT_APP_KEY"];
[airshipConfigOptions setValue:@"xxx" forKey:@"DEVELOPMENT_APP_SECRET"];
[airshipConfigOptions setValue:@"xxx" forKey:@"PRODUCTION_APP_KEY"];
[airshipConfigOptions setValue:@"xxx" forKey:@"PRODUCTION_APP_SECRET"];
// If CONFIGURATION_Debug is defined, then use the development servers, else use the production servers
#ifdef CONFIGURATION_Debug
[airshipConfigOptions setValue:@"NO" forKey:@"APP_STORE_OR_AD_HOC_BUILD"];
NSLog(@"Using Development Servers at Urban Airship");
#else
[airshipConfigOptions setValue:@"YES" forKey:@"APP_STORE_OR_AD_HOC_BUILD"];
NSLog(@"Using Production Servers at Urban Airship");
#endif
// Set and start Urban Airship
[takeOffOptions setValue:airshipConfigOptions forKey:UAirshipTakeOffOptionsAirshipConfigKey];
[UAirship takeOff:takeOffOptions];
// Register for push notifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)];
}
关于这个设置的最好的事情之一是我可以发送我的生产用户看不到的beta测试者推送消息(即:TestFlight上的新测试版!)。