0

我有一个以前从未遇到过的有趣问题。在新的 iOs 项目上尝试使用FirebasePlugin.getVerificationID时会引发以下错误:

'Please register custom URL scheme 'com.googleusercontent.apps.xxxxx' in the app's Info.plist file.'

示例函数是:

if (!data.phoneNumber) {
  return;
}

let phoneNumberString = "+44" + data.phoneNumber;

(<any>window).FirebasePlugin.getVerificationID(phoneNumberString, id => {
  this.navCtrl.push('verify', { id: id });
}, error => {
  console.error("SMS error", error);
})

我使用 Ionic Appflow 编译应用程序,因此不使用 XCode 来管理项目文件。为了解决上述错误,我将以下代码放在“GoogleService-Info.plist”中:

    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLName</key>
            <string>REVERSED_CLIENT_ID</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>com.googleusercontent.apps.xxx</string>
            </array>
        </dict>
    </array>

但是,即使 plistfile 包含在应用程序的编译中,这仍然会返回错误。

我欢迎任何人可能有的任何想法。

4

1 回答 1

0

我解决了这个问题。这个问题与我调用 plist 的方式有关。由于 AppleFlow 的运作方式,它不包含 GoogleServices plist 中的某些值。为了解决这个问题,我在 config.xml 中包含了以下内容来解决它。

    <config-file parent="CFBundleURLTypes" target="*-Info.plist">
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLName</key>
            <string>REVERSED_CLIENT_ID</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>com.googleusercontent.apps.XXXXXXXXXXXX</string>
            </array>
        </dict>
    </config-file>
于 2019-08-20T21:57:57.333 回答