Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions intercom_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

* Bump Intercom Android SDK version to [18.5.0](https://github.com/intercom/intercom-android/releases/tag/18.5.0)
* Bump Intercom iOS SDK version to [19.7.0](https://github.com/intercom/intercom-ios/releases/tag/19.7.0)
* Added API `suppressProactiveContent` to control which proactive content types (carousels, surveys) can be displayed. Not supported on web.
* Updated dependency `intercom_flutter_platform_interface: ^2.0.8`
* Updated dependency `intercom_flutter_web: ^1.1.13`

## 9.6.16

Expand Down
1 change: 1 addition & 0 deletions intercom_flutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ But you can pre-define some Intercom settings, if you want (optional).
- [ ] displayCarousel
- [ ] displayHelpCenterCollections
- [ ] getWindowDidHideStream
- [ ] suppressProactiveContent

## Using Intercom keys with `--dart-define`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,18 @@ class IntercomFlutterPlugin : FlutterPlugin, MethodCallHandler, EventChannel.Str
})
}
}
"suppressProactiveContent" -> {
val types = call.argument<List<String>>("types") ?: emptyList()
val contentTypes = types.mapNotNull { type ->
when (type) {
"carousel" -> Intercom.ContentType.CAROUSEL
"survey" -> Intercom.ContentType.SURVEY
else -> null
}
}
Intercom.client().suppressProactiveContent(contentTypes)
result.success("Suppressed proactive content: $types")
}
"setThemeMode" -> {
val theme = call.argument<String>("theme")
when (theme) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,20 @@ - (void) handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
details: [self getIntercomError:errorCode:errorMsg]]);
}];
}
} else if([@"suppressProactiveContent" isEqualToString:call.method]) {
NSArray *types = call.arguments[@"types"];
NSMutableArray<NSNumber *> *contentTypes = [NSMutableArray array];
if(types != (id)[NSNull null] && types != nil) {
for (NSString *type in types) {
if([@"carousel" isEqualToString:type]) {
[contentTypes addObject:@(IntercomProactiveContentTypeCarousel)];
} else if([@"survey" isEqualToString:type]) {
[contentTypes addObject:@(IntercomProactiveContentTypeSurvey)];
}
}
}
[Intercom suppressProactiveContent:contentTypes];
result(@"Suppressed proactive content");
} else if([@"setThemeMode" isEqualToString:call.method]) {
NSString *theme = call.arguments[@"theme"];

Expand Down
14 changes: 13 additions & 1 deletion intercom_flutter/lib/intercom_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:intercom_flutter_platform_interface/intercom_status_callback.dar

/// export the [IntercomVisibility] enum
export 'package:intercom_flutter_platform_interface/enumeral.dart'
show IntercomVisibility, IntercomTheme;
show IntercomVisibility, IntercomTheme, IntercomProactiveContentType;
export 'package:intercom_flutter_platform_interface/intercom_status_callback.dart'
show IntercomStatusCallback, IntercomError;

Expand Down Expand Up @@ -312,4 +312,16 @@ class Intercom {
Future<void> setThemeMode(IntercomTheme theme) {
return IntercomFlutterPlatform.instance.setThemeMode(theme);
}

/// To suppress the given proactive content [types] (carousels, surveys)
/// from being displayed.
///
/// All the proactive content types are visible by default.
/// Pass an empty list to unsuppress all.
///
/// Note: this is not supported on web.
Future<void> suppressProactiveContent(
List<IntercomProactiveContentType> types) {
return IntercomFlutterPlatform.instance.suppressProactiveContent(types);
}
}
4 changes: 2 additions & 2 deletions intercom_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ dependencies:
sdk: flutter
flutter_web_plugins:
sdk: flutter
intercom_flutter_platform_interface: ^2.0.7
intercom_flutter_web: ^1.1.12
intercom_flutter_platform_interface: ^2.0.8
intercom_flutter_web: ^1.1.13

dev_dependencies:
flutter_test:
Expand Down
19 changes: 19 additions & 0 deletions intercom_flutter/test/intercom_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -355,4 +355,23 @@ void main() {
});
});
});

