背景
自蘋果推出了Sign in with Apple功能后,很快審核指南就加入 4.8 :使用第三方登錄的App,都必須接入AppleID登錄 。已經(jīng)上架的 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),來創(chuàng)建按鈕。
privateletappleButton:ASAuthorizationAppleIDButton={letbutton=ASAuthorizationAppleIDButton(authorizationButtonType:.signIn,authorizationButtonStyle:.white)returnbutton}()
按鈕樣式有white、whiteOutline、black三種,Api部分比較簡單,直接看代碼就好了。
值得一提的是,現(xiàn)在Apple明顯嚴(yán)肅了對AppleID登錄功能的UI規(guī)范審核,聽聞很多小伙伴的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.
這個問題,只要大家認(rèn)真閱讀https://developer.apple.com/design/human-interface-guidelines/sign-in-with-apple/overview/buttons并按照上面的要求修改,都不會再有問題。
ASAuthorizationAppleIDCredential信息釋義:
User ID:? 蘋果用戶唯一標(biāo)識符,該值在同一個開發(fā)者賬號下的所有 App 下是一樣的,開發(fā)者可以用該唯一標(biāo)識符與自己后臺系統(tǒng)的賬號體系綁定起來。
Verification data:Identity token,code驗證數(shù)據(jù),用于傳給開發(fā)者后臺服務(wù)器,然后開發(fā)者服務(wù)器再向蘋果的身份驗證服務(wù)端驗證本次授權(quán)登錄請求數(shù)據(jù)的有效性和真實性
Account information:? 蘋果用戶信息,包括全名、郵箱等
Real user indicator: 用于判斷當(dāng)前登錄的蘋果賬號是否是一個真實用戶
AuthenticationServices 框架概述
1.Sign In with Apple使用Apple登錄
2.Password-Based Login基于密碼的登錄
3.Web-Based Login基于web的登錄
4.Enterprise Single Sign-On企業(yè)單點登錄SSO
5.AutoFill Credential Provider Support自動填充驗證提供者支持
6.Web Browser Authentication Session Support web瀏覽器認(rèn)證會話支持
