Features
Identification
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.
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.
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:
Identify an anonymous user
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.
Identify an unverified user
The unverified identification method identifies users with a unique identifier, but it does not verify their identity with the DevRev backend.
Identify a verified user
The verified identification method is used to identify users with an identifier unique to your system within the DevRev platform. The verification is done through a token exchange process between you and the DevRev backend.
The steps to identify a verified user are as follows:
- Generate an AAT for your system (preferably through your backend).
- Exchange your AAT for a session token for each user of your system.
- Pass the user identifier and the exchanged session token to the
DevRev.identifyVerifiedUser(userID, sessionToken)
method.
For security reasons, it is strongly recommended that the token exchange is executed on your backend to prevent exposing your application access token (AAT).
Generate an AAT
- Open the DevRev web app at https://app.devrev.ai and go to the Settings page.
- Open the PLuG Tokens page.
- Under the Application access tokens panel, click New token and copy the token that’s displayed.
Ensure that you copy the generated application access token, as you cannot view it again.
Exchange your AAT for a session token
To proceed with identifying the user, you need to exchange your AAT for a session token. This step helps you identify a user of your own system within the DevRev platform.
Here is a simple example of an API request to the DevRev backend to exchange your AAT for a session token:
Make sure that you replace the <AAT>
and <YOUR_USER_ID>
with the actual values.
The response of the API call contains a session token that you can use with the verified identification method in your app.
As a good practice, your app should retrieve the exchanged session token from your backend at app launch or any relevant app lifecycle event.
Identify the verified user
Pass the user identifier and the exchanged session token to the verified identification method:
Update the user
You can update the user’s information using the following method:
The userID
property cannot be updated.
Use this property to check whether the user is identified in the current session:
Logout
You can perform a logout of the current user by calling the following method:
The user is logged out by clearing their credentials, as well as unregistering the device from receiving push notifications, and stopping the session recording.
For example:
Identity model
User identity information is passed as a Map<String, dynamic>
to the updateUser
method. The map can contain user, organization, and account information.
Properties
The identity map can contain the following properties:
The custom fields properties defined as part of the user, organization and account traits, must be configured in the DevRev web app before they can be used. See Object customization for more information.
User traits
The userTraits
map contains detailed information about the user:
All properties in userTraits
are optional.
Organization traits
The organizationTraits
map contains detailed information about the organization:
All properties in organizationTraits
are optional.
Account traits
The accountTraits
map contains detailed information about the account:
All properties in accountTraits
are optional.
PLuG support chat
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.
Create a new support conversation
You can initiate a new support conversation directly from your app. This method displays the support chat screen and simultaneously creates a new conversation.
In-app link handling
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:
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.
Dynamic theme configuration
The DevRev SDK allows you to configure the theme dynamically based on the system appearance, or use the theme configured on the DevRev portal. By default, the theme is dynamic and follows the system appearance.
Analytics
The DevRev SDK allows you to send custom analytic events by using a properties map. You can track these events using the following function:
For example:
Session analytics
The DevRev SDK offers session analytics features to help you understand how users interact with your app.
Opt in or out
Session analytics features are opted-in by default, enabling them from the start. However, you can opt-out using the following method:
To opt back in, use the following method:
Session recording
You can enable session recording to record user interactions with your app.
The session recording feature is opt-out and is enabled by default.
The session recording feature includes the following methods to control the recording:
Session properties
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.
To clear the session properties in scenarios such as user logout or when the session ends, use the following method:
Masking sensitive data
To protect sensitive data, you can mask sensitive UI elements such as text fields, text views, and web views using DevRevMask
widget, as shown below.
For example:
Unmasking sensitive data
You can also manually unmask UI elements that would otherwise be automatically masked using DevRevUnmask
:
For example:
Advanced session recording control while masking
For enhanced session recording and screen transition handling, you can use DevRevMonitoredApp
as a drop-in replacement for MaterialApp
. This widget automatically handles screen transition states and ensures proper masking during navigation.
DevRevMonitoredApp
is particularly useful when you want to avoid capturing snapshots during screen navigations, especially if any glitches occur. However, in most cases, this won’t be necessary, as most of masking scenarios are not affected by standard navigation. This is an optional solution for enhanced control over session recording behavior.
Timers
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:
To stop a timer, use the following method:
For example:
Track screens
The DevRev SDK offers automatic screen tracking to help you understand how users navigate through your app. Although screens are automatically tracked, you can manually track screens using the following method:
For example:
Manage screen transitions (Android only)
The DevRev SDK allows tracking of screen transitions to understand the user navigation within your app. You can manually update the state using the following methods:
Push notifications
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.
Configuration
To receive push notifications, you need to configure your DevRev organization by following the instructions in the push notifications section.
Register for push notifications
Push notifications require that the SDK has been configured and the user has been identified, to ensure delivery to the correct user.
The DevRev SDK offers a method to register your device for receiving push notifications. You can register for push notifications using the following method:
On Android devices, the deviceToken
should be the Firebase Cloud Messaging (FCM) token value, while on iOS devices, it should be the Apple Push Notification Service (APNs) token.
Unregister from push notifications
If your app no longer needs to receive push notifications, you can unregister the device.
Use the following method to unregister the device:
The method requires the device identifier, which should be the same as the one used when registering the device.
Handle push notifications
Android
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:
iOS
On iOS devices, you must pass the received push notification payload to the DevRev SDK for processing. The SDK handles the notification and executes the necessary actions.