2014-04-09 38 views
1

我的應用被蘋果評論組拒絕。 他們給我一個崩潰的文件,上面寫着:登錄到應用程序時,使用運行iOS 7.1的iPhone 5S發生當使用運行iOS 7.1的iPhone 5s時,設備令牌爲零

Exception Type: EXC_CRASH (SIGABRT) 
Exception Codes: 0x0000000000000000, 0x0000000000000000 



2 CoreFoundation 0x2e8c0e40 +[NSException raise:format:] + 108 
3 Foundation  0x2f1e7500 -[NSString stringByAppendingString:] + 84 
4 TheApp   0x000aaa3a -[UserSignInViewController userEmail:userPassword:]  (UserSignInViewController.m:175) 

這個崩潰。

首先,我通過AppDelegate.m中的「didRegisterForRemoteNotificationsWithDeviceToken:」(首次啓動應用程序)獲取設備標記並將其保存爲tmp。靜態變量:

NSString *tmpDT = [[[NSString stringWithFormat:@"%@",deviceToken] 
        stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]] stringByReplacingOccurrencesOfString:@" " withString:@""]; 

// Set tmp device token in DataStorage 

[PSDataStorage setDeviceToken:tmpDT]; 

當用戶登錄,並且希望登錄到與參數的URL通過附加字符串創建的應用程序:

//... 

// get device token from DataStorage 

NSString *deviceToken = [PSDataStorage getDeviceToken]; 

NSString *fullURL = @"https://.../.../....json?email="; 
fullURL = [fullURL stringByAppendingString:userEmail]; 
fullURL = [fullURL stringByAppendingString:@"&pw="]; 
fullURL = [fullURL stringByAppendingString:userPassword]; 
fullURL = [fullURL stringByAppendingString:@"&client=ios"]; 
fullURL = [fullURL stringByAppendingString:@"&device_token="]; 
fullURL = [fullURL stringByAppendingString:deviceToken]; 

UserSignInViewController.m:175個引用:

fullURL = [fullURL stringByAppendingString:deviceToken]; 

看起來好像deviceToken是零。我也處理的情況下,用戶禁用PNs通過:

didFailToRegisterForRemoteNotificationsWithError 

我真的很困惑。

我希望你們能幫助我。

+0

a)如果應用程序運行,並且您獲得設備令牌但它的零,b)您使用PSDataStorage存儲零,c)然後應用程序再次運行。那麼你是否有檢查,以確保如果設備標記爲零,fullURL代碼不會運行?如果沒有,那就是你碰撞的原因。你感到困惑的是什麼? – Gruntcakes

+0

我在iPhone4和iPhone5上測試過它。在開發過程中沒有這樣的問題。正如我所說,它只發生在iPhone 5s上。 此外,登錄過程只被調用一次。所以c)不相關。 你說得對。我將執行一次檢查,看看deviceToken是否爲零。我應該在一開始就這樣做了。 但還有一個問題:即使調用了「didRegisterForRemoteNotificationsWithDeviceToken:」,爲什麼應該devie標記爲零? – herdi

+0

如果您的應用在設備啓動後立即運行,您可能偶爾會得到一個零標記。當我得到令牌時,我有一個小的重試算法,如果didFailToRegisterForRemoteNotificationsWithError被調用,我會立即再次嘗試,如果再次失敗,可能會等待幾秒鐘,然後再試一次。我看到初始通話失敗,重試成功。 – Gruntcakes

回答

1

的設備令牌是NSData,如果你想在你需要將其轉換爲十六進制格式的字符串來使用它。嘗試使用NSData+APNSToken cocoapod將NSData轉換爲NSString

+0

檢查第二個代碼段。我正好在那裏。 – herdi

+1

之前已經提到過,這不是從'deviceToken'參數獲取字符串的可靠方法。您依賴於將來可能會改變的描述方法。 – Rich

+0

好的,我也會檢查一下。謝謝。 – herdi

相關問題