Firebase(电话身份验证)获取 iOS 错误:注册自定义 URL 方案

use*_*968 19 ios firebase firebase-authentication flutter

我的 Flutter 应用程序使用 Firebase Auth(电话)。我一直看到错误:'Please register custom URL scheme 'com.googleusercontent.apps.602546125958-5lk04ghhdfj5xxxxxxxx'

我已将 URL 架构添加到 info.plist 中,如下所示,但我遇到了同样的错误。

在此处输入图片说明

2020-04-29 20:40:05.173962-0400 Runner[395:20944] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Please register custom URL scheme 'com.googleusercontent.apps.602546125958-5lk04ghhdfj5xxxxxxxx' in the app's Info.plist file.'
*** First throw call stack:
(0x1889035f0 0x188625bcc 0x1887f9b28 0x10086cfa8 0x100f056a0 0x102efb3b0 0x102e921bc 0x102eeb9cc 0x102ea2a68 0x102ea4dcc 0x1888821c0 0x188881edc 0x1888815b8 0x18887c5c8 0x18887bc34 0x1929c538c 0x18c9ae22c 0x10082addc 0x188703800)
libc++abi.dylib: terminating with uncaught exception of type NSException
Run Code Online (Sandbox Code Playgroud)

Moh*_*mar 51

从 .plist 文件中删除您的 URL Type 条目并按照步骤操作,将自动生成 .plist 条目。

这也适用于 Flutter

脚步:

在此处输入图片说明

如果要添加 1 个以上的 URL 方案,可以单击 URL 类型中的 +。

如果您有任何问题,请发表评论。

乐于帮助!

  • 感谢您详细且非常可爱的绘画指导! (2认同)
  • 该说明也在这里:https://firebase.google.com/docs/auth/ios/phone-auth#set-up-recaptcha-verification (2认同)

Suk*_*khi 8

我有同样的问题。请尝试以下设置。

在此处输入图片说明


小智 8

iOS 电话验证设置有一个 Firebase 文档:

要启用 Firebase SDK 以使用 reCAPTCHA 验证:

将自定义 URL 方案添加到您的 Xcode 项目:

  1. 打开您的项目配置:双击左侧树视图中的项目名称。从 TARGETS 部分选择您的应用,然后选择 Info 选项卡,并展开 URL Types 部分。
  2. 单击 + 按钮,然后为反向客户端 ID 添加 URL 方案。要查找此值,请打开 GoogleService-Info.plist 配置文件,并查找 REVERSED_CLIENT_ID 键。复制该键的值,并将其粘贴到配置页面上的 URL Schemes 框中。将其他字段留空。完成后,您的配置应类似于以下内容(但具有特定于应用程序的值):

https://firebase.google.com/docs/auth/ios/phone-auth?authuser=0

也适用于 Flutter。


Tus*_*kam 7

您需要在应用程序的 Info.plist 文件中注册自定义 URL 方案。

在您的 info.plist 中添加此行

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleIdentifier</key>
        <string></string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>enter your custom URL scheme here</string>
        </array>
    </dict>
</array>
Run Code Online (Sandbox Code Playgroud)


小智 6

In Flutter or Swift Project, 

You will get the REVERSED_CLIENT_ID in the GoogleService-info.plist file. 

<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.465370197171-9vgd73go8jnp3ae00cn29009u8fee5du</string>

You then need to add this value in your info.plist as follows:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleIdentifier</key>
        <string></string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string> VALUE OF REVERSED_CLIENT_ID</string>
        </array>
    </dict>
</array>
Run Code Online (Sandbox Code Playgroud)