README
appbooster-sdk-react-native
React Native wrapper for Appbooster SDK (ios, android)
Installation
Note that RN SDK currently doesn't support projects with RN < 0.62.
If you want to use RN SDK in your project, please, upgrade your project to RN >= 0.62
Common steps
install library
Yarn:
yarn add appbooster-sdk-react-native
npm:
npm install --save appbooster-sdk-react-native
Platform-specific steps
iOS
1. Swift support step
If you use use_frameworks!
Add next lines of code in
Podfile
:
use_frameworks! # You already use it in your project!
# add next lines of code:
pre_install do |installer|
installer.pod_targets.each do |pod|
if pod.name.eql?('appbooster-sdk-react-native')
def pod.build_type; # Uncomment one line depending on your CocoaPods version
Pod::BuildType.static_library # Pods version >= 1.9 (uncommented by default)
# Pod::Target::BuildType.static_library # Pods version < 1.9
end
end
end
end
If you don't use use_frameworks!
(default for RN projects)
If you have no Swift integration in your project follow next steps:
- In XCode, in the project navigator, right click your
[your project's name]
folder, choose ➜Add Files to [your project's name]
- Select
Swift File
➜Next
- Specify name for example
Dummy.swift
➜Create
- Now a pop up is shown select
Create Bridging Header
2. Pods installation step
cd ios && pod install && cd ..
Android
You no need to do anything!
Usage
import AppboosterSdk from 'appbooster-sdk-react-native';
Initialization:
const connected = await AppboosterSdk.connect({
appId: 'YOUR_APP_ID',
sdkToken: 'YOUR_SDK_TOKEN',
deviceId: 'YOUR_DEVICE_ID', // optional, UUID generated by default
appsFlyerId: 'YOUR_APPSFLYER_ID', // optional, null by default, use appsFlyer.getAppsFlyerUID if AppsFlyer integration is needed
amplitudeUserId: 'YOUR_AMPLITUDE_ID', // optional, null by default, use id that you set with `amplitudeInstance.setUserId` method if Amplitude integration is needed
deviceProperties: {
installedAt: '2021-05-20T09:55:05.000+03:00',
}, // optional, empty object by default, additional information about device. You can use next data types: String, Number, Boolean, Date.
usingShake: false, // false by default, cause React Native already uses shake motion in debug mode for own purposes (show React Native debug window after shaking your device)
defaults: {
['TEST_1_KEY']: 'TEST_1_DEFAULT_VALUE',
['TEST_2_KEY']: 'TEST_2_DEFAULT_VALUE',
},
}); // boolean
How to fetch known test values that associated with your device?
const fetched = await AppboosterSdk.fetch(); // boolean
How to get the value for a specific test?
const experiments = await AppboosterSdk.getExperiments(); // object with experiments
// or if you need additional details for experiments
// const experiments = await AppboosterSdk.getExperimentsWithDetails(); // object with experiments
const value = experiments['TEST_1_KEY']; // string
In case of problems with no internet connection or another, the values obtained in the previous session will be used, or if they are missing, the default values specified during initialization will be used.
How to get user tests for analytics?
const experiments = await AppboosterSdk.getExperiments(); // object with experiments
// or if you need additional details for experiments
// const experiments = await AppboosterSdk.getExperimentsWithDetails(); // object with experiments
// example: send to amplitude and appsflyer
// https://github.com/amplitude/Amplitude-ReactNative
const amplitudeInstance = Amplitude.getInstance();
amplitudeInstance.init('Your Amplitude key');
amplitudeInstance.setUserProperties(experiments);
// https://github.com/AppsFlyerSDK/appsflyer-react-native-plugin
try {
await appsFlyer.initSdk(/*object with options*/);
appsFlyer.setAdditionalData(experiments, (res) => {
/*...*/
});
} catch (err) {}
How to debug?
Before debug make sure that debug-mode for your App is turned-on on settings page
const connected = await AppboosterSdk.connect({
//...
showLogs: true, // false by default, to print all debugging info in the console (note that currently you can see logs in XCode or Android Studio but not in JS console)
//...
});
const duration = await AppboosterSdk.getLastOperationDurationMillis(); // number (the duration of the last operation in milliseconds)
In debug mode you can see all actual tests and check how the user will see each option of the test. To show the debug activity you just need to turn it on in your personal cabinet and call
const isDebugModeLaunched = await AppboosterSdk.launchDebugMode(); // boolean
Platform specific (optional info for React Native project)
You can find more info about debug menu usage in iOS and Android here: ios, android)
==================================================
You can see the example of usage here
For additional info you also can see docs of native Appbooster SDK (ios, android)
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT