@screeb/react-native
A react-native module to integrate Screeb mobile sdk for Android and/or iOS.
Installation
npm install @screeb/react-native
iOS specific configuration
You should set IOS target build configuration BUILD_LIBRARY_FOR_DISTRIBUTION to YES in your Podfile to avoid runtime crash:
post_install do |installer|
...
installer.pods_project.targets.each do |target|
...
target.build_configurations.each do |config|
...
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
When upgrading a Screeb sdk-reactnative version, it can be useful to run in /ios directory :
pod update Screeb
Android specific configuration
First, you should use MultidexApplication if not yet to avoid compilation issues.
defaultConfig {
(...)
multiDexEnabled true
}
(...)
dependencies {
(...)
implementation 'androidx.multidex:multidex:2.0.1'
}
Then, the Android sdk needs to be notified of activities lifecycle changes to be correctly started.
It is mandatory to pass the Application context to the module in your custom Application class
in the onCreate function :
override fun onCreate() {
super.onCreate()
ScreebModuleModule.setAppContext(this)
}
NB : Your android app needs to use AGP minimum 7.1.3
classpath("com.android.tools.build:gradle:7.1.3")
Usage
import { initSdk, trackScreen, trackEvent, setProperties, setIdentity } from "@screeb/react-native";
React.useEffect(() => {
initSdk(
"<android-channel-id>",
"<ios-channel-id>",
"<user-identity>",
{
'example-prop1': false,
'example-prop2': 29,
'example-prop3' : 'iPhone 13',
}
);
}, []);
(...)
setIdentity(
'<user-identity>',
{
'example-prop1': false,
'example-prop2': 29,
'example-prop3' : 'iPhone 13',
}
);
(...)
trackEvent(
'<event-name>',
{
'example-prop1': false,
'example-prop2': 29,
'example-prop3' : 'iPhone 13',
}
);
(...)
trackScreen(
'<screen-name>',
{
'example-prop1': false,
'example-prop2': 29,
'example-prop3' : 'iPhone 13',
}
);
(...)
setProperties(
{
'example-prop1': false,
'example-prop2': 29,
'example-prop3' : 'iPhone 13',
}
);
License
MIT