Urban Airship iOS的Rich推送通知,用户未注册

时间:2012-03-12 16:55:59

标签: ios push-notification urbanairship.com

我从UrbanAirship.com复制了丰富的推送样本。 并在app delegate didFinishLaunchingWithOptions中初始化飞艇。

//Init Airship launch options
NSMutableDictionary *takeOffOptions = [[[NSMutableDictionary alloc] init] autorelease];
[takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];    
NSMutableDictionary *analyticsOptions = [[[NSMutableDictionary alloc] init] autorelease];
[analyticsOptions setValue:@"NO" forKey:UAAnalyticsOptionsLoggingKey];
[takeOffOptions setValue:analyticsOptions forKey:UAirshipTakeOffOptionsAnalyticsKey];

添加远程通知观察器并注册设备令牌。 但是在运行应用程序之后,我在UrbanAirship.com的应用程序详细信息页面上找不到任何富有的推送用户。 所以我无法测试丰富的推送通知。 怎么了?我期待着回答。

(以下是日志)

 -[UAAnalytics initWithOptions:] [Line 216] Analytics logging not enabled
 MyApp[3285:707] -[UAUser migrateUser] [Line 187] Migrating User Info: (null)
MyApp[3285:707] -[UAUser loadUser] [Line 268] User Info: (null)
MyApp[3285:707] -[UAInboxMessageList loadSavedMessages] [Line 103] before retrieve saved messages: (null)
MyApp[3285:707] -[UAInboxMessageList loadSavedMessages] [Line 109] after retrieve saved messages: (
)
...
MyApp[3285:707] applicationDidBecomeActive
MyApp[3285:707] -[UAUser listenForDeviceTokenReg] [Line 964] ListenForDeviceTokenReg
MyApp[3285:707] -[UAInboxMessageList requestWentWrong:] [Line 310] Inbox Message List Request Failed: Authentication needed
MyApp[3285:707] -[UAirship setDeviceToken:] [Line 306] Device token: daa75616a2f9b2b2c5e8e42fe6236cae031be082a3e3ddf1af6b00d8ad444444
MyApp[3285:707] -[UAUser observeValueForKeyPath:ofObject:change:context:] [Line 996] KVO device token modified
MyApp[3285:707] -[UAUser updateDefaultDeviceToken] [Line 1011] Updating device token
MyApp[3285:707] -[UAUser updateDefaultDeviceToken] [Line 1016] Skipping device token update: no token, already up to date, or user is being updated.
MyApp[3285:707] -[UAUser retrieveRequestFailed:] [Line 935] User retrieval failed: 401:Authorization Required
MyApp[3285:707] -[UAirship registerDeviceTokenSucceeded:] [Line 334] Device token registered on Urban Airship successfully.

1 个答案:

答案 0 :(得分:2)

我遇到了同样的问题。 UrbanAirship的答案是here - 作为一次性解决方案,添加DELETE_KEYCHAIN_CREDENTIALS = YES配置文件。我构建了我的UA配置文件,我没有使用AirshipConfig.plist,所以我在设置中添加了一个开关,允许根据需要添加这一行。

以下是我用来构建设置数组的代码:

