Signing in
AppleSignIn.signIn(options?) shows Apple's sign-in sheet and resolves an AppleCredential, or undefined when the user cancels.
const credential = await AppleSignIn.signIn({
scopes: ['fullName', 'email'],
nonce: rawNonce,
state: requestId,
})
Options
| Option | Type | Effect |
|---|---|---|
scopes | AppleSignInScope[] | 'fullName' and/or 'email'. Defaults to none: Apple then returns only the user ID and tokens. |
nonce | string | Raw, random, single-use. Hashed with SHA-256 before it goes to Apple. |
state | string | Opaque value returned unchanged in credential.state, to match the response to the request. |
All options are optional; signIn() with no argument asks for no scopes.
Email and name arrive once
Apple returns email and fullName only the first time a user signs in to your app. Later sign-ins leave both undefined, even with the scopes requested. Store them, or send them to your backend, as soon as you receive them.
:::warning Store first-sign-in data immediately If you drop the email or name on the first sign-in, later sign-ins will not bring them back. :::
emailmay be a private relay address ending in@privaterelay.appleid.com.fullNameisundefinedwhen every name component is empty, which is what Apple returns after the first sign-in.
The credential
| Field | Meaning |
|---|---|
user | Stable user ID, the sub claim of the ID token. Same on every device for apps of one developer team. |
identityToken | OpenID Connect ID token (JWT). Verify it on your backend. |
authorizationCode | Short-lived, single-use code your backend exchanges with Apple for refresh tokens. |
realUserStatus | likelyReal, unknown or unsupported. |
state | The state you passed. |
email, fullName | First sign-in only, when the scope was requested. |
Save user: it is the key for getCredentialState.
Cancellation
Closing the sheet resolves undefined. Only real failures reject.
const credential = await AppleSignIn.signIn()
if (credential === undefined) return // user cancelled
One sign-in at a time
Only one sign-in runs at a time. A call made while the sheet is showing rejects with IN_PROGRESS. Guard your button against double taps, as the example button does.
Presentation
The sheet is presented from the window of the top-most view controller of the foreground key window. When there is none, for example while the app is in the background, signIn rejects with NO_PRESENTER.