iOS App Store 应用程序在登录期间崩溃(不在开发中)
Posted
技术标签:
【中文标题】iOS App Store 应用程序在登录期间崩溃(不在开发中)【英文标题】:iOS App Store app crashes during login (not in development) 【发布时间】:2021-03-29 14:21:50 【问题描述】:所以这可能是因为 UserDefaults 在一段时间后被重置,可能是因为我经常更新操作系统,但是一段时间后我的 ios 应用程序的发布版本会在我的登录屏幕上崩溃,可能是我检查的地方用于保存的凭据(在 UserDefaults 中)。重新安装应用程序可以解决此问题。控制台返回很多:
不支持在主线程之外使用 UIKit 视图自定义 API。 -setAlignsToKeyboard: 发送到 <_uialertcontrollerview:>>
我的系统日志在这个线程上显示错误:
异常类型:EXC_CRASH (SIGABRT) 异常代码:0x0000000000000000, 0x0000000000000000 异常说明:EXC_CORPSE_NOTIFY 线程触发:4
应用特定信息: abort() 调用
线程 4 名称:调度队列:com.apple.NSURLSession-delegate 线程 4 崩溃:0 libsystem_kernel.dylib 0x00000001bfb4e414 0x1bfb26000 + 164884 1 libsystem_pthread.dylib 0x00000001dd6a8b50 0x1dd6a6000 + 11088 2 libsystem_c.dylib 0x000000019b027b74 0x19afb1000 + 486260 3 libc++abi.dylib 0x00000001a6d1acf8 0x1a6d07000 + 81144 4 libc++abi.dylib 0x00000001a6d0be4c 0x1a6d07000 + 20044 5 libobjc.A.dylib 0x00000001a6c14f64 0x1a6c0e000 + 28516 6 libc++abi.dylib 0x00000001a6d1a0e0 0x1a6d07000 + 78048 7 libc++abi.dylib 0x00000001a6d1a06c 0x1a6d07000 + 77932 8 libdispatch.dylib 0x00000001917eddc4 0x1917ea000 + 15812 9 libdispatch.dylib 0x00000001917f510c 0x1917ea000 + 45324 10 libdispatch.dylib 0x00000001917f5c90 0x1917ea000 + 48272 11 libdispatch.dylib 0x00000001917ffd78 0x1917ea000 + 89464 12 libsystem_pthread.dylib 0x00000001dd6a9814 0x1dd6a6000 + 14356 13 libsystem_pthread.dylib 0x00000001dd6b076c 0x1dd6a6000 + 42860
这是我用来检查已保存凭据的一些代码。在后端 API 中,我看不到任何登录尝试。如果它有帮助,我可以在它崩溃之前看到这个视图控制器一瞬间。不确定这是否排除了 viewdidload。
override func viewDidLoad()
super.viewDidLoad()
addLoadingSpinner()
bLogIn.titleLabel?.font = UIFont.setToVoiceLight()
self.tfCustomerID.delegate = self
self.tfUsername.delegate = self
self.tfPassword.delegate = self
tfUsername.keyboardType = .default
tfPassword.textContentType = .password
setupUI()
if UserDefaults.standard.string(forKey: UserDefaultsKeys.session) != nil
&& UserDefaults.standard.string(forKey: UserDefaultsKeys.savedCred) == "True"
login_session = UserDefaults.standard.string(forKey: UserDefaultsKeys.session)!
check_session()
else if UserDefaults.standard.string(forKey: UserDefaultsKeys.savedCred) == "True" &&
UserDefaults.standard.string(forKey: UserDefaultsKeys.usesBiometrics) == "True"
promptTouchOrFaceID()
removeLoadingSpinner()
override func viewWillAppear(_ animated: Bool)
AppDelegate.AppUtility.lockOrientation(UIInterfaceOrientationMask.portrait, andRotateTo:
UIInterfaceOrientation.portrait)
cbSave.isChecked = UserDefaults.standard.string(forKey: UserDefaultsKeys.savedCred) == "True"
addObservers()
func check_session()
UserDefaults.standard.set(login_session, forKey: "session")
UserInfo.access_token = UserDefaults.standard.string(forKey: "session")!
var request = URLRequest(url: NSURL(string: checksession_url)! as URL)
request.httpMethod = .GET
request.addValues(...)
let task = URLSession.shared.dataTask(with: request) data, response, error in
if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode == 200
//VERIFIED THAT NEVER GETTING TO API
DispatchQueue.main.async
...
else
self.promptTouchOrFaceID()
UserDefaults.standard.set(nil, forKey: UserDefaultsKeys.session)
task.resume()
这是我的生物识别提示代码:
func promptTouchOrFaceID()
//create context for touch auth
let authenticationContext = LAContext()
var error: NSError?
authenticationContext.localizedFallbackTitle = ""
let biometricType = authenticationContext.biometricType
//check if the device has a fingerprint sensor, exit if not
guard authenticationContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics,
error: &error) else
let title = "Error"
var message = ""
switch biometricType
case .faceID:
message = "This device does not have a FaceID sensor or the sensor is not enabled."
case .touchID:
message = "This device does not have a TouchID sensor or the sensor is not enabled."
case .none:
message = "This device does not have any sensors to use TouchID or FaceID"
AlertService.showAlert(on: self, title: title, message: message)
UserDefaults.standard.set("False", forKey: UserDefaultsKeys.usesBiometrics)
removeLoadingSpinner()
return
authenticationContext.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics,
localizedReason: "Please use your fingerprint to authenticate.",
reply: [unowned self] (success, error) -> Void in
if (success)
//fingerprint recognized, set this possible and go to view controller
OperationQueue.main.addOperation( () -> Void in
self.fillInUserDetails()
self.login_now(
username:self.tfUsername.text!,
password: self.userDefaults.string(forKey: UserDefaultsKeys.password)!,
customer: self.tfCustomerID.text!)
)
)
【问题讨论】:
【参考方案1】:只是一个狂野的镜头,但你的 plist 文件中有NSFaceIDUsageDescription
密钥吗?我记得几个月前遇到过这样的问题。
【讨论】:
我会疯狂拍摄。我确实列出来了。谢谢以上是关于iOS App Store 应用程序在登录期间崩溃(不在开发中)的主要内容,如果未能解决你的问题,请参考以下文章
我的应用在 iOS 4.3 上崩溃,但仅在从 App Store 下载时
发布到 App Store 后,适用于 iOS 的 Google Maps SDK 崩溃
iOS App(使用核心数据)更新后崩溃,但只有 App Store 版本