经过一系列更新后,我最近重新构建了我的Ionic应用程序,signInWithRedirect停止了在Android上运行,登录后重定向到了,而在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上很好地工作.
发布于 2019-07-15 07:26:25
有了这些版本:
"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 (类似于in this SO question),我通过向config.xml添加以下行来修复这个错误
<preference name="OverrideUserAgent" value="Mozilla/5.0 Google" />发布于 2018-09-24 11:51:49
经过进一步的探索,并遵循上面@bojeil的建议,cordova-plugin-ionic-webview@latest在http://localhost:8080上运行了一个集成的SDK服务器,该服务器与Firebase查找Cordova / handles重定向的方式不兼容。
因此,目前的工作解决方案是使用"cordova-plugin-ionic-webview": "1.2.1",并希望Firebase将在他们即将推出的JS版本中解决这个问题。
我在这里也提出了这个问题,https://github.com/firebase/firebase-js-sdk/issues/1244
https://stackoverflow.com/questions/52453529
复制相似问题