You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PhoneAuthProvider在iOS 16.1模拟器突发报错,真机运行正常

iOS 16.1模拟器Firebase手机号验证失败(Token mismatch)

毫无征兆地,PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber, uiDelegate: nil) 方法在我的iOS 16.1模拟器上开始执行失败,但在真机上仍可正常运行(使用同一构建版本)。我已尝试使用真实手机号和测试手机号进行测试。

环境信息

  • Firebase SDK版本:9.6.0
  • 运行环境:iOS 16.1模拟器

错误信息

Error Domain=FIRAuthErrorDomain Code=17048 "Token mismatch" UserInfo={NSLocalizedDescription=Token mismatch, FIRAuthErrorUserInfoNameKey=INVALID_APP_CREDENTIAL}

AppDelegate相关代码

extension AppDelegate: UNUserNotificationCenterDelegate {
    func userNotificationCenter(
        _ center: UNUserNotificationCenter,
        didReceive response: UNNotificationResponse,
        withCompletionHandler completionHandler: @escaping () -> Void
    ) {
        let userInfo = response.notification.request.content.userInfo
        
        completionHandler()
    }
    
    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        Auth.auth().setAPNSToken(deviceToken, type: .unknown)
        Messaging.messaging().apnsToken = deviceToken
    }
    
    func application(_ application: UIApplication, didReceiveRemoteNotification notification: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
        Messaging.messaging().appDidReceiveMessage(notification)
        
        if (Auth.auth().canHandleNotification(notification)) {
            completionHandler(.noData)
            return
        }
    }
}

extension AppDelegate: MessagingDelegate {
    func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
        let tokenDict = ["token": fcmToken ?? ""]
        
        NotificationCenter.default.post(
            name: Notification.Name("FCMToken"),
            object: nil,
            userInfo: tokenDict)
    }
}

Firebase证书配置

Firebase证书配置截图

补充说明

  • 昨天将macOS更新到13.0.1,这会不会是导致问题的原因?
  • 该功能在iOS 15模拟器上仍可正常运行。

请问各位有什么解决思路吗?

内容的提问来源于stack exchange,提问作者Sotiris Kaniras

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 10:10:34