AppleSignIn
import { AppleSignIn } from 'nitro-apple-signin'
Signs users in with their Apple ID through AuthenticationServices on iOS. All methods are static.
| Member | Returns | Summary |
|---|---|---|
isSupported() | boolean | Whether this platform can sign in with Apple. |
signIn(options?) | Promise<AppleCredential | undefined> | Shows Apple's sheet; undefined on cancel. |
getCredentialState(userId) | Promise<AppleCredentialState> | Whether the Apple ID still authorizes the app. |
Failures reject with an Error whose message starts with a [CODE] tag; read it with getAppleSignInErrorCode. On Android every method except isSupported rejects with NOT_SUPPORTED.
isSupported
static isSupported(): boolean
Returns whether this platform can sign in with Apple: true on iOS, false on Android. Synchronous. Use it to decide whether to show a "Sign in with Apple" button.
signIn
static signIn(options?: AppleSignInOptions): Promise<AppleCredential | undefined>
Shows Apple's sign-in sheet and resolves the AppleCredential, or undefined when the user cancels.
Apple returns the email and full name only the first time a user signs in to this app; store them then. Needs the Sign in with Apple capability in the app's entitlements.
| Parameter | Type | Description |
|---|---|---|
options | AppleSignInOptions | Scopes, nonce and state. Optional. |
Rejects with:
| Code | When |
|---|---|
IN_PROGRESS | Another sign-in is still running. |
NO_PRESENTER | No foreground window can show the sheet. |
SIGN_IN_FAILED | Apple could not complete the sign-in, or returned no token or code. |
NOT_SUPPORTED | Android. |
getCredentialState
static getCredentialState(userId: string): Promise<AppleCredentialState>
Returns whether the Apple ID userId still authorizes this app. Check it on launch with the AppleCredential.user you stored, and sign out when it is revoked or notFound. See Credential state.
| Parameter | Type | Description |
|---|---|---|
userId | string | The user of a credential from signIn. |
Resolves an AppleCredentialState. Rejects with CREDENTIAL_STATE_FAILED when Apple cannot report the state, and NOT_SUPPORTED on Android.