集成AppleID登录

背景

自苹果推出了Sign in with Apple功能后,很快审核指南就加入 4.8 :使用第三方登录的App,都必须接入AppleID登录 。已经上架的 App 需在 2020 年 4 月 前完成接入工作, 新老App一样对待。

基本流程

image.png

App

1.首先需要配置Sign In with Apple

image.png

2.生成私钥。勾选Sign In with Apple,->Configure,选择Primary App ID,生成新的.p8私钥。

image.png

image.png

3.项目中配置Capability

image.png

4.集成AuthenticationServices.

官方提供了ASAuthorizationAppleIDButton(继承自UIControl),来创建按钮。

privateletappleButton:ASAuthorizationAppleIDButton={letbutton=ASAuthorizationAppleIDButton(authorizationButtonType:.signIn,authorizationButtonStyle:.white)returnbutton}()

按钮样式有white、whiteOutline、black三种,Api部分比较简单,直接看代码就好了。

值得一提的是,现在Apple明显严肃了对AppleID登录功能的UI规范审核,听闻很多小伙伴的App也都因这个问题而审核被拒,我这里也提一下。基本小伙伴收到的都是下面的这种被拒原由:

Guideline 4.0 - Design

We noticed an issue in your app that contributes to a lower quality user experience than Apple users expect:

Your app uses Sign in with Apple as a login option but does not use Sign in with Apple button design, branding and/or user interface elements appropriately as described in the Sign in With Apple Human Interface Guidelines.

这个问题,只要大家认真阅读https://developer.apple.com/design/human-interface-guidelines/sign-in-with-apple/overview/buttons并按照上面的要求修改,都不会再有问题。

ASAuthorizationAppleIDCredential信息释义:

User ID:  苹果用户唯一标识符,该值在同一个开发者账号下的所有 App 下是一样的,开发者可以用该唯一标识符与自己后台系统的账号体系绑定起来。

Verification data:Identity token,code验证数据,用于传给开发者后台服务器,然后开发者服务器再向苹果的身份验证服务端验证本次授权登录请求数据的有效性和真实性

Account information:  苹果用户信息,包括全名、邮箱等

Real user indicator: 用于判断当前登录的苹果账号是否是一个真实用户

AuthenticationServices 框架概述

1.Sign In with Apple使用Apple登录

2.Password-Based Login基于密码的登录

3.Web-Based Login基于web的登录

4.Enterprise Single Sign-On企业单点登录SSO

5.AutoFill Credential Provider Support自动填充验证提供者支持

6.Web Browser Authentication Session Support web浏览器认证会话支持

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容