React Native Widgets

Overview

The module provides an in-app browser to sign in through Authcore in return of the access token, which can be used for accessing information or secret stored in Authcore.

Installation

Install via npm:

$ npm install react-native-authcore

Install via yarn:

$ yarn add react-native-authcore

To add the functionality of the React Native Authcore module to your project you need to link it:

$ react-native link react-native-authcore

Integrate Authcore in your Application

iOS

iOS Callback

In the file ios/<YOUR PROJECT>/AppDelegate.m, add the following:

Next you will need to add a URLScheme using your App's bundle identifier to allow redirection back to the app.

In the file ios/<YOUR PROJECT>/Info.plist, locate the value of CFBundleIdentifier. In latest version for iOS app, this should be $(PRODUCT_BUNDLE_IDENTIFIER)

And then register a URL type entry using the value of CFBundleIdentifier as the value for the CFBundleURLSchemes

Update the podfile used in iOS, in /ios, run the following:

iOS prompts users when signing in with a web browser. authcore.dev will be replaced with your domain name.

Android

In the file android/app/src/main/AndroidManifest.xml you must make sure the MainActivity of the app has a launchMode value of singleTask and that it has the following intent filter:

MainActivity should look like this:

The rule to interpret deep link in intent-filter is to include all combinations of their combined attributes from <data> tag. To ensure starting Authcore for sign in without showing app picker, use a separated intent-filter for the app link. Check https://developer.android.com/training/app-links/deep-linking#adding-filters for more details about deep link in Android.

Sign In

First import the Authcore module and create a new Authcoreinstance.

Then present the hosted login screen:

Storing the access token

Please be reminded that access token should be stored in secure storage. Developers are adviced to have such solution to store the access token returned from the sign in page.

Setting widgets

The module also provides widgets for setting the user profile and security settings.

Widgets require Authcore instance setting for initialization. In common case the instance will be in store like redux using state management. To use widget inside the page, use the component from the instance.

For user profile, use component ProfileScreen.

For settings widget it is shown by an in-app browser. To instantiate it, run settings.show function. See the example below for detail.

Props Parameters

Prop

Type

Description

accessToken

REQUIRED, string

The access token for getting the user information. This is required for the widgets. Passing invalid access token will still show the widget but not showing correct information.

company

OPTIONAL, string

The company name shown in the widget.

logo

OPTIONAL, string

The logo shown in the widget. Should be in absolute path format.

primaryColour

OPTIONAL, string

The primary colour of the widget. Primary colour mainly consists of general button colour, link colour and border colour when the field box is in focus. Allow colour code, rgb colour value or named colour.

successColour

OPTIONAL, string

The success colour of the widget. Success colour mainly consists of verified message and icon. Allow colour code, rgb colour value or named colour.

dangerColour

OPTIONAL, string

The danger colour of the widget. Danger colour mainly consists of error message, button colour for destructive action (e.g. Remove contact) and invalid field box border. Allow colour code, rgb colour value or named colour.

socialLoginPaneStyle

OPTIONAL, string

The flag to decide position where social login pane should located, either topor bottom, default to be bottom.

Example for settings widget:

Setting Width and Height of the Widgets

It is possible to constraint the widget width and height to fit the app design, to do that apply containerStyle with maxWidgetor maxHeight on the widget.

Last updated

Was this helpful?