How to add functionality of Google SIgn-In in Phonegap Hybrid HTML app

余生颓废 提交于 2020-01-16 17:18:10

问题


How to implement Google Login in Phonegap App & also how to check whether the user is logged in or not as soon as the user opens up the app ? I am already aware of the EddyVerbruggen Plugin but it doesn't tells the status of login, it just logs in the user and also its trysilentLogin method doesn't works (yields error : 4) . Without knowing the login status how can I direct my users to the welcome page of my app.

HTML :

<body onload="init()">
</body>

config.xml :

    <plugin name="cordova-plugin-googleplus" source="npm" spec="5.2.1">

    </plugin>

login.js :

function init() 
{    

    document.addEventListener("deviceready", onDeviceReady, false); 

}




    var onDeviceReady = function() 
                            { 



        window.plugins.googleplus.trySilentLogin( 
            {

                'scopes': '',
                'offline': false
            },
            function (obj) {


                alert(JSON.stringify(obj)); // do something useful instead of alerting


                        alert(' YES LOGGED IN ::: GOOGLE ');

            },
            function (msg) {

              alert(' GOOGLE LOGIN error: ' + msg); //here comes the error : 4

            }
        );

来源:https://stackoverflow.com/questions/49732360/how-to-add-functionality-of-google-sign-in-in-phonegap-hybrid-html-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!