【问题标题】:urban airship , device token is null城市飞艇,设备令牌为空
【发布时间】:2013-07-11 00:18:30
【问题描述】:

我已经在 iPhone 中使用城市飞艇(开发)实现了推送通知。

它工作正常。我想在新设备上进行测试。我从新的 mac PC 在新设备中安装了相同的项目我还在钥匙串中添加了证书并运行,但日志显示设备令牌为空,并且城市仪表板中没有新设备令牌。

设备令牌为空的原因是什么?有什么遗漏吗?我应该对 .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];

}

希望你能帮帮我

【问题讨论】:

    标签: iphone ios device token urbanairship.com


    【解决方案1】:

    您在哪里看到 null 值?在 Urban Airship 仪表板中,或在方法中

    - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken

    【讨论】:

    • 在 Xcode 日志中......来自这个方法......它给了我一个带有属性列表的 json,其中之一是 device token=""
    • 太长了..我贴在下面
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多