Setgreet React Native SDK allows you to show Setgreet flows in your React Native app.
- React Native 0.60.0 and above
- iOS 13.0+ (for iOS apps)
- Android 5.0 (API level 21) and above (for Android apps)
npm install @setgreet/react-native-sdk
# or
yarn add @setgreet/react-native-sdk
The iOS SetgreetSDK is automatically included via CocoaPods when you install the React Native SDK:
cd ios && pod install
No additional setup required for Android.
- Setgreet App Key: You can get the app key while creating a new app in the Setgreet flow editor.
Initialize the SDK in your React Native app:
import { initialize } from '@setgreet/react-native-sdk';
initialize('APP_KEY', {
debugMode: false,
});
Identifies a user for Setgreet analytics and flow management.
Parameters:
userId
(String): The unique identifier for the userattributes
(Optional): Additional user attributes
Example:
import { identifyUser } from '@setgreet/react-native-sdk';
identifyUser('user123', {
name: 'John Doe',
email: 'john@example.com',
plan: 'premium',
});
Clears user identification data and resets user session state for logout scenarios.
Example:
import { resetUser } from '@setgreet/react-native-sdk';
resetUser();
- Setgreet Flow ID: The flow ID is a unique identifier for the flow you want to show. You can get the flow ID from the flow's URL at the web app. For example, if the flow URL is
https://app.setgreet.com/flows/1234
, the flow ID is1234
.
To show the Setgreet flow, call the following method:
import { showFlow } from '@setgreet/react-native-sdk';
showFlow('FLOW_ID');
Tracks a screen view for analytics and potential flow triggers.
Parameters:
screenName
(String): The name of the screen being viewedproperties
(Optional): Additional properties associated with the screen view
Example:
import { trackScreen } from '@setgreet/react-native-sdk';
trackScreen('product_detail', {
product_id: 'prod_123',
category: 'electronics',
price: 299.99,
});
Tracks custom events for analytics and flow triggers.
Parameters:
eventName
(String): The name of the custom eventproperties
(Optional): Additional properties associated with the event
Example:
import { trackEvent } from '@setgreet/react-native-sdk';
trackEvent('purchase_completed', {
order_id: 'ord_456',
total_amount: 299.99,
payment_method: 'credit_card',
items_count: 3,
});
- Ensure you've installed CocoaPods dependencies:
cd ios && pod install
- Clean your project:
cd ios && xcodebuild clean
- Reinstall pods:
cd ios && pod install
- Rebuild your project
This usually means you have both the old embedded framework and the new CocoaPods dependency. Make sure you've:
- Updated to the latest version of this package
- Removed any manual SetgreetSDK framework references
- Only use CocoaPods for SetgreetSDK dependency
If you encounter CocoaPods issues:
- Update CocoaPods:
sudo gem install cocoapods
- Clean CocoaPods cache:
pod cache clean --all
- Reinstall:
cd ios && pod install
Android integration should work automatically. If you encounter issues:
- Clean your project:
cd android && ./gradlew clean
- Rebuild:
cd android && ./gradlew assembleDebug
If you continue to have issues, please open an issue with:
- Your React Native version
- iOS/Android version
- Error messages
- Steps to reproduce