gpt4 book ai didi

android - Firebase + Ionic + Cordova s​​ignInWithRedirect 重定向到 Android 上的本地主机

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:00:08 26 4
gpt4 key购买 nike

我最近重新构建了我的 Ionic 应用程序,经过一系列更新后,signInWithRedirectAndroid 上停止工作,并重定向到 localhost:8080 登录后,在 iOS 上没问题。

这是我的package.json:

{
...
"dependencies": {
...,
"firebase": "5.4.2",
"@angular/fire": "5.0.0",
"@ionic-native/firebase": "4.12.2",
"cordova-plugin-browsertab": "^0.2.0",
"cordova-plugin-buildinfo": "2.0.2",
"cordova-plugin-customurlscheme": "4.3.0",
"cordova-plugin-firebase": "2.0.0",
"cordova-plugin-ionic-webview": "2.1.4",
"cordova-universal-links-plugin": "git+https://github.com/andyepx/cordova-universal-links-plugin.git#b91b58fb8a7ff9f2b2de83b4adceece13e9cf2a8",
},
...
"cordova": {
"plugins": {
...
"cordova-plugin-local-notification": {},
"cordova-plugin-firebase": {},
"cordova-plugin-browsertab": {},
"cordova-universal-links-plugin": {}
},
}

我使用的 cordova-universal-links-plugin 版本是原始插件的一个分支,针对 Cordova 8 进行了一些修复。

config.xml

<preference name="AndroidLaunchMode" value="singleTask" />

<universal-links>
<host event="openAppEvent" name="app.my.com" scheme="https" />
<host name="myapp.page.link" scheme="https" />
<host name="myapp.app.goo.gl" scheme="https" />
<host name="myapp.firebaseapp.com" scheme="https">
<path url="/__/auth/callback" />
</host>
</universal-links>

我正在使用的登录代码段:

// this.firebaseLogin is an instance of AngularFireAuth

return this.firebaseLogin.auth.signInWithRedirect(new auth.GoogleAuthProvider())
.then(() => {
return this.firebaseLogin.auth.getRedirectResult()
.then(x => authCallback(x))
})

我找不到此配置的问题所在,尤其是当它在 iOS 上完美运行时...

最佳答案

对于这些版本:

"cordova-android": "^8.0.0",
"cordova-plugin-browsertab": "0.2.0",
"cordova-plugin-buildinfo": "2.0.3",
"cordova-plugin-compat": "1.2.0",
"cordova-plugin-device": "2.0.3",
"cordova-plugin-inappbrowser": "3.1.0",
"cordova-plugin-whitelist": "1.3.4",
"cordova-universal-links-plugin-fix": "1.2.1",
"firebase": "^5.9.4",
"cordova-universal-links-plugin": "~1.2.1",
"@angular/fire": "^5.1.2"

我能够通过将以下内容添加到我的 config.xml 来解决这个问题:

<allow-navigation href="http://*" />
<allow-navigation href="https://*" />

然后我得到了一个 403 错误:disallowed_useragent(类似于 this SO question),我设法通过将以下行添加到 config.xml 来修复它:

<preference name="OverrideUserAgent" value="Mozilla/5.0 Google" />

关于android - Firebase + Ionic + Cordova s​​ignInWithRedirect 重定向到 Android 上的本地主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52453529/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com