Flutter iOS App Phone Auth问题:[firebase_auth/web-internal-error]无法加载外部reCAPTCHA依赖项

icomxhvb  于 2023-05-23  发布在  Flutter
关注(0)|答案(1)|浏览(245)

我在Flutter iOS应用程序上的手机认证有问题。在Android上一切正常。
当我尝试使用电话号码登录时,我会在网站上重定向,但当它返回到应用程序时,会发生错误,显示[firebase_auth/web-internal-error] unable to load external reCAPTCHA dependencies
我在我的xCode项目中添加了Background Mode功能,模式为Background FetchRemote Notifications,还添加了自定义URL方案,如下所示:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>XXX (client Id is right)</string>
        </array>
    </dict>
</array>

我需要如何修复此错误?

tjvv9vkg

tjvv9vkg1#

尝试将以下代码添加到ios/Runner/AppDelegate.swift文件中:

import UIKit
import Flutter
import Firebase
import GoogleMaps

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    FirebaseApp.configure()
    GeneratedPluginRegistrant.register(with: self)
    if #available(iOS 10.0, *) {
      UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
    }
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }

  override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
      let firebaseAuth = Auth.auth()
      firebaseAuth.setAPNSToken(deviceToken, type: AuthAPNSTokenType.unknown)

  }
  override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
      let firebaseAuth = Auth.auth()
      if (firebaseAuth.canHandleNotification(userInfo)){
          print(userInfo)
          return
      }
  }

}

相关问题