我已经开始在基于official documentation的Fighter中设置Firebase电话身份验证.不幸的是,无论我如何try ,我都会在verifyPhoneNumber方法的verificationFailed回调中得到具有以下值的FirebaseAuthException:

code: "invalid-app-credential"
credential: null
email: null
message: "Token mismatch"
phoneNumber: null
plugin: "firebase_auth"
stackTrace: null
tenantId: null

我已经创建了一个简单的存储库来重现这个问题:https://github.com/peternagy1332/basic_phone_auth

  1. 我使用flutterfire configure将该应用程序添加到现有的Firebase项目中,并在那里创建了iOS应用程序.
  2. 我加了firebase_core@2.1.1firebase_auth@4.1.1
  3. 我已经在Firebase上启用了电话登录方法,并添加了+447123456作为测试号码,代码是000000
  4. 我已经添加了具有Background fetchRemote notifications选项的Push notificationBackground modes功能.
  5. 我把GoogleService-Info.plistREVERSED_CLIENT_ID加成了URL Scheme.
  6. 在苹果开发者页面上,我生成了一个Apple Push Notifications service (APNs) service的新密钥,并将其作为APNs Authentication Key上传到Firebase.

官方文件中的setup section个让我想到了this documentation个.这表明可能需要对SWIFT代码进行额外的修改,但这一点真的不清楚.我是一名Ffltter开发人员,而不是原生iOS开发人员,我认为我实际上不需要做所有这些事情.

推荐答案

  1. 确保在AppDelegate.swft中设置了Firebase App.configuration()
override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        FirebaseApp.configure() 
        GeneratedPluginRegistrant.register(with: self)
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
  1. 将APNS令牌类型设置为AuthAPNSTokenType.UNKNOWN.实际令牌类型将从应用程序Bundle 包中的配置文件中检测到.
    override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        let firebaseAuth = Auth.auth()
        firebaseAuth.setAPNSToken(deviceToken, type: AuthAPNSTokenType.unknown)
    }
  1. 在您的Runner.entiments文件中,将APS-环境值从"Development"更改为"UNKNOWN"

Runner.entitlements

Ios相关问答推荐

在某些情况下,UIHostingController在自动调整时不能调整大小

使用SWIFT传输表示时的条件文件表示格式

iOS应用启动时崩溃问题解决方法-NO_CRASH_STACK-DYLD 4个符号丢失

更改订单时如何保存商品的位置?

查找东南亚语言(泰语、高棉语、老挝语、缅甸语)中的单词边界

iOS SwiftUI - 使用 PhotosPicker 从图库中 Select 图像或视频

xcode-select:找不到clang

通过MatchedGeometryEffect向上滑动视图

通过touch 传递到下面的 UIViews

在 Xcode 5 中为超级视图添加间距约束

iOS 10 错误:UICollectionView 接收到具有不存在索引路径的单元格的布局属性

在 iPhone 中将 UIViewController 显示为弹出窗口

如何覆盖@synthesized getter?

每个版本的 iOS 都附带什么版本的移动 Safari?

判断从 JSON 字符串返回的 Objective-C 中的空值

是否可以将 Socket.io 与 AWS Lambda 一起使用?

快速从 NSTimeInterval 转换为小时、分钟、秒、毫秒

iTunes Connect 中的无限制 Web 访问是什么意思

在 SKScene 中设置按钮

UIGestureRecognizer 阻止子视图处理touch 事件