Sign in with Apple
Sign in with Apple is implemented as an external identity provider (IDP). The iOS SDK allows you to implement it with minimal effort. It requires only configuring the project, selecting an identity provider with Apple ID, and handling registration just like for browser=based identity providers. All of the calls to the AuthorizationServices
framework will be made by the iOS SDK.
To configure the project, follow steps mentioned here.
Note
Perform the following steps before building and running the app:
- Set your development team in the Signing & Capabilities tab so Xcode can create a provisioning profile that uses the Sign In with Apple capability.
- Choose a target device that you’re signed into with an Apple ID that uses Two-Factor Authentication.
Initiating registration
An identity provider that supports Apple ID can be picked by fetching the identity providers set and selecting the an object with the ExternalIdpAppleType
value under the externalIdentityProvider.type
property.
let identityProviders = SharedUserClient.instance.identityProviders
let appleIdentityProvider = identityProviders.filter { $0.type == .apple }
SharedUserClient.instance.registerUserWith(identityProveder: appleIdentityProvider,
scopes: ["read"],
delegate: self)
NSSet <ONGIdentityProviders *> *identityProviders = [ONGUserClient sharedInstance].identityProviders;
ONGIdentityProvider *appleIdentityProvider = [identityProviders filteredSetUsingPredicate:[NSPredicate predicateWithFormat:@"externalIdentityProvider.type == %@", ONGExternalIdpAppleType]].anyObject;
[[ONGUserClient sharedInstance] registerUserWithIdentityProvider:appleIdentityProvider scopes:yourScopes delegate:self];
The iOS SDK will perform Sign in with Apple ID using the authorization services framework after you call SharedUserClient.instance.register
method. The native popup will be shown to the user. After successful authentication, the iOS SDK will send the browser registration challenge that needs to be handled.
Handling registration
The user registration with Apple ID is handled the same way as browser-based identity providers.