当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript GooglePlus.login方法代码示例

本文整理汇总了TypeScript中@ionic-native/google-plus.GooglePlus.login方法的典型用法代码示例。如果您正苦于以下问题:TypeScript GooglePlus.login方法的具体用法?TypeScript GooglePlus.login怎么用?TypeScript GooglePlus.login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@ionic-native/google-plus.GooglePlus的用法示例。


在下文中一共展示了GooglePlus.login方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: signInWithGoogle

 signInWithGoogle() {
   return this.googlePlus.login({
     'webClientId': '638933829742-i0av628updkc723cb3gnirhh3b0829up.apps.googleusercontent.com',
     'offline': true
   })
     .then(res => {
       return this.angularFireAuth.auth.signInWithCredential(firebase.auth.GoogleAuthProvider.credential(res.idToken))
         .then((user: firebase.User) => {
           // atualizando o profile do usuario
           return user.updateProfile({ displayName: res.displayName, photoURL: res.imageUrl });
         });
     });
 }
开发者ID:joaorobertoifrn,项目名称:ionicfirebaseauth,代码行数:13,代码来源:auth-service.ts

示例2: Promise

    return new Promise((resolve, reject) => {
      if (this.plt.is('cordova')) {
        this.google.login({
          'webClientId': '1061030166084-6ga7bg3irrgh2sqekdkti3slb7jda6f6.apps.googleusercontent.com'
        })
          .then(loginResponse => {
            let credential = firebase.auth.GoogleAuthProvider.credential(loginResponse.idToken)
            this.afAuth.auth.signInAndRetrieveDataWithCredential(credential)
              .then(info => {
                resolve(info)
              })
              .catch(err => {
                reject(err)
                alert(err)
                this.loginJobs();
              })
          })
          .catch(err => {
            reject(err)
            alert(err)
          })

      } else {
        this.afAuth.auth
          .signInWithPopup(new firebase.auth.GoogleAuthProvider())
          .then(result => {
            // This gives you a Google Access Token. You can use it to access the Google API.
            let token = result.credential["accessToken"];
            resolve(result)
            this.loginJobs()
          })
          .catch(err => {
            reject(err)
            alert(err)
          })
      }

    })
开发者ID:Microsmsm,项目名称:Dawaey,代码行数:38,代码来源:auth.ts

示例3: resolve

 return new Promise<FirebaseUserModel>((resolve, reject) => {
   if (this.platform.is('cordova')) {
     this.googlePlus.login({
       'scopes': '', // optional, space-separated list of scopes, If not included or empty, defaults to `profile` and `email`.
       'webClientId': environment.googleWebClientId, // optional clientId of your Web application from Credentials settings of your project - On Android, this MUST be included to get an idToken. On iOS, it is not required.
       'offline': true
     }).then((response) => {
       const googleCredential = firebase.auth.GoogleAuthProvider.credential(response.idToken);
       firebase.auth().signInWithCredential(googleCredential)
       .then((user) => {
         resolve();
       });
     },(err) => {
       reject(err);
     });
   }
   else{
     this.afAuth.auth
     .signInWithPopup(new firebase.auth.GoogleAuthProvider())
     .then((user) => {
        resolve()
     })
   }
 })
开发者ID:mksalin,项目名称:test_repository,代码行数:24,代码来源:auth.service.ts


注:本文中的@ionic-native/google-plus.GooglePlus.login方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。