Skip to content

Commit e1c75a8

Browse files
committed
feat: add docs for the first release of the Flutter SDK
1 parent c70a84b commit e1c75a8

14 files changed

+385
-6
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ Register a free account for development and testing at [https://cobrowse.io/regi
3030
[react-native.md](sdk-installation/react-native.md)
3131
{% endcontent-ref %}
3232

33+
{% content-ref url="sdk-installation/flutter.md" %}
34+
[flutter.md](sdk-installation/flutter.md)
35+
{% endcontent-ref %}
36+
3337
{% content-ref url="sdk-installation/xamarin.md" %}
3438
[xamarin.md](sdk-installation/xamarin.md)
3539
{% endcontent-ref %}

SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* [iOS](sdk-installation/ios.md)
99
* [Android](sdk-installation/android.md)
1010
* [React Native](sdk-installation/react-native.md)
11+
* [Flutter](sdk-installation/flutter.md)
1112
* [Xamarin](sdk-installation/xamarin.md)
1213
* [.NET Mobile](sdk-installation/dotnet.md)
1314
* [MacOS](sdk-installation/macos.md)

sdk-features/6-digit-codes.md

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,26 @@ CobrowseIO.client().then(function() {
3939
```
4040
{% endtab %}
4141
42+
{% tab title="Android" %}
43+
```java
44+
CobrowseIO.instance().createSession((err, session) -> {
45+
if (err != null) Log.w("App", "Failed to create code");
46+
else if (session != null) Log.i("App", "Session code " + session.code());
47+
});
48+
```
49+
{% endtab %}
50+
4251
{% tab title="React Native" %}
4352
```javascript
4453
const session = await CobrowseIO.createSession()
4554
console.log('Your 6 digit code is', session.code)
4655
```
4756
{% endtab %}
4857

49-
{% tab title="Android" %}
50-
```java
51-
CobrowseIO.instance().createSession((err, session) -> {
52-
if (err != null) Log.w("App", "Failed to create code");
53-
else if (session != null) Log.i("App", "Session code " + session.code());
54-
});
58+
{% tab title="Flutter" %}
59+
```dart
60+
Session session = await CobrowseIO.instance.createSession();
61+
log('Your session code: ${session.code}');
5562
```
5663
{% endtab %}
5764

@@ -174,6 +181,30 @@ export default class App extends Component {
174181
```
175182
{% endtab %}
176183

184+
{% tab title="Flutter" %}
185+
The Cobrowse.io SDK for Flutter does not provide a default UI for generating 6 digit codes, but you can show the default UI shipped in the native SDKs using [Flutter platform channel](https://docs.flutter.dev/platform-integration/platform-channels). It's not a requirement to use this UI, you can easily build your own if you like!
186+
187+
#### iOS implementation
188+
189+
```objc
190+
@import CobrowseIO;
191+
192+
UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
193+
CBIOViewController *sessionController = [[CBIOViewController alloc] init];
194+
[rootViewController presentViewController:sessionController animated:YES completion:nil];
195+
```
196+
197+
#### Android implementation
198+
199+
```java
200+
import io.cobrowse.ui.CobrowseActivity;
201+
202+
Intent intent = new Intent(activity, CobrowseActivity.class);
203+
activity.startActivity(intent);
204+
```
205+
206+
{% endtab %}
207+
177208
{% tab title="Xamarin / .NET Mobile" %}
178209
#### Xamarin.iOS implementation
179210

sdk-features/advanced-features/starting-and-stopping-the-sdk.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ CobrowseIO.start();
5050
```
5151
{% endtab %}
5252

53+
{% tab title="Flutter" %}
54+
```dart
55+
CobrowseIO.instance.start();
56+
```
57+
{% endtab %}
58+
5359
{% tab title="Xamarin / .NET Mobile" %}
5460
```csharp
5561
CobrowseIO.Instance.Start();
@@ -148,6 +154,12 @@ CobrowseIO.stop();
148154
```
149155
{% endtab %}
150156

157+
{% tab title="Flutter" %}
158+
```dart
159+
CobrowseIO.instance.stop();
160+
```
161+
{% endtab %}
162+
151163
{% tab title="Xamarin / .NET Mobile" %}
152164
```csharp
153165
CobrowseIO.Instance.Stop();

sdk-features/customize-the-interface/customize-session-controls.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,22 @@ CobrowseIO.showSessionControls = false;
9797
```
9898
{% endtab %}
9999

100+
{% tab title="Flutter" %}
101+
102+
Listen to these event emitters to override the default session indicator. These methods may be called several times as the session progresses through its lifecycle, so you may need to adjust your UI accordingly.
103+
104+
```dart
105+
CobrowseIO.instance.showSessionControls.listen((session) {
106+
// Show your session controls
107+
});
108+
109+
CobrowseIO.instance.hideSessionControls.listen((session) {
110+
// Hide your session controls
111+
});
112+
```
113+
114+
{% endtab %}
115+
100116
{% tab title="Xamarin / .NET Mobile" %}
101117
#### Xamarin.iOS / .NET iOS implementation
102118

@@ -183,6 +199,17 @@ if (session) await session.end()
183199
```
184200
{% endtab %}
185201

202+
{% tab title="Flutter" %}
203+
```dart
204+
// Get a reference to the current session if you don't have one
205+
Session? session = await CobrowseIO.instance.currentSession();
206+
// if there's an ongoing session, end it
207+
if (session != null) {
208+
await session.end()
209+
}
210+
```
211+
{% endtab %}
212+
186213
{% tab title="Xamarin / .NET Mobile" %}
187214
```csharp
188215
CobrowseIO.Instance().CurrentSession?.End(null);

sdk-features/customize-the-interface/remote-control-consent.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ CobrowseIO.handleRemoteControlRequest = function(session) {
6060
```
6161
{% endtab %}
6262

63+
{% tab title="Flutter" %}
64+
```dart
65+
CobrowseIO.instance.handleRemoteControlRequest.listen((session) {
66+
// Show your own UI here
67+
// call session.setRemoteControl(RemoteControlState.on) to allow
68+
// or session.setRemoteControl(RemoteControlState.rejected) to reject
69+
session.setRemoteControl(RemoteControlState.on);
70+
});
71+
```
72+
{% endtab %}
73+
6374
{% tab title="Xamarin / .NET Mobile" %}
6475
```сsharp
6576
CobrowseIO.Instance.RemoteControlRequest += (object sender, ISession session) =>
@@ -287,6 +298,46 @@ CobrowseIO.handleRemoteControlRequest = function(session) {
287298
```
288299
{% endtab %}
289300

301+
{% tab title="Flutter" %}
302+
```dart
303+
CobrowseIO.instance.handleRemoteControlRequest.listen((session) {
304+
showDialog(
305+
context: context,
306+
builder: (BuildContext context) {
307+
return AlertDialog(
308+
title: const Text('Remote Control Request'),
309+
content: const Text('A support agent would like to control this app. Do you accept?'),
310+
actions: <Widget>[
311+
TextButton(
312+
onPressed: () {
313+
try {
314+
session.setRemoteControl(RemoteControlState.on);
315+
Navigator.of(context).pop();
316+
} on PlatformException {
317+
// E.g. a network error
318+
}
319+
},
320+
child: const Text('Accept'),
321+
),
322+
TextButton(
323+
onPressed: () {
324+
try {
325+
session.setRemoteControl(RemoteControlState.off);
326+
Navigator.of(context).pop();
327+
} on PlatformException {
328+
// E.g. a network error
329+
}
330+
},
331+
child: const Text('Cancel'),
332+
),
333+
],
334+
);
335+
},
336+
);
337+
});
338+
```
339+
{% endtab %}
340+
290341
{% tab title="Xamarin / .NET Mobile" %}
291342
```сsharp
292343
CobrowseIO.Instance.RemoteControlRequest += async (object sender, ISession session) =>

sdk-features/customize-the-interface/user-consent-dialog.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ CobrowseIO.handleSessionRequest = function(session) {
6262
```
6363
{% endtab %}
6464

65+
{% tab title="Flutter" %}
66+
```dart
67+
CobrowseIO.instance.handleSessionRequest.listen((session) {
68+
// Replace this with your own logic
69+
// Just be sure to call session.activate() to
70+
// accept the session, or session.end() to reject it
71+
try {
72+
session.activate();
73+
} on PlatformException {
74+
// E.g. a network error
75+
}
76+
});
77+
```
78+
{% endtab %}
79+
6580
{% tab title="Xamarin / .NET Mobile" %}
6681
#### Xamarin.iOS / .NET iOS implementation
6782

@@ -250,6 +265,46 @@ CobrowseIO.handleSessionRequest = function(session) {
250265
```
251266
{% endtab %}
252267

268+
{% tab title="Flutter" %}
269+
```dart
270+
CobrowseIO.instance.handleSessionRequest.listen((session) {
271+
showDialog(
272+
context: context,
273+
builder: (BuildContext context) {
274+
return AlertDialog(
275+
title: const Text('Screen Sharing Request'),
276+
content: const Text('A support agent would like to use this app with you. Do you accept?'),
277+
actions: <Widget>[
278+
TextButton(
279+
onPressed: () {
280+
try {
281+
session.activate();
282+
Navigator.of(context).pop();
283+
} on PlatformException {
284+
// E.g. a network error
285+
}
286+
},
287+
child: const Text('Accept'),
288+
),
289+
TextButton(
290+
onPressed: () {
291+
try {
292+
session.end();
293+
Navigator.of(context).pop();
294+
} on PlatformException {
295+
// E.g. a network error
296+
}
297+
},
298+
child: const Text('Cancel'),
299+
),
300+
],
301+
);
302+
},
303+
);
304+
});
305+
```
306+
{% endtab %}
307+
253308
{% tab title="Xamarin / .NET Mobile" %}
254309
#### Xamarin.iOS implementation
255310

sdk-features/full-device-capabilities/full-device-remote-control.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ Please follow the Android documentation to implement full device remote control
7171
{% endhint %}
7272
{% endtab %}
7373

74+
{% tab title="Flutter" %}
75+
{% hint style="info" %}
76+
Please follow the Android documentation to implement full device remote control using Flutter.
77+
{% endhint %}
78+
{% endtab %}
79+
7480
{% tab title="Xamarin / .NET Mobile" %}
7581
{% hint style="info" %}
7682
Please follow the Android documentation to implement full device remote control using Xamarin.
@@ -106,6 +112,14 @@ CobrowseAccessibilityService.showSetup(...);
106112
```
107113
{% endtab %}
108114

115+
{% tab title="Flutter" %}
116+
The Cobrowse.io SDK for Flutter does not provide a default implementation to launch the accessibility service setup, but you can access this API in the native SDK using [Flutter platform channels](https://docs.flutter.dev/platform-integration/platform-channels).
117+
118+
```java
119+
CobrowseAccessibilityService.showSetup(...);
120+
```
121+
{% endtab %}
122+
109123
{% tab title="Xamarin / .NET Mobile" %}
110124
```csharp
111125
CobrowseAccessibilityService.ShowSetup(...)
@@ -129,6 +143,14 @@ CobrowseAccessibilityService.isRunning(...);
129143
```
130144
{% endtab %}
131145

146+
{% tab title="Flutter" %}
147+
The Cobrowse.io SDK for Flutter does not provide a default implementation to detect the state of the accessibility service, but you can access this API in the native SDK using [Flutter platform channels](https://docs.flutter.dev/platform-integration/platform-channels).
148+
149+
```java
150+
CobrowseAccessibilityService.isRunning(...);
151+
```
152+
{% endtab %}
153+
132154
{% tab title="Xamarin / .NET Mobile" %}
133155
```csharp
134156
CobrowseAccessibilityService.IsRunning(...)

sdk-features/full-device-capabilities/full-device-screen-sharing.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,12 @@ Please follow the iOS and Android documentation to implement full device capabil
277277
* If you're not using `use_frameworks!` within CocoaPods, Xcode 13.3 and newer might not copy CobrowseIOExtension.framework extension dependency into resulting IPA builds. If this happens to you, please follow the guide under `iOS` -> `SPM` to create the script to copy `CobrowseIOAppExtension.framework` into the IPA on each build.
278278
{% endtab %}
279279

280+
{% tab title="Flutter" %}
281+
{% hint style="info" %}
282+
Please follow the iOS and Android documentation to implement full device capabilities on Flutter.
283+
{% endhint %}
284+
{% endtab %}
285+
280286
{% tab title="Xamarin.iOS / .NET iOS" %}
281287
{% hint style="info" %}
282288
Please review the iOS documentation for full device capabilities first.

0 commit comments

Comments
 (0)