group('suppressProactiveContent', () {
test('suppress carousel and survey', () {
Intercom.instance.suppressProactiveContent([
IntercomProactiveContentType.carousel,
IntercomProactiveContentType.survey,
]);
expectMethodCall('suppressProactiveContent', arguments: {
'types': ['carousel', 'survey'],
});
});

test('unsuppress all', () {
Intercom.instance.suppressProactiveContent([]);
expectMethodCall('suppressProactiveContent', arguments: {
'types': [],
});
});
});
}
4 changes: 4 additions & 0 deletions intercom_flutter_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.0.8

* Added method `suppressProactiveContent`.

## 2.0.7

* Added method `getWindowDidHideStream`.
Expand Down
7 changes: 7 additions & 0 deletions intercom_flutter_platform_interface/lib/enumeral.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ enum IntercomVisibility {
visible,
}

/// Proactive content types whose visibility can be controlled via
/// `suppressProactiveContent`.
enum IntercomProactiveContentType {
carousel,
survey,
}

enum IntercomTheme {
// // Enable dark mode
dark,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,15 @@ abstract class IntercomFlutterPlatform extends PlatformInterface {
Future<void> setThemeMode(IntercomTheme theme) {
throw UnimplementedError('setThemeMode() has not been implemented.');
}

/// To suppress the given proactive content [types] (carousels, surveys)
/// from being displayed.
///
/// All the proactive content types are visible by default.
/// Pass an empty list to unsuppress all.
Future<void> suppressProactiveContent(
List<IntercomProactiveContentType> types) {
throw UnimplementedError(
'suppressProactiveContent() has not been implemented.');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ class MethodChannelIntercomFlutter extends IntercomFlutterPlatform {
await _channel.invokeMethod('setThemeMode', {'theme': theme.name});
}

@override
Future<void> suppressProactiveContent(
List<IntercomProactiveContentType> types) async {
await _channel.invokeMethod('suppressProactiveContent', {
'types': types.map((type) => type.name).toList(),
});
}

/// Convert the [PlatformException] details to [IntercomError].
/// From the Platform side if the intercom operation failed then error details
/// will be sent as details in [PlatformException].
Expand Down
2 changes: 1 addition & 1 deletion intercom_flutter_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: intercom_flutter_platform_interface
description: A common platform interface for the intercom_flutter plugin.
version: 2.0.7
version: 2.0.8
homepage: https://github.com/v3rm0n/intercom_flutter

dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,35 @@ void main() {
);
});
});

group('suppressProactiveContent', () {
test('suppress carousel and survey', () async {
await intercom.suppressProactiveContent([
IntercomProactiveContentType.carousel,
IntercomProactiveContentType.survey,
]);
expect(
log,
<Matcher>[
isMethodCall('suppressProactiveContent', arguments: {
'types': ['carousel', 'survey'],
})
],
);
});

test('unsuppress all', () async {
await intercom.suppressProactiveContent([]);
expect(
log,
<Matcher>[
isMethodCall('suppressProactiveContent', arguments: {
'types': [],
})
],
);
});
});
});
}

Expand Down
4 changes: 4 additions & 0 deletions intercom_flutter_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.1.13

* Updated `intercom_flutter_platform_interface` to `^2.0.8`.

## 1.1.12

* Updated `intercom_flutter_platform_interface` to `^2.0.7`.
Expand Down
2 changes: 2 additions & 0 deletions intercom_flutter_web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ But you can pre-define some Intercom settings, if you want (optional), such as `
- handlePush
- displayCarousel
- displayHelpCenterCollections
- getWindowDidHideStream
- suppressProactiveContent

[1]: ../intercom_flutter

4 changes: 2 additions & 2 deletions intercom_flutter_web/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: intercom_flutter_web
description: Web platform implementation of intercom_flutter
version: 1.1.12
version: 1.1.13
homepage: https://github.com/v3rm0n/intercom_flutter

flutter:
Expand All @@ -15,7 +15,7 @@ dependencies:
sdk: flutter
flutter_web_plugins:
sdk: flutter
intercom_flutter_platform_interface: ^2.0.7
intercom_flutter_platform_interface: ^2.0.8
uuid: ^4.2.1 # to get the random uuid for loginUnidentifiedUser in web
web: ^1.0.0

Expand Down
Loading