Ionic2 离子2谷歌加认证

Ionic2 离子2谷歌加认证,ionic2,Ionic2,离子2中的谷歌登录认证 一步一步。 我尝试打印简单的响应,但它不起作用 GLogin(){ alert("you are in google plush "); GooglePlus.login((res)=>{ alert(this.data=res); }); } 添加插件(选中此项): 包括库: import { GooglePlus } from 'ionic-native'; 现在登录: google

离子2中的谷歌登录认证 一步一步。 我尝试打印简单的响应,但它不起作用

GLogin(){   
     alert("you are in google plush "); 
     GooglePlus.login((res)=>{       
         alert(this.data=res);   
     });
}
添加插件(选中此项):

包括库:

import { GooglePlus } from 'ionic-native';
现在登录:

googlePlus_login() {
    GooglePlus.login(
        {
            'scopes': '',
            'webClientId': '',
            'offline': false
        }
    ).then(
        (success) => {
            alert(  '\n id: ' + JSON.stringify(success.userId) +
                    '\n name: ' + JSON.stringify(success.displayName) +
                    '\n email: ' + JSON.stringify(success.email)
            );
        },
        (failure) => {
            console.log('GOOGLE+ login FAILED', failure);
        }
    );
}
其中:

范围:可选的、以空格分隔的范围列表,如果不包括或为空,则默认为配置文件和电子邮件

webClientId:来自项目凭据设置的Web应用程序的可选clientId-在Android上,必须包含此项才能获取idToken。在iOS上,它不是必需的

脱机:可选,但需要webClientId-如果设置为true,插件还将返回serverAuthCode,可用于授予对非Google服务器的脱机访问权限

注销功能:

googlePlus_logout() {
    GooglePlus.logout().then(
        (success) => {
            console.log('GOOGLE+: logout DONE', success);
        },
        (failure) => {
            console.log('GOOGLE+: logout FAILED', failure);
        }
    );
}
希望它能帮助你。:)

添加插件(选中此项):

包括库:

import { GooglePlus } from 'ionic-native';
现在登录

googlePlus_login() {
    GooglePlus.login(
        {
            'scopes': '',
            'webClientId': '',
            'offline': false
        }
    ).then(
        (success) => {
            alert(  '\n id: ' + JSON.stringify(success.userId) +
                    '\n name: ' + JSON.stringify(success.displayName) +
                    '\n email: ' + JSON.stringify(success.email)
            );
        },
        (failure) => {
            console.log('GOOGLE+ login FAILED', failure);
        }
    );
}
其中:

范围:可选的、以空格分隔的范围列表,如果不包括或为空,则默认为配置文件和电子邮件

webClientId:来自项目凭据设置的Web应用程序的可选clientId-在Android上,必须包含此项才能获取idToken。在iOS上,它不是必需的

脱机:可选,但需要webClientId-如果设置为true,插件还将返回serverAuthCode,可用于授予对非Google服务器的脱机访问权限

注销功能:

googlePlus_logout() {
    GooglePlus.logout().then(
        (success) => {
            console.log('GOOGLE+: logout DONE', success);
        },
        (failure) => {
            console.log('GOOGLE+: logout FAILED', failure);
        }
    );
}
希望它能帮助你。:)