SV Madhava Reddy
SV Madhava Reddy

Reputation: 2018

TypeError: Cannot read property 'googleplus' of undefined in IONIC with AngularJs

I've been following these links to use social login in my hybrid app.

https://github.com/EddyVerbruggen/cordova-plugin-googleplus

https://ionicthemes.com/tutorials/about/google-plus-login-with-ionic-framework

I've created all the google developer id's and all that stuff. I've installed the cordova-plugin-googleplus using those two as they said. But still my application showing the error i mentioned as header of this message...

In this line:  window.plugins.googleplus.login(

So, please help me with this one... I've stuck on this for 2 dayzz...Any help will be appreciated.

Upvotes: 4

Views: 2175

Answers (1)

beaver
beaver

Reputation: 17647

Here below is an example of cordova plugins check in the $ionicPlatform.ready() function wrapper:

mainApp.run(["$ionicPlatform", "$window", function ($ionicPlatform, $window) {

    $ionicPlatform.ready(function () {
        if ($window.plugins && $window.plugins.googleplus) {
            $window.plugins.googleplus.isAvailable(
                function (available) {
                if (available) {
                    // show the Google+ sign-in button
                }
            });
        }
    ...

    }

PS: $window is an Angular wrapper for window

Upvotes: 2

Related Questions