Skip to Content
defold-typescript libraries
defold (official)

defold/extension-siwa/siwa

Functions and constants for interacting Sign in with Apple.

  • GitHub: defold/extension-siwa — pinned to 1.2.0 (released while Defold 1.9.7 was current)
    1. Pick a release from defold/extension-siwa releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as siwa from "siwa"

Functions

siwa.is_supported()

Check if Sign in with Apple is available (iOS 13+).

siwa.get_credential_state(user_id: string, callback: function)

Get the credential state of a user.

siwa.get_credential_state(id, function(self, data)
	if data.credential_state == siwa.STATE_AUTHORIZED then
		print("User has still authorized the application", data.user_id)
	elseif data.credential_state == siwa.STATE_REVOKED then
		print("User has revoked authorization for the application", data.user_id)
	end
end)

Parameters

  • user_id: string — User id to get credential state for.
  • callback: function — Credential state callback function.
    • self: object — The current object.
    • state: table — The credential state (user_id, credential_state)

siwa.authenticate(callback: function)

Show the Sign in with Apple UI

siwa.authenticate(function(self, data)
	print(data.identity_token)
	print(data.user_id)
	print(data.first_name, data.family_name)
	print(data.email)
	if data.user_status == siwa.STATUS_LIKELY_REAL then
		print("Likely a real person")
	end
end)

Parameters

  • callback: function — Authentication callback function.
    • self: object — The current object.
    • state: table — The authentication result data (user_id, identity_token, email, first_name, family_name, status, result)

Constants

siwa.STATE_NOT_FOUND

The user can’t be found.

siwa.STATE_UNKNOWN

Unknown credential state.

siwa.STATE_AUTHORIZED

The user is authorized.

siwa.STATE_REVOKED

Authorization for the given user has been revoked.

siwa.STATUS_UNKNOWN

The system hasn’t determined whether the user might be a real person.

siwa.STATUS_UNSUPPORTED

The system can’t determine this user’s status as a real person.

siwa.STATUS_LIKELY_REAL

The user appears to be a real person.

On this page