【1】使用第三方登錄而沒有使用Apple登錄時(shí)審核被拒郵件內(nèi)容如下:
### Guideline 4.8 - Design - Sign in with Apple
We noticed that your app uses a third-party login service but does not offer Sign in with Apple.
**Next Steps**
To resolve this issue, please revise your app to offer Sign in with Apple as an equivalent login option.
**Resources**
To learn more, see the Sign in with Apple [Overview](https://developer.apple.com/sign-in-with-apple/).
【2】蘋果登錄實(shí)現(xiàn)步驟與注意事項(xiàng)
【注意】使用蘋果登錄首先需要在蘋果開發(fā)者后臺(tái)開啟 App 的 Sign In with Apple 服務(wù)只有發(fā)布Appstore的應(yīng)用才能使用蘋果登錄。企業(yè)版開發(fā)者賬號(hào)不支持 Sign In with Apple (企業(yè)版開發(fā)者賬號(hào)指的是用于企業(yè)內(nèi)部分發(fā)App,不能用于發(fā)布 App Store 的賬號(hào)起意,也就是價(jià)格為 299$ 的賬號(hào))
【代碼】
#import <AuthenticationServices/AuthenticationServices.h>
@interface LoginView ()<
ASAuthorizationControllerDelegate,
ASAuthorizationControllerPresentationContextProviding
>
@end
@implementation LoginView
#pragma mark - AppleIDLogin
- (void) setup {
if (@available(iOS 13.0, *)) {
/*
// 創(chuàng)建一個(gè) provider
ASAuthorizationAppleIDProvider *appleIDProvider = [[ASAuthorizationAppleIDProvider alloc] init];
UmUserModel *model = [UmUserModel getUmUserModel];
if ( [AppleIDLogin isEqualToString:model.loginType] ) {
}
[appleIDProvider getCredentialStateForUserID:model.unionid completion:^(ASAuthorizationAppleIDProviderCredentialState credentialState, NSError * _Nullable error) {
if ( credentialState == ASAuthorizationAppleIDProviderCredentialAuthorized ) {
}
else {
}
}];
*/
ASAuthorizationAppleIDButton *signInButton = [ASAuthorizationAppleIDButton buttonWithType:ASAuthorizationAppleIDButtonTypeSignIn style:ASAuthorizationAppleIDButtonStyleBlack];
signInButton.frame = self.view0.bounds;
[self.view0 addSubview:signInButton];
// 添加響應(yīng)方法
[signInButton addTarget:self action:@selector(signInButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
}
}
- (void) signInButtonClicked:(ASAuthorizationAppleIDButton *)signInButton API_AVAILABLE(ios(13.0)){
ASAuthorizationAppleIDProvider *appleIDProvider = [[ASAuthorizationAppleIDProvider alloc] init];
ASAuthorizationAppleIDRequest *appleIDRequest = [appleIDProvider createRequest];
appleIDRequest.requestedScopes = @[ASAuthorizationScopeFullName, ASAuthorizationScopeEmail];// 要獲取的內(nèi)容
// 登錄使用的一種方式说贝,后面單獨(dú)討論
// ASAuthorizationPasswordProvider *passwordProvider = [ASAuthorizationPasswordProvider new];
// ASAuthorizationPasswordRequest *passwordRequest = [passwordProvider createRequest];
// 系統(tǒng)提供的 Controller,必須使用践惑,需要傳入 requests 數(shù)組
ASAuthorizationController *authController = [[ASAuthorizationController alloc] initWithAuthorizationRequests:@[appleIDRequest]];//, passwordRequest
// 設(shè)置代理腹泌,接收登錄成功/失敗的回調(diào)
authController.delegate = self;
// 頁面跳轉(zhuǎn)相關(guān)的,通過一個(gè)代理方法傳入一個(gè) window
authController.presentationContextProvider = self;
// Controller 初始化期間尔觉,開始授權(quán)流程
[authController performRequests];
}
#pragma mark - ASAuthorizationControllerDelegate
- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithError:(NSError *)error API_AVAILABLE(ios(13.0)){
// 登錄失敗
NSLog(@"auth failed!, error:%@, code:%ld, description:%@", error, (long)error.code, error.description);
}
- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithAuthorization:(ASAuthorization *)authorization API_AVAILABLE(ios(13.0)){
// 登錄成功
if ( [authorization.credential isKindOfClass:[ASAuthorizationAppleIDCredential class]] ) {
ASAuthorizationAppleIDCredential *credential = (ASAuthorizationAppleIDCredential *)authorization.credential;
// 還有其他的屬性
NSLog(@"appleid auth success!, %@", authorization.description);
// 登錄后具體操作凉袱,如數(shù)據(jù)保存,APP自己的登錄等
}
}
#pragma mark - ASAuthorizationControllerPresentationContextProviding
- (ASPresentationAnchor)presentationAnchorForAuthorizationController:(ASAuthorizationController *)controller API_AVAILABLE(ios(13.0)){
// 返回一個(gè) window侦铜,present 登錄界面需要用到
return [UIApplication sharedApplication].delegate.window;
}
#pragma mark AppleIDLogin end
@end