gpt4 book ai didi

ios - 使用运行 iOS 7.1 的 iPhone 5s 时设备 token 为零

转载 作者:行者123 更新时间:2023-11-29 12:48:43 29 4
gpt4 key购买 nike

我的应用程序被苹果审查小组拒绝了。他们给我发了一个崩溃文件,上面写着:

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 登录应用程序时会发生此崩溃。

首先,我通过 AppDelegate.m 中的“didRegisterForRemoteNotificationsWithDeviceToken:”获取设备 token (应用程序首次启动时)并将其保存在 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

我真的很困惑。

希望大家帮帮我。

最佳答案

设备 token 是 NSData,如果您想在字符串中使用它,您需要将其转换为十六进制格式。尝试使用 NSData+APNSToken cocoapod 将 NSData 转换为 NSString

关于ios - 使用运行 iOS 7.1 的 iPhone 5s 时设备 token 为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22973815/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com