Skip to main content

AppleSignIn

import { AppleSignIn } from 'nitro-apple-signin'

Signs users in with their Apple ID through AuthenticationServices on iOS. All methods are static.

MemberReturnsSummary
isSupported()booleanWhether 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.

ParameterTypeDescription
optionsAppleSignInOptionsScopes, nonce and state. Optional.

Rejects with:

CodeWhen
IN_PROGRESSAnother sign-in is still running.
NO_PRESENTERNo foreground window can show the sheet.
SIGN_IN_FAILEDApple could not complete the sign-in, or returned no token or code.
NOT_SUPPORTEDAndroid.

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.

ParameterTypeDescription
userIdstringThe 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.