2012-03-12 47 views
1

我從UrbanAirship.com複製了豐富的推送樣本。 並在應用委託didFinishLaunchingWithOptions中初始化飛艇。適用於iOS的Urban Airship Rich推送通知,用戶未註冊

//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. 

回答

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. 

顯示新創建用戶。我正在使用基於別名和標籤的富文本收件箱。所以用戶名不會影響我的應用程序。

我錯過了什麼嗎?

+0

只有我重新創建了UrbanAhiphip上的應用程序。 之後,它的工作。 – ttotto 2012-03-31 04:27:00

相關問題