简体   繁体   English

带有 facebook/gmail 的 OAuth 在 iOS 模拟器(Cordova 应用程序 + Firebase)上不起作用

[英]OAuth with facebook/gmail is not working on iOS simulator (Cordova app + Firebase)

I am trying to finish my last thing on cordova (+Firebase) mobile app and stuck with a problem.我试图在 cordova (+Firebase) 移动应用程序上完成我的最后一件事,但遇到了一个问题。 So, I was working on social login for cordova app, I was following this guide - Link to guide因此,我正在为 cordova 应用程序进行社交登录,我正在关注本指南 - 指南链接

when I've finished, I had some problems, but fixed them (only on android)当我完成后,我遇到了一些问题,但修复了它们(仅在 android 上)

on iOS, when u click on some of login button - nothing happens, BUT, when I hide the app (or just close it) and open it again, it start making redirect.在 iOS 上,当您单击一些登录按钮时 - 没有任何反应,但是,当我隐藏应用程序(或只是关闭它)并再次打开它时,它开始进行重定向。

In that redirect I'm making login with facebook/gmail and then it redirects me to the link that I have in my config.xml在该重定向中,我使用 facebook/gmail 登录,然后将我重定向到我在 config.xml 中的链接

here is my request:这是我的要求:

 await firebase.auth().signInWithRedirect(provider);
 const user = await firebase.auth().getRedirectResult();

, it works okay on android ,它在 android 上工作正常

and here is my config.xml (I've tried a lot of stuckoverflow and github solution there, so it can look messy这是我的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>

And here is a screen shot of what I have when I make success login: ios simulator screenshot这是我成功登录时的屏幕截图: ios 模拟器截图

Already fixed by doing next things:已经通过做接下来的事情来修复:

  1. On iOS social button was not even redirecting to appropriate provider because of some error that was stopping whole stack: found answer here - fixedBugLink在 iOS 上,社交按钮甚至没有重定向到适当的提供者,因为一些错误正在停止整个堆栈:在此处找到答案-fixedBugLink
  2. After I've fixed that error, next things I was dealing with was that I could not return back to app after successful login在我修复了这个错误之后,接下来我要处理的是成功登录后我无法返回应用程序

So I found that the problem was in unappropriate adding the next plugin - https://www.google.com/search?q=cordova+url+scheme+ios&oq=cordova+url+scheme+ios&aqs=chrome..69i57j0j69i60.2808j0j4&sourceid=chrome&ie=UTF-8所以我发现问题在于添加下一个插件不合适 - https://www.google.com/search?q=cordova+url+scheme+ios&oq=cordova+url+scheme+ios&aqs=chrome..69i57j0j69i60.2808j0j4&sourceid =chrome&ie=UTF-8

I fixed problem with wrong URL scheme link, by changing the default one to REVERSED_CLIENT_ID from GoogleService-Info.plist file in my iOS app.我通过在我的 iOS 应用程序中将 GoogleService-Info.plist 文件中的默认链接更改为 REVERSED_CLIENT_ID 解决了错误 URL 方案链接的问题。

So be careful with following guides (by the way I've followed this one - oauth-cordva-firebase因此,请注意以下指南(顺便说一下,我已经遵循了这个指南 - oauth-cordva-firebase

Hope this will help someone too:)希望这也会对某人有所帮助:)

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

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