RahulSalvikar
RahulSalvikar

Reputation: 658

Add google plus in android using cordova

As per subject, I want to add google plus (API) in android project using cordova. For this I am using below link tutorial cordova-plugin-googleplus. Actually I can't figure out the problem because I am doing all stapes as per tutorial for iOS and android both. And its work for iOS but not in android. I have both CLIENT ID's. This is my code.

function login() {
    window.plugins.googleplus.login(
        {
                //'androidApiKey': 'demo2-f2piclv62253f0k177i3se3k30fcbqtq.apps.googleusercontent.com'
                'iOSApiKey': 'demo3462-f2piclv62253f0k177i3se3k30fcbqtq.apps.googleusercontent.com'
        },
        function (obj) {
            document.querySelector("#image").src = obj.imageUrl;
            document.querySelector("#image").style.visibility = 'visible';
            document.querySelector("#feedback").innerHTML = "Hi, " + obj.displayName + ", " + obj.email;
        },
        function (msg) {
            document.querySelector("#feedback").innerHTML = "error: " + msg;
        }
    );
}

enter image description here

Upvotes: 1

Views: 3348

Answers (1)

RahulSalvikar
RahulSalvikar

Reputation: 658

Finally I got the solution, I am using cordova-plugin-googleplus plugin, it works properly for iOS, because passing of iOS clientId through HTML. But for Android you have to pass ClientId in deferent way. For me : Project -> Plugins -> android.json

        "nl.x-services.plugins.googleplus": {
        "CLIENT_ID": "your_client_ID",
        "PACKAGE_NAME": "com.demo.googlelogin"
    }

Upvotes: 1

Related Questions