DevRev SDK, used for integrating DevRev services into your Cordova app.
- DevRev SDK for Cordova
To install the DevRev SDK, run the following command:
cordova plugin add devrev-cordova-plugin
- Open the DevRev web app at https://app.devrev.ai and go to the Settings page.
- Under PLuG settings copy the value under Your unique App ID.
- After obtaining the credentials, you can configure the DevRev SDK in your app.
The SDK will be ready for use once you execute the following configuration method.
DevRev.configure(appID, successCallback, errorCallback)
To access certain features of the DevRev SDK, user identification is required.
The identification function should be placed appropriately in your app after the user logs in. If you have the user information available at app launch, call the function after the DevRev.configure(appID:)
method.
[!IMPORTANT] On iOS, if you haven't previously identified the user, the DevRev SDK will automatically create an anonymous user for you immediately after the SDK is configured.
[!IMPORTANT] The
Identity
structure allows for custom fields in the user, organization, and account traits. These fields must be configured through the DevRev app before they can be used. For more information, refer to Object customization.
You can select from the following methods to identify users within your application:
The anonymous identification method allows you to create an anonymous user with an optional user identifier, ensuring that no other data is stored or associated with the user.
DevRev.identifyAnonymousUser(successCallback, errorCallback)
The unverified identification method identifies users with a unique identifier, but it does not verify their identity with the DevRev backend.
DevRev.identifyUnverifiedUser(identity, successCallback, errorCallback)
The verified identification method identifies users with a unique identifier and verifies their identity with the DevRev backend.
DevRev.identifyVerifiedUser(identity, successCallback, errorCallback)
You can update the user's information using the following method:
DevRev.updateUser(identity, successCallback, errorCallback)
[!IMPORTANT] The
userID
property cannot be updated.
You can logout of the current user by using the following method:
DevRev.logout(deviceID, successCallback, errorCallback)
The user will be logged out by clearing their credentials, as well as unregistering the device from receiving push notifications, and stopping the session recording.
Once user identification is complete, you can start using the chat (conversations) dialog supported by our DevRev SDK. The support chat feature can be shown as a modal screen from the top-most screen.
[!IMPORTANT] This feature requires the SDK to be configured and the user to be identified, whether they are unverified or anonymous.
DevRev.showSupport(successCallback, errorCallback)
You can initiate a new support conversation directly from your app. This method displays the support chat screen and simultaneously creates a new conversation.
DevRev.createSupportConversation(isAnimated, successCallback, errorCallback)
In certain cases, tapping links in the support chat opens them in the app instead of a browser. You can control whether the chat modal screen is dismissed after the link is opened by calling the following method:
DevRevSDK.setShouldDismissModalsOnOpenLink(value, successCallback, errorCallback)
Setting this flag to true applies the system's default behavior for opening links, which includes dismissing any DevRev modal screens to facilitate handling your own deep links.
[!NOTE] This feature is for Android only.
For scenarios where custom handling is needed, links from the support chat can be captured with the following method:
DevRevSDK.setInAppLinkHandler(handler, successCallback, errorCallback)
[!IMPORTANT] This feature requires the SDK to be configured and the user to be identified, whether they are unverified or anonymous.
The DevRev SDK allows you to send custom analytic events by using a properties map. You can track these events using the following function:
DevRev.trackEvent(name, properties, successCallback, errorCallback)
The DevRev SDK offers session analytics features to help you understand how users interact with your app.
Session analytics features are opted-in by default, enabling them from the start. However, you can opt-out using the following method:
DevRev.stopAllMonitoring(successCallback, errorCallback)
To opt back in, use the following method:
DevRev.resumeAllMonitoring(successCallback, errorCallback)
You can enable session recording to record user interactions with your app.
[!CAUTION] The session recording feature is opt-out and is enabled by default.
The session recording feature includes the following methods to control the recording:
-
DevRev.startRecording(successCallback, errorCallback)
: Starts the session recording. -
DevRev.stopRecording(successCallback, errorCallback)
: Stops the session recording and upload it to the portal. -
DevRev.pauseRecording(successCallback, errorCallback)
: Pauses the ongoing session recording. -
DevRev.resumeRecording(successCallback, errorCallback)
: Resumes a paused session recording. -
DevRev.processAllOnDemandSessions(successCallback, errorCallback)
: Stops the ongoing session recording and upload all offline sessions on demand, including the current one.
You can add custom properties to the session recording to help you understand the context of the session. The properties are defined as a map of string values.
DevRev.addSessionProperties(properties, successCallback, errorCallback)
To clear the session properties in scenarios such as user logout or when the session ends, use the following method:
DevRev.clearSessionProperties(successCallback, errorCallback)
To protect sensitive data, the DevRev SDK provides an auto-masking feature that masks data before sending to the server. Input views such as text fields, text views, and web views are automatically masked.
While the auto-masking mechanism might be sufficient for most cases, to explicitly mask any WebView element on a webpage, use the CSS class devrev-mask
. This ensures that sensitive elements, such as confidential text, remain hidden.
<label class="ue-mask">Foo: Bar</label>
If any previously masked views need to be unmasked, you can use the following method:
<input type="text" placeholder="Enter Foo" name="foo" required class="ue-unmask">
The DevRev SDK offers a timer mechanism to measure the time spent on specific tasks, allowing you to track events such as response time, loading time, or any other duration-based metrics.
The mechanism uses balanced start and stop methods, both of which accept a timer name and an optional dictionary of properties.
To start a timer, use the following method:
DevRev.startTimer(name, properties, successCallback, errorCallback)
To stop a timer, use the following method:
DevRev.endTimer(name, properties, successCallback, errorCallback)
The DevRev SDK offers automatic screen tracking to help you understand how users navigate through your app. Although view controllers are automatically tracked, you can manually track screens using the following method:
DevRev.trackScreenName(screenName, successCallback, errorCallback)
You can configure your app to receive push notifications from the DevRev SDK. The SDK is able to handle push notifications and execute actions based on the notification's content.
The DevRev backend sends push notifications to your app to notify users about new messages in the PLuG support chat.
To receive push notifications, you need to configure your DevRev organization by following the instructions in the push notifications section.
[!IMPORTANT] To ensure delivery to the correct user, push notifications require that the SDK has been configured and the user has been identified.
The DevRev SDK offers a method to register your device for receiving push notifications. You can register for push notifications using the following method:
DevRev.registerDeviceToken(deviceToken, deviceID, successCallback, errorCallback)
On Android devices, the deviceToken
must be the Firebase Cloud Messaging (FCM) token value. On iOS devices, it must be the Apple Push Notification Service (APNs) token.
If your app no longer needs to receive push notifications, you can unregister the device.
Use the following method to unregister the device:
DevRev.unregisterDevice(deviceID, successCallback, errorCallback)
The method requires the device identifier, which should be the same as the one used when registering the device.
On Android, notifications are implemented as data messages to offer flexibility. However, this means that automatic click processing isn't available. To handle notification clicks, developers need to intercept the click event, extract the payload, and pass it to a designated method for processing. This custom approach enables tailored notification handling in Android applications.
To process the notification, use the following method:
DevRev.processPushNotification(payload, successCallback, errorCallback)
Here, the message
object from the notification payload needs to be passed to this function.
const notificationPayload = {
"message": {
"title": "New Message",
"body": "You have received a new message.",
"data": {
"messageId": "12345",
"sender": "John Doe"
}
}
};
const messageJson = notificationPayload["message"];
DevRev.processPushNotification(messageJson, function() {
console.log("Push notification processed successfully.");
}, function(error) {
console.error("Failed to process push notification:", error);
});
On iOS devices, you must pass the received push notification payload to the DevRev SDK for processing. The SDK will then handle the notification and execute the necessary actions.
DevRev.processPushNotification(payload, successCallback, errorCallback)
const notificationPayload = {
"message": {
"title": "New Message",
"body": "You have received a new message.",
"data": {
"messageId": "12345",
"sender": "John Doe"
}
}
};
const messageJson = notificationPayload["message"];
DevRev.processPushNotification(messageJson, function() {
console.log("Push notification processed successfully.");
}, function(error) {
console.error("Failed to process push notification:", error);
});
-
Issue: Support chat won't show. Solution: Ensure you have correctly called one of the identification methods:
DevRev.identifyUnverifiedUser(...)
,DevRev.identifyVerifiedUser(...)
, orDevRev.identifyAnonymousUser(...)
. -
Issue: Not receiving push notifications. Solution: Ensure that your app is configured to receive push notifications and that your device is registered with the DevRev SDK.
If you are migrating from the legacy UserExperior SDK to the new DevRev SDK, please refer to the Migration Guide for detailed instructions and feature equivalence.