# Modules.Applesignin

A module to use apple signin functionality.

Availability
1.0.0

# Overview

# Apple sign in Resources

# Requirements

  • iOS 13 and later

# Getting Started

# Configure iOS: Capabilities and Provisioning Profiles

  • Required capabilities:

    <key>com.apple.developer.applesignin</key>
    <array>
      <string>Default</string>
    </array>
    
  • Provisioning Profile entitled with 'Sign In with Apple' capability

# Accessing the Module

  • Use require to access this module from JavaScript:

    var AppleSignin = require('ti.applesignin');
    

    The AppleSignin variable is a reference to the Module object.

# Example applications

  • Example applications are located in the example/ios folder of the module:

# Properties

# apiName READONLY

Availability
3.2.0
apiName :String

The name of the API that this proxy corresponds to.

The value of this property is the fully qualified name of the API. For example, Titanium.UI.Button returns Ti.UI.Button.


# bubbleParent

Availability
3.0.0
bubbleParent :Boolean

Indicates if the proxy will bubble an event to its parent.

Some proxies (most commonly views) have a relationship to other proxies, often established by the add() method. For example, for a button added to a window, a click event on the button would bubble up to the window. Other common parents are table sections to their rows, table views to their sections, and scrollable views to their views. Set this property to false to disable the bubbling to the proxy's parent.

Default: true

# Methods

# addEventListener

Availability
1.0.0
addEventListener(name, callback) void

Adds the specified callback as an event listener for the named event.

Parameters

Name Type Description
name String

Name of the event.

callback Callback<Titanium.Event>

Callback function to invoke when the event is fired.

Returns

Type
void

# applyProperties

Availability
3.0.0
applyProperties(props) void

Applies the properties to the proxy.

Properties are supplied as a dictionary. Each key-value pair in the object is applied to the proxy such that myproxy[key] = value.

Parameters

Name Type Description
props Dictionary

A dictionary of properties to apply.

Returns

Type
void

# authorize

Availability
1.0.0
authorize(scopes) void

Request Apple ID authorization.

After authorizarion it will fire event login event which tells success or failure of login.

Parameters

Name Type Description
scopes Array<Number>

The contact information to be requested from the user during authentication. Use the Modules.Applesignin.AUTHORIZATION_SCOPE_* constant values to populate the array.

Returns

Type
void

# createLoginButton

Availability
1.0.0
createLoginButton([parameters]) Modules.Applesignin.LoginButton

Creates and returns an instance of Modules.Applesignin.LoginButton.

Parameters

Name Type Description
parameters Dictionary<Modules.Applesignin.LoginButton>

Properties to set on a new object, including any defined by Modules.Applesignin.LoginButton except those marked not-creation or read-only.

Returns


# fireEvent

Availability
1.0.0
fireEvent(name[, event]) void

Fires a synthesized event to any registered listeners.

Parameters

Name Type Description
name String

Name of the event.

event Dictionary

A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

Returns

Type
void

# getCredentialState

Availability
1.0.0
getCredentialState(userId, callback) void

Returns the credential state for the given user.

This method returns immediately without waiting for tasks to finish. Once a session is invalidated, new tasks cannot be created in the session, but existing tasks continue until completion. Once invalidated, references to the events and callback objects are broken. Session objects cannot be reused. To cancel all outstanding tasks, call invalidateAndCancel instead.

Parameters

Name Type Description
userId String

A string, <Modules.Applesignin.ProfileObject.userId>, associated with the Apple ID that your app receives in login event.

callback Callback<CredentialStateResponse>

Function to invoke on success or failure.

Returns

Type
void

# removeEventListener

Availability
1.0.0
removeEventListener(name, callback) void

Removes the specified callback as an event listener for the named event.

Multiple listeners can be registered for the same event, so the callback parameter is used to determine which listener to remove.

When adding a listener, you must save a reference to the callback function in order to remove the listener later:

var listener = function() { Ti.API.info("Event listener called."); }
window.addEventListener('click', listener);

To remove the listener, pass in a reference to the callback function:

window.removeEventListener('click', listener);

Parameters

Name Type Description
name String

Name of the event.

callback Callback<Titanium.Event>

Callback function to remove. Must be the same function passed to addEventListener.

Returns

Type
void

# Events

# login

Availability
1.0.0

Fired at login.

Properties

Name Type Description
success Boolean

Indicates if the user was logged in successfully. Returns true if request succeeded, false otherwise.

cancelled Boolean

Indicates if the user cancelled the login request by closing the dialog.

error String

Error message, if any returned. Will be undefined if success is true.

profile ProfileObject

User profile returned after successful login.

source Object

Source object that fired the event.

type String

Name of the event fired.

bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

# Constants

# AUTHORIZATION_SCOPE_EMAIL

Availability
1.0.0
AUTHORIZATION_SCOPE_EMAIL :Number

A scope that includes the user's email address.


# AUTHORIZATION_SCOPE_FULLNAME

Availability
1.0.0
AUTHORIZATION_SCOPE_FULLNAME :Number

A scope that includes the user's full name.


# BUTTON_STYLE_BLACK

Availability
1.0.0
BUTTON_STYLE_BLACK :Number

Authorization button style black. Use with style.


# BUTTON_STYLE_WHITE

Availability
1.0.0
BUTTON_STYLE_WHITE :Number

Authorization button style white. Use with style.


# BUTTON_STYLE_WHITE_OUTLINE

Availability
1.0.0
BUTTON_STYLE_WHITE_OUTLINE :Number

Authorization button style white outline. Use with style.


# BUTTON_TYPE_CONTINUE

Availability
1.0.0
BUTTON_TYPE_CONTINUE :Number

Continue authorization button type. Use with type.


# BUTTON_TYPE_DEFAULT

Availability
1.0.0
BUTTON_TYPE_DEFAULT :Number

Default authorization button type. Use with type.


# BUTTON_TYPE_SIGN_IN

Availability
1.0.0
BUTTON_TYPE_SIGN_IN :Number

Signin authorization button type. Use with type.


# CREDENTIAL_STATE_AUTHORIZED

Availability
1.0.0
CREDENTIAL_STATE_AUTHORIZED :Number

The user is authorized.


# CREDENTIAL_STATE_NOT_FOUNFD

Availability
1.0.0
CREDENTIAL_STATE_NOT_FOUNFD :Number

The user can't be found.


# CREDENTIAL_STATE_REVOKED

Availability
1.0.0
CREDENTIAL_STATE_REVOKED :Number

Authorization for the given user has been revoked.


# USER_DETECTION_STATUS_REAL

Availability
1.0.0
USER_DETECTION_STATUS_REAL :Number

The user appears to be a real person.


# USER_DETECTION_STATUS_UNKNOWN

Availability
1.0.0
USER_DETECTION_STATUS_UNKNOWN :Number

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


# USER_DETECTION_STATUS_UNSUPPORTED

Availability
1.0.0
USER_DETECTION_STATUS_UNSUPPORTED :Number

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