Singular React Native SDK | |
---|---|
Download |
Singular React Native SDK version 3.3.0(see Change Log) |
Compatibility | React Native 0.46.4+ |
Integration Guides |
[NEW] Creating Short Referrer Links
Note: This functionality is available in SDK version 3.1.8+.
Use short links to transform long, parameter-filled Singular Links into shorter and more secure links that are convenient for sharing.
Typically, you will want to create short links dynamically so that your app's users can share them with friends to invite them to use the app.
To create a short link, you need:
- A Singular Link that leads to your app download (see the Singular Links FAQ).
- Any parameters you want to add to the link dynamically (see Tracking Link Parameters for the list of options).
- The name and ID of the referring user, if you want to be able to track new app installs back to the user who shared the link.
Use the createReferrerShortLink method to create a short link as in the example below.
Singular.createReferrerShortLink (
"https://sample.sng.link/B4tbm/v8fp?_dl=https%3A%2F%2Fabc.com",
"John Doe", // Referrer Name
"aq239897", // Referrer ID
{"channel": "sms"}, // Any parameters you want to add to the link
(shortLinkURL,error) => {
// Add your share logic here if shortLinkURL is not null
// If there was an error, add logic to retry/abort/modify the params
// passed to the function, based on the cause of the error
}
)
Tracking Uninstalls
To let Singular track uninstalls for your app:
- First, configure the app in the Singular platform, as detailed in Setting Up Uninstall Tracking.
- Use your preferred method to retrieve the APNS/FCM tokens in React Native.
- Call the setUninstallToken method, passing the APNS/FCM token to as in the example below. Be sure to pass the right token based on the device platform.
Singular.setUninstallToken Method | |
---|---|
Description | Send Singular the APNS/FCM token in order to let it track app uninstalls. |
Usage Example |
|
Modifying the Session Timeout
The Singular SDK manages user sessions automatically, so you don't need to add any code to handle sessions. However, you can modify the session timeout value if you want.
By default, if the app runs in the background for 60 seconds or more before returning to the foreground, the SDK registers a new session.
To change the timeout value, use .withSessionTimeoutInSec when you create the SingularConfig object. For example:
const config = new SingularConfig('<SDK KEY>', '<SDK SECRET>')
.withSessionTimeoutInSec(120); // Set timeout to 120 seconds
Singular.init(config);
Complying with Data Privacy Laws
Singular provides privacy-safeguarding functionality to help you cooperate with any partners who may be complying with consumer privacy laws such as GDPR and CCPA (California Consumer Privacy Act). These partners want to be notified if the end-user has consented to share their private information.
If you have implemented a way to ask users for consent to share their information, use the limitDataSharing method to notify Singular of the user's choice:
- Use Singular.limitDataSharing(false) to indicate that the user consented (opted in) to share their information.
- Use Singular.limitDataSharing(true) if the user did not consent.
Singular will pass this information on to partners who require it in order to comply with relevant regulations.
Note: The use of the method is optional, but there may be attribution information that the partner will share with Singular only if specifically notified that the user has opted in.
Singular.limitDataSharing Method | |
---|---|
Signature | Singular.limitDataSharing(shouldLimitDataSharing) |
Description | Notify Singular of user consent (opt-in) for sharing private data. |
Usage Example |
|
Additional Methods for GDPR Compliance
The Singular SDK provides several methods to help you comply with GDPR policies and let Singular know about user consent or non-consent for tracking.
Singular.trackingOptIn Method | |
---|---|
Description | Let Singular know of user consent (opt-in) for tracking. |
Usage Example |
|
Singular.stopAllTracking Method | |
Description |
Stop all tracking activities for this user on this app. Important: This effectively disables the Singular SDK, even after you restart the app. The only way to re-enable the SDK is by calling resumeAllTracking. |
Usage Example |
|
Singular.resumeAllTracking Method | |
Description | Resume tracking activities for this user on this app. |
Usage Example |
|
Singular.isAllTrackingStopped Method | |
Description | Check the tracking status for this user on this app. Returns true if tracking has been stopped. |
Usage Example |
|