我如何使用城市飞艇注册设备

时间:2014-05-21 12:09:54

标签: java android push-notification urbanairship.com

我正在开发将接收城市飞艇推送通知的应用程序。我设法获得推送通知。 目前我已在myapplication类中添加了此代码

       AirshipConfigOptions options = AirshipConfigOptions
            .loadDefaultOptions(Myapplication.this);
    UAirship.takeOff(this, options);
    PushManager.shared().setAlias("test");

    // Tags
    HashSet<String> tags = new HashSet<String>();
    tags.add("tag1");
    tags.add("tag2");
    PushManager.shared().setTags(tags);
    PushManager.enablePush();
    PushManager.shared().setIntentReceiver(IntentReceiver.class);
    String apid = PushManager.shared().getAPID();
    Logger.info("My Application onCreate - App APID: " + apid); 

它始终显示“您还没有注册任何设备令牌。” 我如何用城市飞艇注册设备?谁能帮我吗 。

1 个答案:

答案 0 :(得分:0)

试试这个代码段:

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
UA_LINFO(@"APNS device token: %@", deviceToken);

// Updates the device token and registers the token with UA. This won't occur until
// push is enabled if the outlined process is followed. This call is required.
[[UAPush shared] registerDeviceToken:deviceToken];

}