ios - 带有 facebook/gmail 的 OAuth 不适用于 iOS 模拟器(Cordova 应用程序 + Firebase)
问题描述
我正在尝试在科尔多瓦(+Firebase)移动应用程序上完成我的最后一件事,但遇到了一个问题。所以,我正在为科尔多瓦应用程序进行社交登录,我正在关注本指南 - 指南链接
当我完成后,我遇到了一些问题,但修复了它们(仅在 android 上)
在 iOS 上,当您单击某些登录按钮时 - 没有任何反应,但是,当我隐藏应用程序(或只是关闭它)并再次打开它时,它开始进行重定向。
在该重定向中,我使用 facebook/gmail 登录,然后将我重定向到我在 config.xml 中的链接
这是我的要求:
await firebase.auth().signInWithRedirect(provider);
const user = await firebase.auth().getRedirectResult();
,在安卓上运行正常
这是我的 config.xml (我在那里尝试了很多stuckoverflow和github解决方案,所以它看起来很乱
<?xml version='0.0.1.2' encoding='utf-8'?>
<widget id="com.appname.ios" version="0.0.1.2" xmlns="http://www.w3.org/ns/widgets">
<name>App name</name>
<description>
Some description...
</description>
<author email="example@gmail.com" href="https://appname.com">
App ame
</author>
<content src="index.html" />
<icon src="/public/favicon.ico" />
<universal-links>
<host name="appname.page.link" scheme="https" />
<host name="appname.com" scheme="https">
<path url="/__/auth/callback"/>
</host>
</universal-links>
<plugin name="cordova-plugin-whitelist" spec="1" />
<plugin name="cordova.plugins.diagnostic" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-navigation href="*"/>
<platform name="android">
<allow-intent href="market:*" />
</platform>
<preference name="AndroidLaunchMode" value="singleTask" />
<preference name="orientation" value="portrait" />
<preference name="CordovaWebViewEngine" value="CDVUIWebViewEngine" />
<platform name="ios">
<icon src="public/ios/60.png" width="180" height="180" />
<icon src="public/ios/60.png" width="60" height="60" />
<icon src="public/ios/76.png" width="76" height="76" />
<icon src="public/ios/40.png" width="40" height="40" />
<icon src="public/ios/57.png" width="57" height="57" />
<icon src="public/ios/72.png" width="72" height="72" />
<icon src="public/ios/167.png" width="167" height="167" />
<icon src="public/ios/29.png" width="29" height="29" />
<icon src="public/ios/50.png" width="50" height="50" />
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<splash src="public/ios/appname.png" width="320" height="480"/>
<splash src="public/ios/appname.png" width="640" height="960"/>
<splash src="public/ios/appname.png" width="768" height="1024"/>
<splash src="public/ios/appname.png" width="1536" height="2048"/>
<splash src="public/ios/appname.png" width="1024" height="768"/>
<splash src="public/ios/appname.png" width="2048" height="1536"/>
<splash src="public/ios/appname.png" width="640" height="1136"/>
<splash src="public/ios/appname.png" width="750" height="1334"/>
<splash src="public/ios/appname.png" width="1242" height="2208"/>
</platform>
</widget>
这是我成功登录时的屏幕截图: ios模拟器截图
解决方案
已经通过做接下来的事情来修复:
- 在 iOS 上,社交按钮甚至没有重定向到适当的提供程序,因为某些错误正在停止整个堆栈:在此处找到答案-fixedBugLink
- 在我修复了这个错误之后,接下来我要处理的是成功登录后我无法返回应用程序
所以我发现问题在于添加下一个插件不合适 - https://www.google.com/search?q=cordova+url+scheme+ios&oq=cordova+url+scheme+ios&aqs=chrome..69i57j0j69i60.2808j0j4&sourceid =chrome&ie=UTF-8
我通过在我的 iOS 应用程序中将 GoogleService-Info.plist 文件中的默认链接更改为 REVERSED_CLIENT_ID 来解决错误 URL 方案链接的问题。
因此,请注意以下指南(顺便说一下,我已经遵循了这个指南 - oauth-cordva-firebase
希望这也会对某人有所帮助:)
推荐阅读
- kotlin - kotlin 程序错误:jar 文件中没有主要清单属性
- android - 如何在android中的材质主题下将可绘制的状态列表设置为按钮的背景
- android-layout - 我找不到动态添加的片段,片段管理器总是返回 null
- ios - 如果 Set 包含它,则更改数组内所有元素的变量
- rrdtool - RRD 工具 - 令人困惑的开始时间
- node.js - 将 Angular 更新到版本 8 后出现错误
- python - 在检查符号是 BTC 后,我想访问美元下的价格值
- php - 如何计算laravel中的订单总和?
- r - 如何使用 Matching 包中的 Mahalanobis 距离进行匹配
- python-3.x - 当其中一个容器挂载到文件系统时,如何连接两个容器?