@primer-io/react-native package, then wrap your checkout in PrimerCheckoutProvider with a client token. The package brings the native iOS and Android SDKs with it.
Prerequisites
- A React Native app with its
iosandandroidprojects, which you build with Xcode and Gradle - iOS deployment target 15.1 or higher
- Android
minSdkVersion24 or higher - CocoaPods, to install the iOS dependencies
- A client token from your server, created with the Client Session API
This release is built in CI against React Native 0.81.1, 0.82.1 and 0.83.1. The example app runs React Native 0.81 with the New Architecture enabled.
Install the package
Add the package with the exact beta version:This is a beta release line. Check that
package.json lists 3.0.0-beta.1 with no ^ or ~ in front, so a new beta doesn’t change your build until you upgrade on purpose.iOS
Install the pods from your app’sios folder:
.podspec file pins PrimerSDK. Don’t add a pod 'PrimerSDK' line with another version to your Podfile.
Set your app’s deployment target to iOS 15.1 or higher.
Android
React Native links the package automatically. It depends onio.primer:android, io.primer:components-analytics and io.primer:components-bridge, all at the version above. Don’t add these artifacts to your app’s build.gradle or force another version of them.
Set minSdkVersion to 24 or higher in android/build.gradle. The native Android SDK requires API level 24.
Rebuild the app
The package contains native code. Rebuild and reinstall the app on each platform after you install or upgrade it. Reloading the JavaScript bundle doesn’t load new native code.Basic usage
Fetch a client token, mountPrimerCheckoutProvider with it, and render PrimerCheckoutSheet inside:
PrimerCheckoutProviderstarts a checkout session for itsclientTokenand ends it when it unmounts.PrimerCheckoutSheetopens whenvisibleistrue. It closes only when youronRequestDismisssetsvisibletofalse.onDismissruns after the sheet has closed. Unmounting the provider there means the next checkout starts with a new client token.
usePrimerCheckout().paymentOutcome. See Handle the payment result.
Verify the installation
Build and run the app on both platforms:See also
Native setup
URL schemes, Apple Pay, Google Pay and optional native dependencies
Handle the payment result
Read the outcome of each payment attempt
API reference
The provider, the sheet, and the hooks
Troubleshooting
Fix installation and build issues