Skip to content

ISS-160256: Restructure the SDK documentation for iOS #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 108 additions & 33 deletions fern/docs/pages/plug-sdk/ios.mdx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [EkLine] reported by reviewdog 🐶

Where possible, do not structure sentences in future tense. Use present tense instead. (EK00005)

The SDK will be ready for use once you execute the following configuration method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [EkLine] reported by reviewdog 🐶

Where possible, do not structure sentences in future tense. Use present tense instead. (EK00005)

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [EkLine] reported by reviewdog 🐶

Consider using 'go' instead of 'navigate'. (EK25033)

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:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [EkLine] reported by reviewdog 🐶

Remove 'properly ' if it's not important to the meaning of the statement. (EK00006)

To properly handle push notifications, implement the following method, typically in either the `UNUserNotificationCenterDelegate.userNotificationCenter(_:didReceive:)` or `UIApplicationDelegate.application(_:didReceiveRemoteNotification:fetchCompletionHandler:)`:

Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@
This section describes the process of integrating the DevRev SDK with your iOS app.

## Requirements
## Quickstart
Copy link
Contributor

@bc-devrev bc-devrev Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend against this. It doesn't look all that "quick" to me. "Integration" seems like a more suitable term, but that's used in the section that has SPM and CocoaPods.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll split it in the next iteration into sub-pages.

### Requirements

- Xcode 16.0 or higher (latest stable version available on the App Store).
- Swift 5.9 or later.
- Set the minimum deployment target for your iOS application as iOS 15.

## Integration
### Integration

The DevRev SDK can be integrated using either Swift Package Manager (SPM) or CocoaPods.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SPM and CocoaPods sections aren't nested properly. They'd need to be H4, which isn't recommended. An accordion group or tabs might be a better option for those sections.


<Callout intent="note">
We recommend integrating the DevRev SDK using SPM.
</Callout>

### Swift Package Manager
<Tabs>
<Tab title="Swift Package Manager">
To integrate the DevRev SDK into your project using SPM:

To integrate the DevRev SDK into your project using SPM:
1. Open your project in Xcode and navigate to the **Add Package Dependency**.
2. Enter the DevRev SDK URL under **Enter Package URL**:
- For HTTPS: https://github.com/devrev/devrev-sdk-ios
- For SSH: `[email protected]:devrev/devrev-sdk-ios.git`
3. In the **Build Phases** section of your app target, locate the **Link Binary With Libraries** phase and confirm that `DevRevSDK` is linked. If not, add it by clicking **+** and selecting `DevRevSDK` from the list.

1. Open your project in Xcode and navigate to the **Add Package Dependency**.
2. Enter the DevRev SDK URL under **Enter Package URL**:
- For HTTPS: https://github.com/devrev/devrev-sdk-ios
- For SSH: `[email protected]:devrev/devrev-sdk-ios.git`
3. In the **Build Phases** section of your app target, locate the **Link Binary With Libraries** phase and confirm that `DevRevSDK` is linked. If not, add it by clicking **+** and selecting `DevRevSDK` from the list.
Now you should be able to import and use the DevRev SDK in your project.
</Tab>
<Tab title="CocoaPods">
To integrate the DevRev SDK using CocoaPods:

Now you should be able to import and use the DevRev SDK in your project.
1. Add the following to your Podfile:
```ruby
pod 'DevRevSDK', '~> 1.0.0'
```
2. Run `pod install` in your project directory.

### CocoaPods
This will install the DevRev SDK in your project, making it ready for use.
</Tab>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not leave blank lines before the closing tab (for both cases).

</Tabs>

To integrate the DevRev SDK using CocoaPods:

1. Add the following to your Podfile:
```ruby
pod 'DevRevSDK', '~> 1.0.0'
```
2. Run `pod install` in your project directory.

This will install the DevRev SDK in your project, making it ready for use.

## Set up the DevRev SDK
### Set up the DevRev SDK

