我的应用被Apple审核小组拒绝了。 他们发给我一个崩溃文件说:
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)
使用运行iOS 7.1的iPhone 5s登录应用时会发生此崩溃。
首先,我通过" didRegisterForRemoteNotificationsWithDeviceToken获取设备令牌:"在AppDelegate.m中(第一次启动应用程序)并将其保存为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是零。我还处理了这个案例,即用户通过以下方式禁用了PN:
didFailToRegisterForRemoteNotificationsWithError
我真的很困惑。
我希望你们能帮助我。
答案 0 :(得分:1)
设备令牌为NSData
,如果您想在字符串中使用它,则需要将其转换为十六进制格式。尝试使用NSData+APNSToken
cocoapod将NSData
转换为NSString
。