Install
How to install the React-Native SDK in your app?โ
See the example to install the last version of the Screeb SDK dependency in a React-Native app.
Screeb SDK Usage in CI Environmentsโ
Please note that if you are utilizing a Continuous Integration (CI) system, it is advisable to deactivate the Screeb SDK during CI execution. This precaution helps prevent the creation of numerous new anonymous users and potential exceedance of your MTU limit.
Technical requirementsโ
The Screeb SDK is configured to work with Android API 19+ and iOS version 12.0 minimum.
The Swift version is >= 5.0.
Screeb adds about 110 KB on Android and about 450 KB on iOS release apps.
How to configure the React-Native SDK in your app?โ
First, log in to the Screeb application, then create your first survey.
Add Screeb as a dependencyโ
npm install @screeb/react-native
Androidโ
The Android SDK needs the permissions INTERNET to work well.
<uses-permission android:name="android.permission.INTERNET" />
The SDK also need theses permissions if you want to use the Screeb Audio/Video feature.
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.MICROPHONE" />
<uses-feature android:name="android.hardware.camera" android:required="true"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
iOSโ
The SDK need theses permissions if you want to use the Screeb Audio/Video feature.
<key>NSCameraUsageDescription</key>
<string>This app needs access to the camera to take photos.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app needs access to microphone to record audio.</string>
<key>UISupportedInterfaceOrientations</key>
Updateโ
When upgrading the React-Native SDK version, you may need to run in ios/ directory:
cd ios/
pod update Screeb
Import Screeb SDK into your packageโ
import { initSdk, closeSdk, trackScreen, trackEvent, setProperties, setIdentity, resetIdentity, assignGroup, startSurvey } from "@screeb/react-native";
Setup the SDKโ
You can find your channel id in your workspace settings.
// Init the sdk at app start (useEffect hook used here, but componentDidMount is fine)
React.useEffect(() => {
initSdk(
"<YOUR-CHANNEL-ID>",
"<USER-ID>",
{
'example-prop1': false,
'example-prop2': 29,
'example-prop3' : 'iPhone 13',
}
);
}, []);
About SDK lifecycleโ
At any time, you can disable the Screeb SDK with the following command:
import { closeSdk } from "@screeb/react-native";
closeSdk();
Configure In-App Messaging (Deep Links)โ
To enable the Screeb In-App Message editor on your React Native app, you need to configure deep links on both platforms.
iOSโ
Add the following to your Info.plist file, replacing <channel-id> with your channel ID:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>screeb</string>
<key>CFBundleURLSchemes</key>
<array>
<string>screeb-<channel-id></string>
</array>
</dict>
</array>
If using AppDelegate, add this code:
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool {
Screeb.handleDeepLink(url: url)
return true
}
}
Or if using SceneDelegate:
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
Screeb.handleDeepLink(url: URLContexts.first?.url)
}
}
Androidโ
Add the following intent filter to your main Activity in AndroidManifest.xml, replacing <channel-id> with your channel ID:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="screeb-<channel-id>" />
</intent-filter>
Then handle deep links in your MainActivity.kt:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Screeb.handleDeepLink(intent)
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
Screeb.handleDeepLink(intent)
}