【问题标题】:Urban Airship not creating a device tokenUrban Airship 未创建设备令牌
【发布时间】:2013-03-19 09:30:05
【问题描述】:

我怎么没有设备令牌?

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary      *)launchOptions {

 //Create Airship options dictionary 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 is 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];

// Register for remote notfications with the UA Library. This call is required.
[[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];



  2013-03-19 04:22:44.202 MyApp[1070:907] [D] -[UAPush applicationDidBecomeActive] [Line 555]        Checking registration status after foreground notification
  2013-03-19 04:22:44.204 MyApp[1070:907] [D] -[UAPush applicationDidBecomeActive] [Line 561]           Checking registration on app foreground disabled on app initialization
  2013-03-19 04:22:44.241 MyApp[1070:907] [D] -[UAUser listenForDeviceTokenReg] [Line 931]   ListenForDeviceTokenReg
  2013-03-19 04:22:44.270 MyApp[1070:907] [D] -[UAUser userCreated:] [Line 467] User created:   201:{"username": null, "alias": null, "tags": [], "user_id": "xK4v5lARRDCAvekt25TeqA",   "user_url": "https://device-api.urbanairship.com/api/user/xK4v5lARRDCAvekt25TeqA/",   "device_tokens": [], "password": "oZeZFMO9SpyDZw3lM", "apids": [], "device_pins": [],  "ua_device_id": "2A6651E5-6D23-4FAD-B53C-4D6356D7A2AA"}
  2013-03-19 04:22:44.336 MyApp[1070:907] [D] -[UAUser updateDefaultDeviceToken] [Line 978] Updating device token.
 2013-03-19 04:22:44.338 MyApp[1070:907] [D] -[UAUser updateDefaultDeviceToken] [Line 981] Skipping device token update: no token, already up to date, or user is being updated.
 2013-03-19 04:22:58.766 F

我的 AirshipConfig.plist 中有 DEVELOPMENT_APP_SECRET 和 DEVELOPMENT_APP_KEY 以及 APP_STORE_OR_AD_HOC = NO

【问题讨论】:

标签: iphone objective-c xcode push-notification urbanairship.com


【解决方案1】:

我认为,配置时缺少一些步骤:

请再看https://docs.urbanairship.com/display/DOCS/Getting+Started:+iOS:+Push

并尝试在 AppDelegate 中记录您的令牌:

-(void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSLog(@"My token is: %@", deviceToken);
[[UAPush shared] registerDeviceToken:deviceToken];
}

同时更新 AirshipConfig.plist 文件

这可能是错误配置的证书/配置文件的问题。

【讨论】:

  • 我浏览了该教程,这就是我获得上述代码的方式。我在那里有一个断点,没有看到任何标记。我将添加一个登录以更加确定。城市飞艇仪表板上有 0 个代币。
  • 值得注意的是,“registerDeviceToken”对我来说已经贬值了。我正在使用 1.3.0 的库。另一个问题是,在您首先调用 takeOff 之前,您不能调用库中的任何方法。如果您使用提供的代理,那么这将不起作用。我目前正在寻找最好的方法来做到这一点。当我找到解决方案时会在这里发布。
【解决方案2】:

我遇到了同样的问题。虽然您有 DEVELOPMENT_APP_SECRET 和 DEVELOPMENT_APP_KEY,但我猜 UrbanAirship 库需要 PRODUCTION_APP_SECRET 和 PRODUCTION_APP_KEY。当我将它们添加到我的 AirshipConfig.plist 中时,问题得到了解决,我能够通过 UrbanAirship 发送推送消息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多