Client Attributes
Optional
In some cases, the Host application may need to pass attributes to the DR SDK. This is supported with the ClientAttributes class provided as a part of the SDK.
The following code snippet shows how this can be done.
Avoid Data Override
Please note that all values need to be passed together to the SDK before the
setClientAttributes
method is called. By calling multiple times the previous data would be overwritten and only the new value would be available and sent to DR servers.
// import Module from DR lib
import { NativeModules } from 'react-native';
const { IuLibraryModule } = NativeModules;
const App: () => Node = () => {
....
// Start of Sending Client Attributes
// Set Client Attributes to be sent with JSONObject and Pass the values to the IU SDK.
useEffect(() => {
var jsonObject = {
"PHONE_NUMBER": '9876543210',
"CARRIER": 'AIRTEL',
"BILL_TYPE": 'PrePaid'
};
IuLibraryModule.setClientAttributes(JSON.stringify(jsonObject));
},[])
// End of of Sending Client Attributes
....
}
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, DR would be storing the information in DB for future reference.
// Example 1 - setting the phone number
useEffect(() => {
var jsonObject = { PHONE_NUMBER : '9876543210'};
IuLibraryModule.setClientAttributes(JSON.stringify(jsonObject));
},[])
// Example 2 - setting the bill type and custom key
useEffect(() => {
var jsonObject = { BILL_TYPE : 'PrePaid', NEW_KEY : 'new_value'};
IuLibraryModule.setClientAttributes(JSON.stringify(jsonObject));
},[])
External ID
We can set the Partner ID or External ID or Host App reference ID using the Client Attributes.
For this we have reserved a KEY as "EXTERNAL_ID".
Example:
// Example 3 - setting the External ID
useEffect(() => {
var jsonObject = { EXTERNAL_ID : '[email protected]'};
IuLibraryModule.setClientAttributes(JSON.stringify(jsonObject));
},[])
Updated over 2 years ago