Additional Methods React
SDK Invocation and Functions
For use the plugin you need import to your class:
import SiprocalPluginModule from "siprocalsdk-reactnative-plugin";
Common methods for Android and iOS
Custom Org Selection (Optional):
If the client wishes to make the same app available for different organizations, they can achieve this by calling the following API to the Siprocal SDK.
SiprocalPluginModule.setCountryCodeSelected(countryCode)
Opt-In/Opt-Out Settings:
The host application can provide an option to the users to Opt-In and Opt-Out of the Ads services. The same can be accomplished via the following methods to access or update the Status. The method accepts boolean value. When TRUE is passed, the user is Opted-In to the Ad services and when FALSE is passed, the user is Opted-Out of the Ad Service.
To update Opt-In status:
SiprocalPluginModule.updateOptInStatus(optinValue)
To get Opt-in status:
SiprocalPluginModule.getOptInStatus().then((data) => {
const optinValue = data
});
ClientAttributes:
In some cases, the Host application may need to pass attributes to the Siprocal SDK. This is supported with the ClientAttributes class provided as a part of the SDK.
Note: Avoid Data Override: Please note that all values need to be passed together to the SDK before the setClientAttributes method is called. Calling the method multiple times will overwrite the previous data, and only the new value will be available and sent to Siprocal servers.
The following code snippet shows how this can be done.
const json = { CUSTOM_CLIENT_ATTRIBUTE: ‘custom value’ };
SiprocalPluginModule.setClientAttributes(JSON.stringify(json));
The following are the keys which we have pre-defied.
- Phone number - "PHONE_NUMBER"
- Carrier - "CARRIER"
- Bill type - "BILL_TYPE" // POSTPAY or PREPAY.
In addition to the keys above you are free to add your own keys, Siprocal would be storing the information in DB for future reference.
Methods available for Android
Enable/Disable capture of Sensitive Data:
Capturing sensitive data requires a prominent disclosure, and the user must consent to the app's data capture and usage. If the user consents, the app should send a boolean flag using the following method:
Keep in mind that capturing data deemed sensitive depends on the user’s acceptance of the prominent popup, which must be created and managed by the host application.
SiprocalPluginModule.setSensitiveDataSwitch(sensitiveValue)
Notification Channel
If you need to know information about the SDK notification channel you can use the following methods.
SiprocalPluginModule.getNotificationChannelId().then((data) => {
const notificationChannelId = data
});
SiprocalPluginModule.getNotificationChannelName()().then((data) => {
const notificationChannelName = data
});
FCM Push Integration (Optional)
FCM integration in Android for Host Apps with existing FCM implementation :
Follow these steps if your application has Firebase Cloud Messaging (FCM). If not you can skip this section.
To get the App token and handle the push notification when App is in foreground, added the next code in the file App.tsx
import { NativeModules } from 'react-native';
const { SiprocalPluginModule } = NativeModules;
export default function App() {
React.useEffect(() => {
if (Platform.OS === 'android') {
PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS
);// for Android 13+
messaging().onMessage(async (remoteMessage) => {
const siprocalFcmSenderId = await SiprocalPluginModule.getFCMSenderId();
if (
Platform.OS === "android" &&
siprocalFcmSenderId === remoteMessage.from
) {
const jsonString = JSON.stringify(remoteMessage.data);
SiprocalPluginModule.invokeFCM(jsonString);
}
});
messaging().onTokenRefresh((token) => {
// HostApp can handle the FCM token here...
SiprocalPluginModule.refreshToken();
});
}
}, []);
}
App in Background
When App is in Background, include the following sample code to your index.js file.
import { NativeModules } from 'react-native';
const { SiprocalPluginModule } = NativeModules;
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
const siprocalFcmSenderId = await SiprocalPluginModule.getFCMSenderId();
if (Platform.OS === "android" && siprocalFcmSenderId === remoteMessage.from) {
const jsonString = JSON.stringify(remoteMessage.data);
SiprocalPluginModule.invokeFCM(jsonString);
}
});
And in your AndroidManifest.xml add the next line inside of <application> tag
<service
android:name="com.siprocal.sdk.data.cloudmessage.SiproFirebaseMessagingService"
tools:node="remove" />
Methods available for iOS
Request Push Notification Permission:
SiprocalPluginModule.requestPushPermissioniOS()
App Tracking Permission:
Siprocal SDK needs to request App Tracking permission from the user to collect IDFA details and track user activity on DR Platform. Below is the sample code to invoke the same from any View Controller class.
SiprocalPluginModule.requestAppTrackingTransparencyPermissioniOS()
Updated 2 days ago