我已经在iPhone中使用城市飞艇(开发)实现推送通知。
它工作正常。我想在新设备中测试。我从新的mac PC在新设备中安装了相同的项目我还在钥匙串中添加了证书并运行,但是日志显示设备令牌为空并且在城市仪表板中没有新的设备令牌。
null设备令牌的原因是什么?有什么遗失的吗?我要用.p12文件做些什么吗?
我在didFinishLaunchingWithOptions中有这个:
// Get the results out to open or close notification
bool storedresult = [defaults boolForKey:airShipKey];
if(storedresult){
[UAPush shared].pushEnabled=YES;
}else{
[UAPush shared].pushEnabled=NO;
}
// Override point for customization after application launch.
//Create Airship options directory and add the required UIApplication launchOptions
NSMutableDictionary *takeOffOptions = [NSMutableDictionary dictionary];
[takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];
// Call takeOff (which creates the UAirship singleton), passing in the launch options so the
// library can properly record when the app i launched from a push notification. This call is
// required.
//
// Populate AirshipConfig.plist with your app's info from https://go.urbanairship.com
[UAirship takeOff:takeOffOptions];
// Set the icon badge to zero on startup (optional)
[[UAPush shared] resetBadge];
[[UAPush shared]
registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)];
// Handle any incoming incoming push notifications.
// This will invoke `handleBackgroundNotification` on your UAPushNotificationDelegate.
[[UAPush shared] handleNotification:[launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]
applicationState:application.applicationState];
这里是didRegisterForRemoteNotificationsWithDeviceToken
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
UA_LINFO(@"APNS device token: %@", deviceToken);
// Updates the device token and registers the token with UA.
[[UAPush shared] registerDeviceToken:deviceToken];
}
我希望你能帮助我
答案 0 :(得分:0)
您在哪里看到null
值?在Urban Airship仪表板中,或在方法
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken