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

Posted

技术标签:

【中文标题】如何在 ionic 3 应用程序中添加“使用 Apple 登录”?【英文标题】:How to add "Sign in With Apple" In ionic 3 Application? 【发布时间】:2019-12-04 08:02:05 【问题描述】:

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

【问题讨论】:

同样的问题:***.com/questions/57825306/… 【参考方案1】:

你可以如下实现

安装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");
    )
)

【讨论】:

以上是关于如何在 ionic 3 应用程序中添加“使用 Apple 登录”?的主要内容,如果未能解决你的问题,请参考以下文章

如何在 Ionic 3 中发送本地通知?

如何在 IONIC 2 应用程序中添加选项卡

如何在 IONIC 3 物理设备上运行我的应用程序

如何在 Ionic 应用程序中添加后台服务

如何在 Ionic 3 中导入外部 JS 文件

如何在 Ionic/Angular 中添加 OAuth facebook 登录?