1. Open the DevRev web app at [https://app.devrev.ai](https://app.devrev.ai) and go to the **Settings** page.
2. Under **PLuG settings** copy the value under **Your unique App ID**.
Expand All @@ -58,15 +60,20 @@ For example:
DevRev.configure(appID: "abcdefg12345")
```

Use this property to check whether the DevRev SDK has been configured:
```swift
await DevRev.isConfigured
```

- UIKit apps

Configure the SDK in the `AppDelegate.application(_:didFinishLaunchingWithOptions:)` method.

- SwiftUI apps

Depending on your app's architecture, configure the SDK at the app's entry point or initial view.

## Identification
## Features
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure of the purpose of calling a list of stuff "Features". I'm also not sure if everything in this group is really a feature.

Suggested change
## Features
## Features

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all features of the SDK and they will get split into sub-pages in the next iteration.

### Identification

To access certain features of the DevRev SDK, user identification is required.

Expand Down Expand Up @@ -100,6 +107,13 @@ DevRev.identifyUnverifiedUser(_:)

The function accepts the `DevRev.Identity` structure, where the user identifier (`userId`) is 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.

```swift
DevRev.identifyVerifiedUser(_:sessionToken:)
```

### Update the user

You can update the user's information using the following method:
Expand All @@ -120,6 +134,20 @@ The `userID` property cannot be updated.
The identification functions are asynchronous. Ensure you wrap them in a `Task` when calling from synchronous contexts.
</Callout>

Use this property to check whether the user is identified in the current session:
```swift
await DevRev.isUserIdentified
```

### Logout
You can perform a logout of the current user by calling the following method:

```swift
DevRev.logout(deviceID:)
```

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [EkLine] reported by reviewdog 🐶

Where possible, do not structure sentences in future tense. Use present tense instead. (EK00005)

Suggested change
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.
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:

```swift
Expand All @@ -133,7 +161,7 @@ await DevRev.identifyUnverifiedUser(Identity(userID: "[email protected]"))
await DevRev.updateUser(Identity(organizationID: "organization-1337"))
```

## PLuG support chat
### PLuG support chat

### UIKit

Expand Down Expand Up @@ -175,7 +203,14 @@ To display the support chat screen in a SwiftUI app, you can use the following v
DevRev.supportView
```

#### New conversation closure
### Creating a new conversation
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [EkLine] reported by reviewdog 🐶

Where possible, do not structure sentences in future tense. Use present tense instead. (EK00005)

Suggested change
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.
You have the ability to create a new conversation from within your app. The method shows the support chat screen and creates a new conversation at the same time.


```swift
DevRev.createSupportConversation()
```

### New conversation closure

You can receive a callback when a new conversation is created by setting the following closure:

Expand All @@ -193,7 +228,31 @@ DevRev.conversationCreatedCompletion = { conversationID in
}
```

## Analytics
### 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.

```swift
DevRev.inAppLinkHandler: ((URL) -> Void)?
```

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.

```swift
DevRev.shouldDismissModalsOnOpenLink: Bool
```

### Dynamic Theme Configuration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [EkLine] reported by reviewdog 🐶

'Dynamic Theme Configuration' should use sentence-style capitalization. (EK00037)


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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [EkLine] reported by reviewdog 🐶

Where possible, do not structure sentences in future tense. Use present tense instead. (EK00005)

Suggested change
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.
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.


```swift
DevRev.prefersSystemTheme: Bool
```

### 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:

Expand All @@ -207,7 +266,7 @@ For example:
await DevRev.trackEvent(name: "open-message-screen", properties: ["id": "message-1337"])
```

## Session analytics
### Session analytics

The DevRev SDK offers session analytics features to help you understand how users interact with your app.

Expand All @@ -225,6 +284,11 @@ To opt back in, use the following method:
DevRev.resumeAllMonitoring()
```

You can check whether session monitoring has been enabled by using this property:
```swift
DevRev.isMonitoringEnabled
```

### Session recording

You can enable session recording to capture user interactions with your app.
Expand All @@ -241,6 +305,17 @@ The session recording feature includes the following methods to control the reco
|`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. |

Using this property will return the status of the session recording:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [EkLine] reported by reviewdog 🐶

Where possible, do not structure sentences in future tense. Use present tense instead. (EK00005)

Suggested change
Using this property will return the status of the session recording:
Using this property returns the status of the session recording.

```swift
DevRev.isRecording
```

To check if on-demand sessions are enabled, use:
```swift
DevRev.areOnDemandSessionsEnabled
```

### Session properties

Expand All @@ -250,7 +325,7 @@ You can add custom properties to the session recording to help you understand th
DevRev.addSessionProperties(_:)
```

To clear the session properties in scenarios such as user logout or when the session ends, use the following method:
To clear the session properties in scenarios such as user logout or when the session ends, use the following method:

```swift
DevRev.clearSessionProperties()
Expand Down Expand Up @@ -411,14 +486,14 @@ func userNotificationCenter(

## Troubleshooting

- **Issue**: Can't import the SDK into my app.
- **Issue**: Can't import the SDK into my app.
**Solution**: Double-check the setup process and ensure that `DevRevSDK` is correctly linked to your application.

- **Issue**: How does the DevRev SDK handle errors?
- **Issue**: How does the DevRev SDK handle errors?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is important information to include but doesn't belong here. I'd suggest moving it up to the "Quickstart" section.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The troubleshooting will go into a sub-page in the next iteration.

**Solution**: The DevRev SDK reports all errors in the console using Apple's Unified Logging System. Look for error messages in the subsystem `ai.devrev.sdk`.

- **Issue**: Support chat won't show.
- **Issue**: Support chat won't show.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [EkLine] reported by reviewdog 🐶

Where possible, do not structure sentences in future tense. Use present tense instead. (EK00005)

Suggested change
- **Issue**: Support chat won't show.
- **Issue**: Support chat doesn't show.

**Solution**: Ensure you have correctly called one of the identification methods: `DevRev.identifyUnverifiedUser(...)` or `DevRev.identifyAnonymousUser(...)`.

- **Issue**: Not receiving push notifications.
- **Issue**: Users do not receive push notifications.
**Solution**: Ensure that your app is configured to receive push notifications and that your device is registered with the DevRev SDK.
Loading