Pinwheel SDK for React Native
- Install Pinwheel React Native SDK
$ npm install --save @pinwheel/react-native-pinwheelSome platform integrations may require camera access for verification purposes. On Android, storage access is also required to enable direct deposit form downloads on API level 28 (Android 9) and below. Ensure the following permissions are configured in your project:
Android: Add the following permission to your AndroidManifest.xml:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
iOS: Add the following entry to your Info.plist:
<key>NSCameraUsageDescription</key>
<string>We need access to your camera for verification purposes.</string>
To initialize Link Modal, a short-lived link token will need to be generated first. Your server can generate the link token by sending a POST request to the /v1/link_tokens endpoint. DO NOT ever send this request from the client side and publicly expose your api_secret.
The link token returned is valid for one hour, after which it expires and can no longer be used to initialize Link. The expiration time is returned as a unix timestamp.
The PinwheelLink component is a view that you can integrate into your app's flow like so:
import PinwheelLink from "@pinwheel/react-native-pinwheel";
<PinwheelLink
linkToken={response.data.token}
onLogin={result => { /* ... */ }}
onError={error => { /* ... */ }}
onSuccess={result => { /* ... */ }}
onExit={error => { /* ... */ }}
onEvent={(eventName, payload) => { /* ... */ }}
/>;With the PinwheelLink component, end-users can select their employer, authenticate with their payroll platform login credentials, and authorize the direct deposit change. Throughout the authorization process, events will be emitted to the onEvent callback and any errors (both user errors such as invalid parameters and any system errors which arise) will be emitted to the onError callback. Upon a successful login, onLogin will be called and once the full flow is complete the onSuccess callback will be called. onExit will be called when the Pinwheel modal is closed, and you should remove the PinwheelLink component from your view hierarchy.
The link token retrieved using the create link token endpoint.
| Type | Required |
|---|---|
| string | Yes |
Callback when a user successfully signs in to their payroll account.
| Type | Required |
|---|---|
| function | No |
Callback whenever an error occurs during the modal flow. This does not necessarily mean that the flow cannot still complete successfully. These include such retryable events as the user inputting an incorrect password or MFA code and needs to reattempt it. Error codes can be seen here.
| Type | Required |
|---|---|
| function | No |
Callback whenever a user completes a modal flow successfully. Note: This is simply a front end callback only. If a user begins a job, closes the app, and the job completes successfully this callback will not be called.
| Type | Required |
|---|---|
| function | No |
Callback whenever a user exits the modal either explicitly or if an error occurred that crashed the modal. Error codes can be seen here. Will pass back an error result if the modal either crashed due to an error or if the user exited while in an error state (e.g. invalid credentials).
| Type | Required |
|---|---|
| function | No |
Callback for all significant events that happen during the modal flow. See all possible event types.
| Type | Required |
|---|---|
| function | No |
Determines whether the SDK should respond to window insets on Android. This allows the modal to adjust automatically for areas such as the display cutout and system bars when displaying content edge-to-edge.
| Type | Required | Default |
|---|---|---|
| boolean | No | true |
Enables Link to run with a dark mode theme.
| Type | Required | Default |
|---|---|---|
| boolean | No | false |
You may want to run the example app locally to get started. The application is located inside of the example_expo directory inside of the repository.
- Node 22.18.0 (check with
node -vand upgrade versions usingnvmif needed) - Xcode for iOS
- Android Studio for Android
Enter the example_expo directory and run the following commands:
- Create a
.envfile with your Pinwheel API secret. An example env file is located at example_repo/.env.example. - Directions to run the iOS simulator
- Directions to run the Android simulator
EXPO_PUBLIC_PINWHEEL_API_KEY=YOUR_API_SECRET
npm inpm run ios(for iOS)npm run android(for Android)
- Click Apple > About This Mac > Storage > Manage > Developer
- Delete Xcode cache
- Delete Project Build and indexes
- Try downloading Xcode 14.2 from https://developer.apple.com/download/all/?q=xcode
For this or other errors related to command line developer tools:
- Make sure you have Command Line Tools for Xcode 14.2 installed
- Open Xcode > Click Xcode in the app menu > Settings > Locations > Command Line Tools dropdown and set the correct location