如何在ionic 3应用程序中添加“使用Apple登录”?

时间:2019-12-04 08:02:05

标签: cordova ionic-framework ionic3 cordova-plugins

有人知道如何在Ionic 3 IOS应用程序中添加“使用Apple登录”,因为Apple拒绝了包含第三方登录库但不包括“使用Apple登录”的应用程序。

1 个答案:

答案 0 :(得分:0)

您可以按以下方式实现

安装cordova插件:

ionic cordova plugin add cordova-plugin-sign-in-with-apple
npm install @ionic-native/sign-in-with-apple



 declare var cordova: any; //Add this line right below the imports

///

SignInApple(){
return new Promise((resolve, reject) => {
    cordova.plugins.SignInWithApple.signin({ 
        requestedScopes: [0, 1] 
    }, (succ) => { 
        // If you want to use firebase then use below
        var provider = new firebase.auth.OAuthProvider('apple.com').credential(succ.identityToken);
        this.afAuth.auth.signinWithCredential(provider).then(result => {
        }).catch( error => {
            reject( error.message || error );
        })
        // If you want your own auth validation method you can add it here.
    },(err) => { // changed here too, for consistence
        reject("Apple login failed");
    })
})
}