Skip to content

Commit 53a06b1

Browse files
Split the cordova documentation sections
1 parent 8bd3659 commit 53a06b1

File tree

5 files changed

+371
-340
lines changed

5 files changed

+371
-340
lines changed

fern/docs/pages/plug-sdk/cordova.mdx

Lines changed: 7 additions & 340 deletions
Original file line numberDiff line numberDiff line change
@@ -1,343 +1,10 @@
1-
This section describes the process of integrating the DevRev SDK with your Cordova app.
1+
# DevRev SDK for Cordova
22

3-
## Requirements
3+
This section provides documentation for integrating and using the DevRev SDK in your Cordova app.
44

5-
- Cordova CLI 10.0.0 or higher.
6-
- A minimum deployment target of Android 5.0 (API level 21) or iOS 11.
5+
## Documentation Sections
76

8-
## Installation
9-
10-
To install the DevRev SDK, run the following command:
11-
12-
```sh
13-
cordova plugin add devrev-cordova-plugin
14-
```
15-
16-
## Set up the DevRev SDK
17-
18-
1. Open the DevRev web app at [https://app.devrev.ai](https://app.devrev.ai) and go to the **Settings** page.
19-
2. Under **PLuG settings**, copy the value under **Your unique App ID**.
20-
3. After obtaining the credentials, you can configure the DevRev SDK in your app.
21-
22-
<Callout intent="note">
23-
The DevRev SDK must be configured before you can use any of its features.
24-
</Callout>
25-
26-
The SDK will be ready for use once you execute the following configuration method:
27-
28-
```javascript
29-
DevRev.configure(appID, successCallback, errorCallback)
30-
```
31-
32-
## Identification
33-
34-
To access certain features of the DevRev SDK, user identification is required.
35-
36-
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.
37-
38-
<Callout intent="note">
39-
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.
40-
</Callout>
41-
42-
<Callout intent="note">
43-
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](https://devrev.ai/docs/product/object-customization).
44-
</Callout>
45-
46-
You can select from the following methods to identify users within your application:
47-
48-
### Anonymous identification
49-
50-
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.
51-
52-
```javascript
53-
DevRev.identifyAnonymousUser(successCallback, errorCallback)
54-
```
55-
56-
### Unverified identification
57-
58-
The unverified identification method identifies users with a unique identifier, but it does not verify their identity with the DevRev backend.
59-
60-
```javascript
61-
DevRev.identifyUnverifiedUser(identity, successCallback, errorCallback)
62-
```
63-
64-
### Verified identification
65-
66-
The verified identification method identifies users with a unique identifier and verifies their identity with the DevRev backend.
67-
68-
```javascript
69-
DevRev.identifyVerifiedUser(identity, successCallback, errorCallback)
70-
```
71-
72-
### Update the user
73-
74-
You can update the user's information using the following method:
75-
76-
```javascript
77-
DevRev.updateUser(identity, successCallback, errorCallback)
78-
```
79-
80-
<Callout intent="note">
81-
The `userID` property cannot be updated.
82-
</Callout>
83-
84-
### Logout
85-
86-
You can log out the current user by using the following method:
87-
88-
```javascript
89-
DevRev.logout(deviceID, successCallback, errorCallback)
90-
```
91-
92-
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.
93-
94-
## PLuG support chat
95-
96-
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.
97-
98-
<Callout intent="note">
99-
This functionality requires the SDK to be configured and the user to be identified, whether they are unverified or anonymous.
100-
</Callout>
101-
102-
To show the support chat screen in your app, you can use the following method:
103-
104-
```javascript
105-
DevRev.showSupport(successCallback, errorCallback)
106-
```
107-
108-
### Creating a new support conversation
109-
110-
You can initiate a new support conversation directly from your app. This method displays the support chat screen and simultaneously creates a new conversation.
111-
112-
```javascript
113-
DevRev.createSupportConversation(isAnimated, successCallback, errorCallback)
114-
```
115-
116-
## In-app link handling
117-
118-
The DevRev SDK provides a mechanism to handle links opened from within any screen that is part of the DevRev SDK.
119-
120-
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.
121-
122-
```javascript
123-
DevRevSDK.setInAppLinkHandler(handler, successCallback, errorCallback)
124-
```
125-
126-
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.
127-
128-
```javascript
129-
DevRevSDK.setShouldDismissModalsOnOpenLink(value, successCallback, errorCallback)
130-
```
131-
132-
## Analytics
133-
134-
The DevRev SDK allows you to send custom analytic events by using a properties map. You can track these events using the following function:
135-
136-
<Callout intent="note">
137-
This functionality requires the SDK to be configured and the user to be identified, whether they are unverified or anonymous.
138-
</Callout>
139-
140-
```javascript
141-
DevRev.trackEvent(name, properties, successCallback, errorCallback)
142-
```
143-
144-
## Session analytics
145-
146-
The DevRev SDK offers session analytics features to help you understand how users interact with your app.
147-
148-
### Opting-in or out
149-
150-
Session analytics features are opted-in by default, enabling them from the start. However, you can opt-out using the following method:
151-
152-
```javascript
153-
DevRev.stopAllMonitoring(successCallback, errorCallback)
154-
```
155-
156-
To opt back in, use the following method:
157-
158-
```javascript
159-
DevRev.resumeAllMonitoring(successCallback, errorCallback)
160-
```
161-
162-
### Session recording
163-
164-
You can enable session recording to capture user interactions with your app.
165-
166-
<Callout intent="note">
167-
The session recording feature is opt-out and is enabled by default.
168-
</Callout>
169-
170-
The session recording feature includes the following methods to control the recording:
171-
172-
| Method | Action |
173-
|--------------------------------------------------------------------|-----------------------------------------------------------|
174-
|`DevRev.startRecording(successCallback, errorCallback)` | Starts the session recording. |
175-
|`DevRev.stopRecording(successCallback, errorCallback)` | Ends the session recording and uploads it to the portal. |
176-
|`DevRev.pauseRecording(successCallback, errorCallback)` | Pauses the ongoing session recording. |
177-
|`DevRev.resumeRecording(successCallback, errorCallback)` | Resumes a paused session recording. |
178-
179-
### Session properties
180-
181-
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.
182-
183-
```javascript
184-
DevRev.addSessionProperties(properties, successCallback, errorCallback)
185-
```
186-
187-
To clear the session properties in scenarios such as user logout or when the session ends, use the following method:
188-
189-
```javascript
190-
DevRev.clearSessionProperties(successCallback, errorCallback)
191-
```
192-
193-
### Masking sensitive data
194-
195-
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.
196-
197-
While the auto-masking feature may be sufficient for most situations, you can manually mark additional views as sensitive using the following method:
198-
199-
```javascript
200-
DevRev.markSensitiveViews(tags, successCallback, errorCallback)
201-
```
202-
203-
If any previously masked views need to be unmasked, you can use the following method:
204-
205-
```javascript
206-
DevRev.unmarkSensitiveViews(tags, successCallback, errorCallback)
207-
```
208-
209-
### Timers
210-
211-
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.
212-
213-
The mechanism utilizes balanced start and stop methods, both of which accept a timer name and an optional dictionary of properties.
214-
215-
To start a timer, use the following method:
216-
217-
```javascript
218-
DevRev.startTimer(name, properties, successCallback, errorCallback)
219-
```
220-
221-
To stop a timer, use the following method:
222-
223-
```javascript
224-
DevRev.endTimer(name, properties, successCallback, errorCallback)
225-
```
226-
227-
### Screen tracking
228-
229-
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:
230-
231-
```javascript
232-
DevRev.trackScreenName(screenName, successCallback, errorCallback)
233-
```
234-
235-
## Push notifications
236-
237-
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.
238-
239-
The DevRev backend sends push notifications to your app to alert users about new messages in the PLuG support chat.
240-
241-
### Configuration
242-
243-
To receive push notifications, you need to configure your DevRev organization by following the instructions in the [push notifications](https://developer.devrev.ai/public/sdks/mobile/push-notification) section.
244-
245-
### Register for push notifications
246-
247-
<Callout intent="note">
248-
Push notifications require SDK configuration and user identification, whether unverified or anonymous, to ensure delivery to the correct user.
249-
</Callout>
250-
251-
The DevRev SDK offers a method to register your device for receiving push notifications. You can register for push notifications using the following method:
252-
253-
```javascript
254-
DevRev.registerDeviceToken(deviceToken, deviceID, successCallback, errorCallback)
255-
```
256-
257-
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.
258-
259-
### Unregister from push notifications
260-
261-
If your app no longer needs to receive push notifications, you can unregister the device.
262-
263-
Use the following method to unregister the device:
264-
265-
```javascript
266-
DevRev.unregisterDevice(deviceID, successCallback, errorCallback)
267-
```
268-
269-
### Processing push notifications
270-
271-
#### Android
272-
273-
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.
274-
275-
To process the notification, use the following method:
276-
277-
```javascript
278-
DevRev.processPushNotification(payload, successCallback, errorCallback)
279-
```
280-
281-
Here, the `message` object from the notification payload should be passed to this function.
282-
283-
For example:
284-
285-
```javascript
286-
const notificationPayload = {
287-
"message": {
288-
"title": "New Message",
289-
"body": "You have received a new message.",
290-
"data": {
291-
"messageId": "12345",
292-
"sender": "John Doe"
293-
}
294-
}
295-
};
296-
297-
const messageJson = notificationPayload["message"];
298-
299-
DevRev.processPushNotification(messageJson, function() {
300-
console.log("Push notification processed successfully.");
301-
}, function(error) {
302-
console.error("Failed to process push notification:", error);
303-
});
304-
```
305-
306-
#### iOS
307-
308-
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.
309-
310-
```javascript
311-
DevRev.processPushNotification(payload, successCallback, errorCallback)
312-
```
313-
314-
For example:
315-
316-
```javascript
317-
const notificationPayload = {
318-
"message": {
319-
"title": "New Message",
320-
"body": "You have received a new message.",
321-
"data": {
322-
"messageId": "12345",
323-
"sender": "John Doe"
324-
}
325-
}
326-
};
327-
328-
const messageJson = notificationPayload["message"];
329-
330-
DevRev.processPushNotification(messageJson, function() {
331-
console.log("Push notification processed successfully.");
332-
}, function(error) {
333-
console.error("Failed to process push notification:", error);
334-
});
335-
```
336-
337-
## Troubleshooting
338-
339-
- **Issue**: Support chat won't show.
340-
**Solution**: Ensure you have correctly called one of the identification methods: `DevRev.identifyUnverifiedUser(...)`, `DevRev.identifyVerifiedUser(...)`, or `DevRev.identifyAnonymousUser(...)`.
341-
342-
- **Issue**: Not receiving push notifications.
343-
**Solution**: Ensure that your app is configured to receive push notifications and that your device is registered with the DevRev SDK.
7+
- [Quickstart Guide](./cordova/quickstart)
8+
- [Features](./cordova/features)
9+
- [Troubleshooting](./cordova/troubleshooting)
10+
- [Migration Guide](./cordova/migration-guide)

0 commit comments

Comments
 (0)