Back in the ReferralHero overview, click to edit your desired Campaign.
Then the Installation tab, then Mobile App Installation.
Get your UUID: The 12-letter ID that starts with ‘MF’ in Edit Campaign > launch > Mobile app installation, e.g. MF15298bba6d.
Add the Campaign Token obtained from the campaign, and UUID from the installation Tab.
Step 4:
In the Goal section of your Campaign settings, ensure you have added the Google Play and Apple App Store links and a default referral link for desktop web users.
Well done! You should now be able to build and run your campaign. Before using the more advanced features of the API, you should learn about a couple of important concepts.
Tracking Referrals
Now that you have implemented the SDK, you can start identifying and tracking referrals!
For that, you will need 2 things:
Universal Link
Your Integrated App
The RH SDK Pulls information from your Device, like this:
final referralParams = {
'email': 'user@example.com', // Capture this from user
'hosting_url': 'https://a.domain.co/', // Optional value, and set as default by admin
'name': 'User Name', // Capture this from user
'referrer': 'referrerCode', // Optional value, only necessary if you want to capture the referrer code from user
'uuid': 'MFcd4113d4bf', // Get this from RH Dashboard
'device': getDeviceType(), // Get device type
'ip_address': ipAddress , // Get IP address
'os_type': getOperatingSystem(), // Get operating system type
'screen_size': getDeviceScreenSize(), // Get screen size
'status': 'custom_event_pending' //Use 'custom_event_pending' to set the referral status to pending
};
Helper Functions
Get Device Type
You can use the react-native-device-info library to get the device type.
import DeviceInfo from 'react-native-device-info';
function getDeviceType() {
let deviceType = "Desktop";
if (Platform.OS === 'ios')
{ if (DeviceInfo.getModel().toLowerCase().includes("ipad")) {
deviceType = "iPad";
} else if (DeviceInfo.getModel().toLowerCase().includes("ipod")) {
deviceType = "iPod";
} else { deviceType = "iPhone"; }
} else if (Platform.OS === 'android') {
deviceType = "Android";
} else if (Platform.OS === 'windows') {
deviceType = "Windows Phone";
} else if (Platform.OS === 'blackberry') {
deviceType = "BlackBerry";
} else {
deviceType = "Unknown Device";
}
return deviceType;
}
Send the necessary mobile parameters and subscriber details. The API response will include a subscriber ID, which is required for authentication.
It is crucial to store the subscriber ID securely as it will be used for future authentication. Make sure that the API call is handled properly and errors are logged for debugging.
2. Set Authentication Cookies in the WebView
Before loading the widget, ensure the WebView injects the subscriber ID as a cookie. These cookies allow the widget to automatically recognize the user without requiring manual authentication.
This step helps in reducing friction for users, enabling a smoother experience without the need for repeated logins.
3. Embed the Widget Inside a WebView
The RH-hosted page, containing the widget, should be loaded within a WebView inside the React Native app. This ensures that the widget functions exactly as it does in a standard browser environment.
Additionally, ensure that WebView settings allow JavaScript execution and storage access, which is necessary for proper widget functionality.
4. Auto-Redirect to the Share Screen
Once the widget detects the authentication cookies, it will bypass the login screen and directly load the share screen. This creates a seamless user experience, similar to accessing the widget from a logged-in web browser.
To further enhance user experience, consider adding loading indicators while the WebView is initializing to inform users of ongoing processes.
This implementation ensures that the subscriber authentication process is seamless, automatically logging users into the referral widget inside the React Native WebView.
Get your API_TOKEN from the ReferralHero Dashboard -> API: .