React Native SDK
Flock provides a React Native SDK that allows developers to integrate Flock’s referral into their apps. This guide will help you set up and use FlockSdk in your React Native project.
Installation
1. Install the Package
To get started, install the SDK package:
OR
2. Link the Native Dependencies
The SDK supports React Native version 0.60 and above, which means auto-linking will handle the native dependencies without extra configuration.
For iOS
- Install CocoaPods dependencies:
- Ensure your
Info.plist
file includes permissions for internet access, as the SDK makes network requests:
For Android
Make sure AndroidManifest.xml
includes the following permission:
Usage
1. Initialize the SDK
Wrap your app in the FlockSDKProvider
and pass the publicAccessKey
in the configuration:
2. Identify Customers
The identify
method should be called after the user has successfully authenticated in your app. This ensures that the user’s details are properly linked to their account in the Flock system. Here’s an example:
3. Open Referrals WebView
To display the referral page for the referrer, use the openPage
method with the referrer
page type. You can also listen for events from the WebView, such as a onClose
event.
4. Open Invitee WebView
To display the invitation page for the invitee, use the openPage
method with the invitee
page type. This method allows for additional callbacks: onSuccess
for successful actions and onInvalid
for invalid cases.
5. Post-Success Flow for Invitees (Optional)
After a successful onboarding of an invitee, you can choose to either navigate the user to your custom success page or open a Flock-hosted success page. Use the openPage
with the invitee?state=success
page type for the latter option.
Example:
FAQ
Q: What React Native version is required?
A: @wflock/react-native-sdk supports React Native 0.60 and above.
Q: Can I customize WebView actions?
A: Yes, you can listen to messages from the WebView and define custom follow-up actions.
Support
If you encounter issues, feel free to contact the Flock support team at support@withflock.com.
Thank you for using Flock SDK!