- (void)urbanAirshipTakeoffWithLaunchOptions:(NSDictionary *)launchOptions {

    // Init Airship launch options
    NSMutableDictionary *takeOffOptions = [[NSMutableDictionary alloc] init];
    [takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];

    // Build the Urban Airship TakeOffOptions
    NSMutableDictionary *airshipConfigOptions = [[NSMutableDictionary alloc] init];

    /*
     * Set up the Push keys based on target
     */

    // TARGET1
#ifdef TARGET1
    NSLog(@"Urban Airship - Target TARGET1");
    [airshipConfigOptions setValue:@"xxxxxxxxxxxxxxxxxxxxxx" forKey:@"DEVELOPMENT_APP_KEY"];
    [airshipConfigOptions setValue:@"xxxxxxxxxxxxxxxxxxxxxx" forKey:@"DEVELOPMENT_APP_SECRET"];
    [airshipConfigOptions setValue:@"xxxxxxxxxxxxxxxxxxxxxx" forKey:@"PRODUCTION_APP_KEY"];
    [airshipConfigOptions setValue:@"xxxxxxxxxxxxxxxxxxxxxx" forKey:@"PRODUCTION_APP_SECRET"];
#endif

    // TARGET2
#ifdef TARGET2
    NSLog(@"Urban Airship - Target TARGET2");
    [airshipConfigOptions setValue:@"xxxxxxxxxxxxxxxxxxxxxx" forKey:@"DEVELOPMENT_APP_KEY"];
    [airshipConfigOptions setValue:@"xxxxxxxxxxxxxxxxxxxxxx" forKey:@"DEVELOPMENT_APP_SECRET"];
    [airshipConfigOptions setValue:@"xxxxxxxxxxxxxxxxxxxxxx" forKey:@"PRODUCTION_APP_KEY"];
    [airshipConfigOptions setValue:@"xxxxxxxxxxxxxxxxxxxxxx" forKey:@"PRODUCTION_APP_SECRET"];
#endif

    // TARGET3
#ifdef TARGET3
    NSLog(@"Urban Airship - Target TARGET3");
    [airshipConfigOptions setValue:@"xxxxxxxxxxxxxxxxxxxxxx" forKey:@"DEVELOPMENT_APP_KEY"];
    [airshipConfigOptions setValue:@"xxxxxxxxxxxxxxxxxxxxxx" forKey:@"DEVELOPMENT_APP_SECRET"];
    [airshipConfigOptions setValue:@"xxxxxxxxxxxxxxxxxxxxxx" forKey:@"PRODUCTION_APP_KEY"];
    [airshipConfigOptions setValue:@"xxxxxxxxxxxxxxxxxxxxxx" forKey:@"PRODUCTION_APP_SECRET"];
#endif

    // If CONFIGURATION_Debug is definied, 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

    // Erase stored user information from keychain - set in settings?
    if(self.getEraseUser) [airshipConfigOptions setValue:@"YES" forKey:@"DELETE_KEYCHAIN_CREDENTIALS"];

    // Set and start Urban Airship
    [takeOffOptions setValue:airshipConfigOptions forKey:UAirshipTakeOffOptionsAirshipConfigKey];
    [UAirship takeOff:takeOffOptions];

    // If the application gets an UAInbox message id on launch open it up immediately. Only works for the default inbox
    [UAInbox useCustomUI:[UAInboxUI class]]; //sample UI implementation
    [UAInbox shared].pushHandler.delegate = [UAInboxUI shared];
    [UAInboxUI shared].inboxParentController = self.tabcontroller;
    [UAInboxPushHandler handleLaunchOptions:launchOptions];

    if([[UAInbox shared].pushHandler hasLaunchMessage]) {
        [[[UAInbox shared] uiClass] loadLaunchMessage];
    }

    // Register for push notifications
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
                                                                           UIRemoteNotificationTypeSound |
                                                                           UIRemoteNotificationTypeAlert)];

}

运行此命令后,我的日志文件显示:

2012-03-30 10:32:33.505 iFlightBag[13792:707] -[UAInboxMessageList messageListReady:] [Line 188] after retrieveMessageList, messages: (
"4e825e6863051f2fed001efa - New User Welcome"
)
2012-03-30 10:32:33.632 ThisApp[13792:707] -[UAUser updatedDefaultDeviceToken:] [Line 1036] Updated Device Token response: 200
2012-03-30 10:33:32.089 ThisApp[13792:707] +[UAKeychainUtils getDeviceID] [Line 263] Retrieved device id info from keychain.
2012-03-30 10:33:32.090 ThisApp[13792:707] +[UAKeychainUtils getDeviceID] [Line 267] Device ID result is not nil.

显示新用户已创建。我正在使用基于别名和标签的富文本收件箱。所以用户名不会影响我的应用程序。

我错过了什么吗?