This is an example Meteor Android App with native Google Plus Login using hedcet:cordova-google-plus-native-sign-in
meteor package.
- Android example.
-
Add Android platform to your App
meteor add-platform Android
. You can follow this Documentation. -
Install
hedcet:cordova-google-plus-native-sign-in
package to your App by typingmeteor add hedcet:cordova-google-plus-native-sign-in
. -
Add
mobile-config.js
file to your App & specify an App ID likecom.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',
});
- 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.
- Create oAuth credential for web-Application in the same project(in google-dev-console created in step 4) for
accounts-google
package. Use theclient ID
,client Secret
from web-client credentials foraccounts-google
like this.
- Now in your client side code you can use
Meteor.cordova_g_plus({cordova_g_plus: true});
as shown
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
}
});
}
window.plugins.googleplus.logout((msg) => {
Meteor.logout((error) => {
if (error) {
// error handling code
}
});
// do something useful
});
window.plugins.googleplus.disconnect((msg) => {
// do something useful
});