Skip to content

Latest commit

 

History

History
85 lines (59 loc) · 3.19 KB

README.md

File metadata and controls

85 lines (59 loc) · 3.19 KB

Cordova Google Plus native Login implemented in MeteorJS

Donate ghit.me

Description

This is an example Meteor Android App with native Google Plus Login using hedcet:cordova-google-plus-native-sign-in meteor package.

Screenshots

Screenshots

Demo

Usage

  1. Add Android platform to your App meteor add-platform Android. You can follow this Documentation.

  2. Install hedcet:cordova-google-plus-native-sign-in package to your App by typing meteor add hedcet:cordova-google-plus-native-sign-in.

  3. Add mobile-config.js file to your App & specify an App ID like com.example.meteor_g_plus

App.info({
  author: 'x',
  description: 'Cordova Google Plus SignIn',
  email: 'x',
  id: 'com.example.meteor_g_plus',
  name: 'example',
  website: 'https://github.com/x/x',
  version: '1.0.0',
});
  1. Now use the App ID(com.example.meteor_g_plus) created in step-3 as "Android package name" to setup Google Plus API for Android by following this guide. Once Google Sign-In is enabled Google will automatically create necessary credentials in Developer Console. There is no need to add the generated google-services.json file into your meteor project.

Make sure you execute the keytool steps as well or authentication will fail.

  1. Create oAuth credential for web-Application in the same project(in google-dev-console created in step 4) for accounts-google package. Use the client ID, client Secret from web-client credentials for accounts-google like this.

Screenshots

  1. Now in your client side code you can use Meteor.cordova_g_plus({cordova_g_plus: true}); as shown
LogIn
if (Meteor.isCordova) { // signIn through cordova
    Meteor.cordova_g_plus({
        cordova_g_plus: true,
        profile: ["email", "email_verified", "gender", "locale", "name", "picture"],
        webClientId: 'your-web-client-id'
      }, (error) => {
        if (error) {
            // error handling code
        }
    });
}
Logout
window.plugins.googleplus.logout((msg) => {
   Meteor.logout((error) => {
       if (error) {
           // error handling code
       }
   });

   // do something useful

});
Disconnect
window.plugins.googleplus.disconnect((msg) => {

    // do something useful

});