# Interface AppleSignInNative

public interface AppleSignInNative

Service-provider interface for native `Sign in with Apple`. The iOS port supplies a class `com.codename1.social.AppleSignInNativeImpl` that wraps `ASAuthorizationAppleIDProvider`; `AppleSignIn` loads it via `Class.forName` at first use. Cn1libs that want to plug in their own implementation can register one with

invalid reference

    AppleSignIn#setNative(AppleSignInNative)

-- this interface does not extend `NativeInterface` because `AppleSignIn` is part of the core framework and the iOS impl talks to native code via `IOSImplementation.nativeInstance`, not through `NativeLookup`.

The native side serialises its result as a single pipe-delimited string to keep the bridge boundary primitive-only:

`{idToken}|{authorizationCode}|{user}|{givenName}|{familyName}|{email}`

`null` segments are sent as empty strings. `user` is the stable opaque identifier Apple returns; `givenName` / `familyName` / `email` are only populated on the first authorization (Apple does not re-send the profile on subsequent logins). The Java side persists them.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `isLoggedIn()`
  Returns `true` if the user is currently signed in (i.e. the previously returned credential is still valid in the Apple keychain).
  `boolean`
  `isSupported()`
  `true` if this implementation is usable on the current device / OS version.
  `String`
  `signIn(String scopes, String nonce)`
  Starts the system Sign-in-with-Apple sheet.
  `void`
  `signOut()`
  Clears the current Apple credential from the app's keychain entry.

- ## Method Details

  - ### isSupported

    boolean isSupported()
    `true` if this implementation is usable on the current device / OS version. iOS 13+ returns `true`; older iOS, non-iOS platforms, or missing entitlement returns `false` so `AppleSignIn` falls back to its web OIDC flow.

  - ### signIn

    String signIn(String scopes, String nonce)

    Starts the system Sign-in-with-Apple sheet. The call blocks the calling thread until the user completes or cancels.

    ###### Parameters

    - `scopes`: Space-separated scope list (e.g. `"name email"`).
    - `nonce`: SHA-256 hash of the per-request nonce, base64url encoded. Apple binds this to the returned ID token's `nonce` claim.

  - ### isLoggedIn

    boolean isLoggedIn()
    Returns `true` if the user is currently signed in (i.e. the previously returned credential is still valid in the Apple keychain).

  - ### signOut

    void signOut()
    Clears the current Apple credential from the app's keychain entry. Apple does not provide an explicit sign-out -- this only removes the local credential association so the next `signIn(String, String)` will prompt again.