Skip to main content

Errors

import {
appleSignInErrorCodes,
getAppleSignInErrorCode,
type AppleSignInErrorCode,
} from 'nitro-apple-signin'
ExportKindSummary
getAppleSignInErrorCodefunctionReads the [CODE] tag of an AppleSignIn error.
AppleSignInErrorCodetypeUnion of every error code.
appleSignInErrorCodesconstantEvery code, as a readonly array.

getAppleSignInErrorCode​

function getAppleSignInErrorCode(error: unknown): AppleSignInErrorCode | undefined

Returns the code of an error thrown or rejected by AppleSignIn, or undefined for any other value: a non-Error, an untagged message, or a tag that is not a known code.

It reads the tag at the start of the message, and also accepts the forms the bridge produces:

MessageResult
[IN_PROGRESS] Another Apple sign-in is ...IN_PROGRESS
signIn: [NOT_SUPPORTED] Android has no ... (synchronous throw)NOT_SUPPORTED
[NOT_SUPPORTED] ... followed by a Kotlin stack traceNOT_SUPPORTED
[NOT_CONFIGURED] ...undefined
plain failureundefined
a string, not an Errorundefined

AppleSignInErrorCode​

type AppleSignInErrorCode =
'NOT_SUPPORTED' | 'NO_PRESENTER' | 'IN_PROGRESS' | 'SIGN_IN_FAILED' | 'CREDENTIAL_STATE_FAILED'
CodeMeaning
NOT_SUPPORTEDThe platform has no Sign in with Apple (Android).
NO_PRESENTERNo foreground window can present the sign-in sheet.
IN_PROGRESSAnother sign-in is already running.
SIGN_IN_FAILEDApple could not complete the sign-in, such as when the app lacks the entitlement or the device has no Apple ID.
CREDENTIAL_STATE_FAILEDApple could not report the credential state.

appleSignInErrorCodes​

const appleSignInErrorCodes: readonly [
'NOT_SUPPORTED',
'NO_PRESENTER',
'IN_PROGRESS',
'SIGN_IN_FAILED',
'CREDENTIAL_STATE_FAILED',
]

Every code AppleSignIn writes into the [CODE] tag of its messages. AppleSignInErrorCode is derived from it.