简体   繁体   English

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

[英]Firebase (Phone Auth) Getting iOS error: register custom URL scheme

My flutter app uses Firebase Auth (Phone).我的 flutter 应用程序使用 Firebase Auth(电话)。 I keep seeing the error: 'Please register custom URL scheme 'com.googleusercontent.apps.602546125958-5lk04ghhdfj5xxxxxxxx' .我一直看到错误: 'Please register custom URL scheme 'com.googleusercontent.apps.602546125958-5lk04ghhdfj5xxxxxxxx'

I have added the URL schema to the info.plist as follows, but I'm getting the same error.我已将 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

Delete you URL Type entry from.plist file and follow the steps, .plist entry will be automatically generated.删除你 URL 从.plist 文件中输入条目并按照步骤操作,将自动生成.plist 条目。

This works for Flutter as well这也适用于 Flutter

Steps:脚步:

在此处输入图像描述

You can click on + in URL Types if you want to add more than 1 URL Schemes.如果要添加超过 1 个 URL 方案,可以单击 URL 类型中的 +。

Please comment if you have any questions.如果您有任何问题,请发表评论。

Happy to help!乐意效劳!

There is a Firebase documentation for iOS phone verification setup: iOS 电话验证设置有一个 Firebase 文档:

To enable the Firebase SDK to use reCAPTCHA verification:要启用 Firebase SDK 以使用 reCAPTCHA 验证:

Add custom URL schemes to your Xcode project:将自定义 URL 方案添加到您的 Xcode 项目:

  1. Open your project configuration: double-click the project name in the left tree view.打开您的项目配置:双击左侧树视图中的项目名称。 Select your app from the TARGETS section, then select the Info tab, and expand the URL Types section. Select 您的应用从 TARGETS 部分,然后 select Info 选项卡,并展开 URL Types 部分。
  2. Click the + button, and add a URL scheme for your reversed client ID.单击 + 按钮,并为您的反向客户端 ID 添加 URL 方案。 To find this value, open the GoogleService-Info.plist configuration file, and look for the REVERSED_CLIENT_ID key.要查找此值,请打开 GoogleService-Info.plist 配置文件,然后查找 REVERSED_CLIENT_ID 键。 Copy the value of that key, and paste it into the URL Schemes box on the configuration page.复制该键的值,并将其粘贴到配置页面上的 URL 方案框中。 Leave the other fields blank.将其他字段留空。 When completed, your config should look something similar to the following (but with your application-specific values):完成后,您的配置应类似于以下内容(但使用特定于应用程序的值):

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

Works for Flutter too.也适用于 Flutter。

I had the same problem.我有同样的问题。 Try with the following setting.尝试以下设置。

在此处输入图像描述

My issue was I had copied the GoogleService-info.plist into the wrong directory.我的问题是我将GoogleService-info.plist复制到了错误的目录中。 There is a top level folder named after your app, and a folder with the same name, inside that one.有一个以您的应用程序命名的顶级文件夹,以及一个同名的文件夹,在该文件夹 So like, MyApp/MyApp , it needs to be inside that second, inner folder.就像MyApp/MyApp一样,它需要在第二个内部文件夹中。

Add the reverse client id in the url launcher.在 url 启动器中添加反向客户端 ID。

Reverse client id is located in googleservies.infolist xcode and copy the url and paste the url in url launcher by add the link Reverse client id is located in googleservies.infolist xcode and copy the url and paste the url in url launcher by add the link

You need to register custom URL scheme in the app's Info.plist file.您需要在应用程序的 Info.plist 文件中注册自定义 URL 方案。

Add this line in your info.plist将此行添加到您的 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM