Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Latest commit

 

History

History
147 lines (97 loc) · 5.08 KB

_lib_index_d_.rnappleauth.module.md

File metadata and controls

147 lines (97 loc) · 5.08 KB

Interface: appleAuth Module

This is the default module provided by react-native-apple-authentication.

What is it?

This module contains the methods you will use to perform sign in requests, and to revoke authorization access.

import React from 'react';
import { View, Button } from 'react-native';
import appleAuth, {
  AppleButton,
  AppleAuthCredentialState,
} from '@invertase/react-native-apple-authentication';

async function onAppleButtonPress() {
  // sign in request
  const responseObject = await appleAuth.performRequest({
    requestedOperation: AppleAuthRequestOperation.LOGIN,
    requestedScopes: [AppleAuthRequestScope.EMAIL, AppleAuthRequestScope.FULL_NAME],
  });

  //authorization state request
  const credentialState = await appleAuth.getCredentialStateForUser(responseObject.user);

  if (credentialState === AppleAuthCredentialState.AUTHORIZED) {
    //user is authorized
  }
}

async function onLogoutPress() {
  //logout request
  const responseObject = await appleAuth.performRequest({
    requestedOperation: AppleAuthRequestOperation.LOGOUT,
  });
}

function App() {
  return (
    <View>
      <AppleButton
        cornerRadius={5}
        buttonStyle={AppleButton.Style.BLACK}
        buttonType={AppleButton.Type.SIGN_IN}
        onPress={() => onAppleButtonPress()}
      />
      <Button onPress={() => onLogoutPress()}>Log me out</Button>
    </View>
  );
}

Index

Properties

Methods

Properties

isSignUpButtonSupported

isSignUpButtonSupported: boolean

Defined in lib/index.d.ts:368

A boolean value of whether the 'SignUp' Type variant of the Apple Authentication Button is supported.

This will always return false for Android, and false for iOS devices running iOS versions less than 13.2


isSupported

isSupported: boolean

Defined in lib/index.d.ts:359

A boolean value of whether Apple Authentication is supported on this device & platform version.

This will always return false for Android, and false for iOS devices running iOS versions less than 13.

Methods

getCredentialStateForUser

getCredentialStateForUser(user: string): _Promise‹AppleAuthCredentialState›_

Defined in lib/index.d.ts:381

Get the current @{RNAppleAuth.AppleAuthCredentialState} for the provided user identifier.

Parameters:

Name Type Description
user string An opaque user ID associated with the AppleID used for the sign in.

Returns: _Promise‹AppleAuthCredentialState›_


onCredentialRevoked

onCredentialRevoked(listener: Function): Function

Defined in lib/index.d.ts:389

Subscribe to credential revoked events. Call getCredentialStateForUser on event received to confirm the current credential state for your user identifier.

Parameters:

Name Type Description
listener Function Returns a function that when called will unsubscribe from future events.

Returns: Function


performRequest

performRequest(options: AppleAuthRequestOptions): _Promise‹AppleAuthRequestResponse›_

Defined in lib/index.d.ts:374

Perform a request to Apple Authentication services with the provided request options.

Parameters:

Name Type Description
options AppleAuthRequestOptions AppleAuthRequestOptions

Returns: _Promise‹AppleAuthRequestResponse›_