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.
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 utilized. For more information, refer to Object customization.
You can select from the following methods to identify users within your application:
Anonymous identification
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.
Unverified identification
The unverified identification method identifies users with a unique identifier, but it does not verify their identity with the DevRev backend.
The function accepts the DevRev.Identity
structure, with the user identifier (userID
) as the only required property, all other properties are optional.
Verified identification
The verified identification method is used to identify the user with a unique identifier and verify the user’s identity with the DevRev backend.
Update the user
You can update the user’s information using the following method:
This function accepts the DevRev.Identity
structure.
The userID
property cannot be updated.
The identification functions are asynchronous. Ensure you wrap them in a Task
when calling from synchronous contexts.
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 will be logged out by clearing their credentials, as well as unregistering the device from receiving push notifications, and stopping the session recording.
For example:
PLuG support chat
UIKit
The support chat feature can be shown as a modal screen from a specific view controller or the top-most one, or can be pushed onto a navigation stack.
To show the support chat screen in your app, you can use the following overloaded method:
-
When a
UIViewController
is passed as thefrom
parameter, the screen is shown modally. -
When a
UINavigationController
is passed as thefrom
parameter, the screen is pushed onto the navigation stack.
If you want to display the support chat screen from the top-most view controller, use the following method:
For example:
SwiftUI
To display the support chat screen in a SwiftUI app, you can use the following view:
New conversation closure
You can receive a callback when a new conversation is created by setting the following closure:
This allows your app to access the ID of the newly created conversation.
For example:
In-app link handling
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.
You can further customize the behavior by setting the shouldDismissModalsOnOpenLink
boolean flag. This flag controls whether the DevRev SDK should dismiss the top-most modal screen when a link is opened.
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 will be dynamic and follow the system appearance.
Analytics
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:
For example:
Session analytics
The DevRev SDK offers session analytics features to help you understand how users interact with your app.
Opting-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 capture user interactions with your app.
The session recording feature is opt-in 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 dictionary 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, 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 additional views as sensitive using the following method:
If any previously masked views need to be unmasked, you can use the following method:
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 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:
To stop a timer, use the following method:
For example:
Screen tracking
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:
For example:
Push notifications
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.
Configuration
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 iOS app is configured to receive push notifications. You can follow the Apple documentation for guidance on registering your app with Apple Push Notification Service (APNs).
Register for push notifications
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:
The method requires a device identifier, which can either be an identifier unique to your system or the Apple-provided Vendor Identifier (IDFV). Typically, the token registration is called from the AppDelegate.application(_:didRegisterForRemoteNotificationsWithDeviceToken:)
method.
For example:
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:
This method requires the device identifier, which should be the same as the one used during registration. It is recommended to place this method after calling UIApplication.unregisterForRemoteNotifications()
in your app.
For example:
Handle push notifications
Push notifications coming to the DevRev SDK need to be handled manually. To properly handle them, implement the following method, typically in either the UNUserNotificationCenterDelegate.userNotificationCenter(_:didReceive:)
or UIApplicationDelegate.application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
:
For convenience, this method provides two overloads that accept userInfo
as either [AnyHashable: Any]
or [String: any Sendable]
dictionary types.
For example: