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

Viewed 166

I am trying to finish my last thing on cordova (+Firebase) mobile app and stuck with a problem. So, I was working on social login for cordova app, I was following this guide - Link to guide

when I've finished, I had some problems, but fixed them (only on 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.

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

here is my request:

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

, it works okay on android

and here is my config.xml (I've tried a lot of stuckoverflow and github solution there, so it can look messy

<?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

1 Answers

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
  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

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.

So be careful with following guides (by the way I've followed this one - oauth-cordva-firebase

Hope this will help someone too :)

Related