DevRev SDK, used for integrating DevRev services into your Android app.
- DevRev SDK for Android
- Android Studio 2025.1.1 or later.
- Android Gradle Plugin 8.2 or later.
- Gradle 8.9 or later.
- Minimum Android API level 24.
- Recommended: An SSH key configured locally and registered with GitHub.
To integrate the latest version of our SDK into your app, follow these steps:
Our SDK is available on Maven Central. To access it, add mavenCentral
to your root level build.gradle
file.
repositories {
mavenCentral()
}
After completing these steps in your gradle files, you should be able to import and use the DevRev SDK in your Android application.
- Kotlin
Add the following dependencies to your app's
build.gradle.kts
file to get the latest version of our SDK:dependencies { implementation("ai.devrev.sdk:devrev-sdk:<VERSION>") }
- Groovy
Add the following dependencies to your app's
build.gradle
file to get the latest version of our SDK:dependencies { implementation 'ai.devrev.sdk:devrev-sdk:<VERSION>' }
If you are using ProGuard in your project, add the following lines to your configuration:
-keep class ai.devrev.** { *; }
-keep class com.userexperior.* { *; }
- 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.
Warning
The DevRev SDK must be configured before you can use any of its features.
The SDK becomes ready for use once the following configuration method is executed.
- Kotlin
DevRev.configure(context: Context, appId: String)
- Java
DevRev.INSTANCE.configure(Context context, String appId);
Ensure that the custom application is specified in the AndroidManifest.xml
file:
<application
android:name=".MyApp">
</application>
Use this property to check whether the DevRev SDK has been configured:
- Kotlin
DevRev.isConfigured
- Java
DevRev.INSTANCE.isConfigured();
Tip
The property prefersDialogMode
, when set to true
, enables the SDK to open the screens in the app's main task/activity.
- Call the following method inside your
Application
class to configure the SDK:
Tip
If you don't have a custom Application
class, create one as shown below.
- Kotlin
import ai.devrev.sdk.DevRev class FooApplication : Application() { override fun onCreate() { super.onCreate() DevRev.configure( context = this, appId = "<APP_ID>" ) } }
- Java
import ai.devrev.sdk.DevRev; public class FooApplication extends Application { @Override public void onCreate() { super.onCreate(); DevRev.INSTANCE.configure( this, "<APP_ID>" ); } }
- In the
onCreate
method of yourApplication
, configure the DevRev SDK with the required parameters using the credentials obtained earlier. - Ensure that the custom application is specified in the
AndroidManifest.xml
, as shown below:<application android:name=".FooApplication"> </application>
We provide a sample app demonstrating use cases with both XML-based UI and Jetpack Compose as part our public repository.
Before running the sample app, make sure to configure it with your DevRev credentials. To do this, update the ai.devrev.sdk.sample.DevRevApplication
class with your credentials.
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(context, appID)
method.
Tip
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 utilized. For more information, refer to Object customization.
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.
- Kotlin
DevRev.identifyAnonymousUser( userId: String )
- Java
DevRev.INSTANCE.identifyAnonymousUser( String userId );
The unverified identification method identifies users with a unique identifier, but it does not verify their identity with the DevRev backend.
- Kotlin
DevRev.identifyUnverifiedUser( identity: Identity )
- Java
DevRev.INSTANCE.identifyUnverifiedUser( Identity identity );
The function accepts the DevRev.Identity
structure, with the user identifier (userID
) as the only required property, all other properties are optional.
For example:
- Kotlin
// Identify an unverified user using their email address as the user identifier. DevRev.identifyUnverifiedUser(Identity(userId = "user@example.org"))
- Java
// Identify an unverified user using their email address as the user identifier. DevRev.identifyUnverifiedUser( new Identity("user@example.org", null, null, null, null, null) );
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(_:sessionToken:)
method.
Warning
For security reasons, it is strongly recommended that the token exchange is executed on your backend to prevent exposing your application access token (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.
Warning
Ensure that you copy the generated application access token, as you cannot view it again.
In order to proceed with identifying the user, you need to exchange your AAT for a session token. This step will help 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:
Warning
Make sure that you replace the <AAT>
and <YOUR_USER_ID>
with the actual values.
curl \
--location 'https://api.devrev.ai/auth-tokens.create' \
--header 'accept: application/json, text/plain, */*' \
--header 'content-type: application/json' \
--header 'authorization: <AAT>' \
--data '{
"rev_info": {
"user_ref": "<YOUR_USER_ID>"
}
}'
The response of the API call contains a session token that you can use with the verified identification method in your app.
Warning
As a good practice, your app should retrieve the exchanged session token from your backend at app launch or any relevant app lifecycle event.
Pass the user identifier and the exchanged session token to the verified identification method:
DevRev.identifyVerifiedUser(userId: String, sessionToken: String)
DevRev.INSTANCE.identifyVerifiedUser(String userId, String sessionToken);
For example:
- Kotlin
// Identify an anonymous user without a user identifier. DevRev.identifyAnonymousUser("abcd1234") // Identify an unverified user with its email address as a user identifier. DevRev.identifyUnverifiedUser(Identity(userId = "foo@example.org")) // Identify a verified user with its user identifier and session token. DevRev.identifyVerifiedUser("foo@example.org", "session-token-1234")
- Java
// Identify an anonymous user without a user identifier. DevRev.INSTANCE.identifyAnonymousUser("abcd1234"); // Identify an unverified user with its email address as a user identifier. DevRev.identifyUnverifiedUser( new Identity("foo@example.org", null, null, null, null, null) ); // Identify a verified user with its user identifier and session token. DevRev.INSTANCE.identifyVerifiedUser("foo@example.org", "session-token-1234");
The identification function should be placed at the appropriate place in your app after you log in your user. If you have the user information at app launch, call the function after the DevRev.configure(context, appID)
method.
Use this property to check whether the user has been provided to the SDK:
- Kotlin
DevRev.isUserIdentified
- Java
DevRev.INSTANCE.isUserIdentified();
To update a user's information, use the following method:
- Kotlin
DevRev.updateUser( identity: Identity )
- Java
DevRev.INSTANCE.updateUser( Identity identity );
The function accepts the DevRev.Identity
ojbect.
Warning
The userID
property cannot be updated.
You can perform a logout of the current user by calling the following method:
- Kotlin
DevRev.logout(context: Context, deviceId: String)
- Java
DevRev.logout(context: Context, deviceId: String)
The user is logged out by clearing their credentials, as well as unregistering the device from receiving push notifications, and stopping the session recording.
The Identity
class is used to provide user, organization, and account information when identifying users or updating their details. This class is used primarily with the identifyUnverifiedUser(_:)
and updateUser(_:)
methods.
The Identity
class contains the following properties:
Property | Type | Required | Description |
---|---|---|---|
userID |
String |
âś… | A unique identifier for the user |
organizationID |
String? |
❌ | An identifier for the user's organization |
accountID |
String? |
❌ | An identifier for the user's account |
userTraits |
UserTraits? |
❌ | Additional information about the user |
organizationTraits |
OrganizationTraits? |
❌ | Additional information about the organization |
accountTraits |
AccountTraits? |
❌ | Additional information about the account |
Note
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.
The UserTraits
class contains detailed information about the user:
Note
All properties in UserTraits
are optional.
Property | Type | Description |
---|---|---|
displayName |
String? |
The displayed name of the user |
email |
String? |
The user's email address |
fullName |
String? |
The user's full name |
userDescription |
String? |
A description of the user |
phoneNumbers |
[String]? |
Array of the user's phone numbers |
customFields |
[String: Any]? |
Dictionary of custom fields configured in DevRev |
The OrganizationTraits
class contains detailed information about the organization:
Note
All properties in OrganizationTraits
are optional.
Property | Type | Description |
---|---|---|
displayName |
String? |
The displayed name of the organization |
domain |
String? |
The organization's domain |
organizationDescription |
String? |
A description of the organization |
phoneNumbers |
[String]? |
Array of the organization's phone numbers |
tier |
String? |
The organization's tier or plan level |
customFields |
[String: Any]? |
Dictionary of custom fields configured in DevRev |
The AccountTraits
class contains detailed information about the account:
Note
All properties in AccountTraits
are optional.
Property | Type | Description |
---|---|---|
displayName |
String? |
The displayed name of the account |
domains |
[String]? |
Array of domains associated with the account |
accountDescription |
String? |
A description of the account |
phoneNumbers |
[String]? |
Array of the account's phone numbers |
websites |
[String]? |
Array of websites associated with the account |
tier |
String? |
The account's tier or plan level |
customFields |
[String: Any]? |
Dictionary of custom fields configured in DevRev |
Once user identification is complete, you can start using the chat (conversations) dialog supported by our DevRev SDK. To open the chat dialog, your application should use the showSupport
API, as shown in the following example:
- Kotlin
DevRev.showSupport(context: Context)
- Java
DevRevExtKt.showSupport(DevRev.INSTANCE, context);
You have the ability to create a new conversation from within your app. The method will show the support chat screen and create a new conversation at the same time.
- Kotlin
DevRev.createSupportConversation(context: Context)
- Java
DevRev.INSTANCE.createSupportConversation(context);
The DevRev SDK also provides a support button, which can be integrated into your application. To include it on the current screen, add the following code to your XML layout:
<ai.devrev.sdk.plug.view.PlugFloatingActionButton
android:id="@+id/plug_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
The support button can be customized using default parameters, enabling you to tailor its appearance to your application's design:
android:src="@your_drawable_here"
android:backgroundTint="@your_background_color"
The DevRev SDK provides a mechanism to handle links opened from within any screen that is part of the DevRev SDK.
You can fully customize the link handling behavior by setting the specialized in-app link handler. That way you can decide what should happen when a link is opened from within the app.
- Kotlin
DevRev.setInAppLinkHandler(handler: (String) -> Unit)
- Java
DevRev.INSTANCE.setInAppLinkHandler(Function1<String, Unit> handler)
You can further customize the behavior by setting the setShouldDismissModalsOnOpenLink
boolean flag. This flag controls whether the DevRev SDK should dismiss the top-most modal screen when a link is opened.
- Kotlin
DevRev.setShouldDismissModalsOnOpenLink(value: boolean)
- Java
DevRev.INSTANCE.setShouldDismissModalsOnOpenLink(boolean value)
For example:
- Kotlin
DevRev.setInAppLinkHandler { link -> // Do something here } DevRev.setShouldDismissModalsOnOpenLink(false)
- Java
DevRev.INSTANCE.setInAppLinkHandler(link -> { // Do something here return kotlin.Unit.INSTANCE; }); DevRev.INSTANCE.setShouldDismissModalsOnOpenLink(false);
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.
- Kotlin
DevRev.setShouldPreferSystemTheme(value: Boolean)
- Java
DevRev.INSTANCE.setShouldPreferSystemTheme(boolean value);
The DevRev SDK allows you to send custom analytic events by using a name and a string dictionary. You can track these events using the following function:
- Kotlin
DevRev.trackEvent( name: String, properties: HashMap<String, String> )
- Java
DevRevAnalyticsExtKt.trackEvent( DevRev instance, String name, HashMap<String, String> properties );
For example:
- Kotlin
DevRev.trackEvent( name = "open-message-screen", properties = mapOf("id" to "foo-bar-1337") )
- Java
DevRevAnalyticsExtKt.trackEvent( DevRev.INSTANCE, "open-message-screen", new HashMap<>().put("id", "foo-bar-1337") );
The DevRev SDK provides observability features to help you understand how your users are interacting 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:
- Kotlin
DevRev.stopAllMonitoring()
- Java
DevRevObservabilityExtKt.stopAllMonitoring(DevRev.INSTANCE);
To opt back in, use the following method:
- Kotlin
DevRev.resumeAllMonitoring()
- Java
DevRevObservabilityExtKt.resumeAllMonitoring(DevRev.INSTANCE);
You can check whether session monitoring has been enabled by using this property:
- Kotlin
DevRev.isMonitoringEnabled
- Java
DevRevObservabilityExtKt.isMonitoringEnabled(DevRev.INSTANCE);
If the user was disabled for session recording by using the stopAllMonitoring()
method, you can use this method to enable recording at runtime.
Note
This feature will only store a monitoring permission flag, it will not provide any UI or dialog.
You can enable session recording to capture user interactions with your app.
Caution
The session recording feature is opt-out and is enabled by default.
Here are the available methods to help you control the session recording feature:
-
Kotlin
Method Action DevRev.startRecording()
Starts the session recording. DevRev.stopRecording()
Ends the session recording and uploads it to the portal. DevRev.pauseRecording()
Pauses the ongoing session recording. DevRev.resumeRecording()
Resumes a paused session recording. DevRev.processAllOnDemandSessions()
Stops the ongoing user recording and sends all on-demand sessions along with the current recording. -
Java
Method Action DevRevObservabilityExtKt.startRecording(DevRev.INSTANCE, context)
Starts the session recording. DevRevObservabilityExtKt.stopRecording(DevRev.INSTANCE)
Ends the session recording and uploads it to the portal. DevRevObservabilityExtKt.pauseRecording(DevRev.INSTANCE)
Pauses the ongoing session recording. DevRevObservabilityExtKt.resumeRecording(DevRev.INSTANCE)
Resumes a paused session recording. DevRevObservabilityExtKt.processAllOnDemandSessions(DevRev.INSTANCE)
Stops the ongoing user recording and sends all on-demand sessions along with the current recording.
Using this property returns the status of the session recording:
- Kotlin
DevRev.isRecording
- Java
DevRevObservabilityExtKt.isRecording(DevRev.INSTANCE);
To check if on-demand sessions are enabled, use:
- Kotlin
DevRev.areOnDemandSessionsEnabled
- Java
DevRevObservabilityExtKt.areOnDemandSessionsEnabled(DevRev.INSTANCE);
You can add custom properties to the session recording to help you understand the context of the session. The properties are defined as a dictionary of string values.
- Kotlin
DevRev.addSessionProperties(properties: HashMap<String, String>)
- Java
DevRevObservabilityExtKt.addSessionProperties(DevRev.INSTANCE, HashMap<String, String> properties);
To clear the session properties in scenarios such as user logout or when the session ends, use the following method:
- Kotlin
DevRev.clearSessionProperties()
- Java
DevRevObservabilityExtKt.clearSessionProperties(DevRev.INSTANCE);
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 feature may be sufficient for most situations, you can manually mark/unmark additional views as sensitive.
The SDK provides two approaches to manually mask or unmask your views, using a set of predefined tags or using the API methods.
Use the tag method only when you don't have any other tag already applied to your UI element.Masking views using the predefined tags is the simplest way to mask your views, use the tag devrev-mask
to mask a view and devrev-unmask
to unmask a view.
-
Mark a view as masked:
android:tag="devrev-mask"
-
Mark a view as unmasked:
android:tag="devrev-unmask"
For example:
<!-- A masked web view -->
<WebView
android:id="@+id/webview2"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:background="@android:color/transparent"
android:tag="devrev-mask"/>
<!-- An unmasked web view -->
<WebView
android:id="@+id/webview3"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:background="@android:color/transparent"
android:tag="devrev-unmask"/>
The tags can also be set programmatically:
-
Kotlin
- Mark a view as masked:
val firstView: View = findViewById(R.id.firstView) firstView.tag = "devrev-mask"
- Mark a view as unmasked: ```kotlin val secondView: View = findViewById(R.id.secondView) secondView.tag = "devrev-unmask"
- Mark a view as masked:
-
Java
- Mark a view as masked:
View firstView = findViewById(R.id.firstView); firstView.setTag("devrev-mask");
- Mark a view as unmasked:
View secondView = findViewById(R.id.secondView); secondView.setTag("devrev-unmask");
- Mark a view as masked:
You can also use the API methods to mask or unmask your views programmatically.
-
Kotlin
- Mark a view as masked:
DevRev.markSensitiveViews(sensitiveViews: List<View>)
- Mark a view as unmasked:
DevRev.unmarkSensitiveViews(sensitiveViews: List<View>)
- Mark a view as masked:
-
Java
- Mark a view as masked:
DevRevObservabilityExtKt.markSensitiveViews(DevRev.INSTANCE, List<View> sensitiveViews);
- Mark a view as unmasked:
DevRevObservabilityExtKt.unmarkSensitiveViews(DevRev.INSTANCE, List<View> sensitiveViews);
- Mark a view as masked:
For example:
- Kotlin
// Mark two views as masked. val view1 = findViewById(R.id.view1) val view2 = findViewById(R.id.view2) DevRev.markSensitiveViews(listOf(view1, view2)) // Mark two views as unmasked. val view3 = findViewById(R.id.view3) val view4 = findViewById(R.id.view4) DevRev.unmarkSensitiveViews(listOf(view3, view4))
- Java
// Mark two views as masked. View view1 = findViewById(R.id.view1); View view2 = findViewById(R.id.view2); List<View> sensitiveViewsList = new ArrayList<>(); sensitiveViewsList.add(view1); sensitiveViewsList.add(view2); DevRevObservabilityExtKt.markSensitiveViews(DevRev.INSTANCE, sensitiveViewsList); // Mark two views as unmasked. View view3 = findViewById(R.id.view3); View view4 = findViewById(R.id.view4); List<View> sensitiveViewsList = new ArrayList<>(); sensitiveViewsList.add(view3); sensitiveViewsList.add(view4); DevRevObservabilityExtKt.unmarkSensitiveViews(DevRev.INSTANCE, sensitiveViewsList);
If you want to mask any Jetpack Compose UI elements or views, you can apply a mask on it using a modifier.
modifier = Modifier.markAsMaskedLocation("VIEW_NAME_OR_ID")
For example:
TextField(
modifier = Modifier
.markAsMaskedLocation("myTextField")
.padding(horizontal = 20.dp)
.onGloballyPositioned { coordinates = it },
value = input,
onValueChange = { input = it }
)
If you wish to explicitly mask any WebView
element on a web page, you can do so by using the class devrev-mask
.
For example:
<label class="devrev-mask">OTP: 12345</label>
If you wish to explicitly unmask any manually masked WebView
element, you can do so by using the class devrev-unmask
.
For example:
<input type="text" placeholder="Enter Username" name="username" required class="devrev-unmask">
For advanced use cases, you can provide a custom masking provider to explicitly specify which regions of the UI should be masked during snapshots.
You can implement your own masking logic by creating a class that implements the MaskLocationProvider
interface and setting your custom object as the masking provider. This allows you to specify explicit regions to be masked or to skip snapshots entirely.
Symbol | Description |
---|---|
DevRev.setMaskLocationProvider(maskLocationProvider: MaskLocationProvider) |
A custom provider that determines which UI regions should be masked for privacy during snapshots (this overrides any previously set provider). |
MaskLocationProvider |
An interface for providing explicit masking locations for UI snapshots. |
SnapshotMask |
An object that describes the regions of a snapshot to be masked. |
For example:
- Kotlin
import com.userexperior.bridge.model.MaskLocationProvider
import com.userexperior.bridge.model.SnapshotMask
import ai.devrev.sdk.setMaskLocationProvider
import ai.devrev.sdk.DevRev
import android.graphics.Rect
class MyMaskingProvider : MaskLocationProvider {
init {
// Register the custom masking provider
DevRev.setMaskLocationProvider(this)
}
override fun provideSnapshotMask(): SnapshotMask {
// Create a MutableSet to hold the masked regions
val locations: MutableSet<Rect> = mutableSetOf()
// Define the regions to be masked
val rect1 = Rect(0, 0, 100, 50)
val rect2 = Rect(50, 50, 150, 100)
// Add the regions to the Set
locations.add(rect1)
locations.add(rect2)
return SnapshotMask(
locations,
false
)
}
}
- Java
import com.userexperior.bridge.model.MaskLocationProvider;
import com.userexperior.bridge.model.SnapshotMask;
import ai.devrev.sdk.DevRevObservabilityExtKt;
import ai.devrev.sdk.DevRev;
import android.graphics.Rect;
import java.util.HashSet;
import java.util.Set;
public class MyMaskingProvider implements MaskLocationProvider {
public MyMaskingProvider() {
// Register the custom masking provider
DevRevObservabilityExtKt.setMaskLocationProvider(DevRev.INSTANCE, this);
}
@Override
public SnapshotMask provideSnapshotMask() {
// Create a Set to hold the masked regions
Set<Rect> locations = new HashSet<>();
// Define the regions to be masked
Rect rect1 = new Rect(0, 0, 100, 100);
Rect rect2 = new Rect(50, 50, 150, 150);
// Add the regions to the Set
locations.add(rect1);
locations.add(rect2);
return new SnapshotMask(
locations,
false
);
}
}
Note
Setting a new provider will override any previously set masking location provider.
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 works using balanced start and stop methods that both accept a timer name and an optional dictionary of properties.
To start a timer, use the following method:
- Kotlin
DevRev.startTimer(name: String, properties: HashMap<String, String>)
- Java
DevRevObservabilityExtKt.startTimer(DevRev.INSTANCE, String name, HashMap<String, String> properties);
To stop a timer, use the following method:
- Kotlin
DevRev.endTimer(name: String, properties: HashMap<String, String>)
- Java
DevRevObservabilityExtKt.endTimer(DevRev.INSTANCE, String name, HashMap<String, String> properties);
For example:
- Kotlin
DevRev.startTimer("response-time", properties: {"id": "task-1337"})
// Perform the task that you want to measure.
DevRev.endTimer("response-time", properties: {"id": "task-1337"})
- Java
DevRevObservabilityExtKt.startTimer(DevRev.INSTANCE, "response-time", new HashMap<String, String>().put("id", "task-1337"));
// Perform the task that you want to measure.
DevRevObservabilityExtKt.endTimer(DevRev.INSTANCE, "response-time", new HashMap<String, String>().put("id", "task-1337"));
The DevRev SDK offers automatic screen tracking to help you understand how users navigate through your app. Although activities and fragments are automatically tracked, you can manually track screens using the following method:
- Kotlin
DevRev.trackScreenName(screenName: String)
- Java
DevRevObservabilityExtKt.trackScreenName(DevRev.INSTANCE, String screenName);
For example:
- Kotlin
DevRev.trackScreenName("profile-screen")
- Java
DevRevObservabilityExtKt.trackScreenName(DevRev.INSTANCE, "profile-screen");
The DevRev SDK allows tracking of screen transitions to understand the user navigation within your app. You can check if a screen transition is in progress and manually update the state using the following methods:
- Kotlin
val isTransitioning = DevRev.isInScreenTransitioning
- Java
boolean isTransitioning = DevRevObservabilityExtKt.isInScreenTransitioning(DevRev.INSTANCE);
- Kotlin
// Mark the transition as started.
DevRev.setInScreenTransitioning(true)
// Mark the transition as ended.
DevRev.setInScreenTransitioning(false)
- Java
// Mark the transition as started.
DevRevObservabilityExtKt.setInScreenTransitioning(DevRev.INSTANCE, true)
// Mark the transition as ended.
DevRevObservabilityExtKt.setInScreenTransitioning(DevRev.INSTANCE, false)
You can configure your app to receive push notifications from the DevRev SDK. The SDK is designed 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.
You need to ensure that your Android app is configured to receive push notifications. To set it up, follow the Firebase documentation.
Tip
Push notifications require that the SDK has been configured and the user has been identified (unverified and anonymous users). The user identification is required to send the push notification 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:
- Kotlin
DevRev.registerDeviceToken(
context: Context,
deviceToken: String,
deviceId: String
)
- Java
DevRev.INSTANCE.registerDeviceToken(
Context context,
String deviceToken,
String deviceId
);
The method requires a device identifier that persists across device restarts and app launches. This could be a Firebase installation ID, Android ID, or a unique system identifier. To obtain the device token for Firebase Cloud Messaging, follow these steps:
- Use the
FirebaseMessaging
object. - Call the
firebaseMessaging.token.await()
method.
This method will generate and return the device token.
val firebaseMessaging = FirebaseMessaging.getInstance()
val token = firebaseMessaging.token.await()
// Use the token as needed
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.
- Kotlin
DevRev.unregisterDevice(
context: Context,
deviceId: String
)
- Java
DevRev.INSTANCE.unregisterDevice(
Context context,
String deviceId
);
The DevRev SDK currently does not support automatic handling of push notifications. To open the PLuG chat and manage navigation internally, you must pass the message payload received in the notification to the SDK.
- Kotlin
DevRev.processPushNotification(
context: Context,
userInfo: String
)
- Java
DevRev.INSTANCE.processPushNotification(
Context context,
String userInfo
);
To extract the notification payload, do the following:
- In Firebase Cloud Messaging (FCM), when a push notification is received, it triggers the
onMessageReceived
function in yourFirebaseMessagingService
class. - This function receives a
RemoteMessage
object as a parameter, which contains the notification data. - The
RemoteMessage
object has adata
property, which is a map containing key-value pairs of the notification payload. - To extract a specific piece of data from the payload, use the key to access the value in the data map.
- To retrieve the "message" from the payload:
- Kotlin
val message = remoteMessage.data["message"]
- Java
String messageData = remoteMessage.getData().get("message");
For example:
- Kotlin
class MyFirebaseMessagingService: FirebaseMessagingService {
// ...
override fun onMessageReceived(remoteMessage: RemoteMessage) {
// ...
val messageData = remoteMessage.data["message"]
DevRev.processPushNotification(messageData)
}
}
- Java
public class MyFirebaseMessagingService extends FirebaseMessagingService {
// ...
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// ...
String messageData = remoteMessage.getData().get("message");
DevRev.processPushNotification(messageData);
}
}
-
Issue: Can't import the SDK into my app. Solution: Double-check the setup process and ensure that
mavenCentral()
is present in the project-level repositories block. -
Issue: How does the DevRev SDK handle errors? Solution: The DevRev SDK reports all errors using Android's logging utility. Look for error messages in Android Studio's Logcat after applying
DEVREV SDK
filter. -
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.
-
Issue: Missing class
com.google.android.play.core.splitcompat.SplitCompatApplication
. Solution: Add the following line to yourproguard-rules.pro
file:-dontwarn com.google.android.play.core.**
. -
Issue: Missing class issue due to transitive Flutter dependencies. Solution: Add the following lines to your
proguard-rules.pro
file:-keep class io.flutter.** { *; } -keep class io.flutter.plugins.** { *; } -keep class GeneratedPluginRegistrant { *; }
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.