import { Component } from '@angular/core' ; import { NavController , LoadingController } from 'ionic-angular' ; import { UserPage } from '../user/user' ; import { GooglePlus } from '@ionic-native/google-plus' ; import { NativeStorage } from '@ionic-native/native-storage' ; @ Component ( { selector : 'page-login' , templateUrl : 'login.html' , } ) export class LoginPage { constructor ( public navCtrl , public loadingCtrl , public nativeStorage , public googlePlus ) { } doGoogleLogin ( ) { let nav = this . navCtrl ; let loading = this . loadingCtrl . create ( { content : 'Please wait...' } ) ; loading . present ( ) ; this . googlePlus . login ( { 'scopes' : '' , 'webClientId' : '1091419544653-nhncrb7n0sk43t3unhqk3q8h6smnbt22.apps.googleusercontent.com' , 'offline' : true } ) . then ( ( user ) => { loading . dismiss ( ) ; this . nativeStorage . setItem ( 'user' , { name : user . displayName , email : user . email , picture : user . imageUrl } ) . then ( ( ) => { nav . push ( UserPage ) ; } , ( error ) => { console . log ( error ) ; } ) ; } , ( error ) => { loading . dismiss ( ) ; } ) ; } }