Skip to content

Commit

Permalink
Add Method displayHome (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepak786 authored Oct 4, 2024
1 parent 85013a6 commit df0cd0f
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 5 deletions.
1 change: 1 addition & 0 deletions intercom_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 9.0.11

* Removed references to v1 embedding.
* Implemented `displayHome` for all platforms.

## 9.0.10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ class IntercomFlutterPlugin : FlutterPlugin, MethodCallHandler, EventChannel.Str
Intercom.client().present(IntercomSpace.Tickets)
result.success("Launched Tickets space")
}
"displayHome" -> {
Intercom.client().present(IntercomSpace.Home)
result.success("Launched Home space")
}
else -> result.notImplemented()
}
}
Expand Down
3 changes: 3 additions & 0 deletions intercom_flutter/ios/Classes/IntercomFlutterPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ - (void) handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
} else if([@"displayTickets" isEqualToString:call.method]) {
[Intercom presentIntercom:tickets];
result(@"Presented tickets space");
} else if([@"displayHome" isEqualToString:call.method]) {
[Intercom presentIntercom:home];
result(@"Presented home space");
}
else {
result(FlutterMethodNotImplemented);
Expand Down
5 changes: 5 additions & 0 deletions intercom_flutter/lib/intercom_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,9 @@ class Intercom {
Future<void> displayTickets() {
return IntercomFlutterPlatform.instance.displayTickets();
}

/// To display an Intercom Home space.
Future<void> displayHome() {
return IntercomFlutterPlatform.instance.displayHome();
}
}
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.0
intercom_flutter_web: ^1.1.2
intercom_flutter_platform_interface: ^2.0.1
intercom_flutter_web: ^1.1.3

dev_dependencies:
flutter_test:
Expand Down
5 changes: 5 additions & 0 deletions intercom_flutter/test/intercom_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,9 @@ void main() {
await Intercom.instance.displayTickets();
expectMethodCall('displayTickets');
});

test('displayHome', () async {
await Intercom.instance.displayHome();
expectMethodCall('displayHome');
});
}
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.1

* Added method `displayHome`.

## 2.0.0

* Removed deprecated methods `registerIdentifiedUser` and `registerUnidentifiedUser`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,9 @@ abstract class IntercomFlutterPlatform extends PlatformInterface {
Future<void> displayTickets() {
throw UnimplementedError('displayTickets() has not been implemented.');
}

/// To display an Intercom Home space.
Future<void> displayHome() {
throw UnimplementedError('displayHome() has not been implemented.');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ class MethodChannelIntercomFlutter extends IntercomFlutterPlatform {
await _channel.invokeMethod('displayTickets');
}

@override
Future<void> displayHome() async {
await _channel.invokeMethod('displayHome');
}

/// 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.0
version: 2.0.1
homepage: https://github.com/v3rm0n/intercom_flutter

dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,14 @@ void main() {
<Matcher>[isMethodCall('displayTickets', arguments: null)],
);
});

test('displayHome', () async {
await intercom.displayHome();
expect(
log,
<Matcher>[isMethodCall('displayHome', arguments: null)],
);
});
});
}

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.3

* Implemented method `displayHome`.

## 1.1.2

* Bump `web` to `^1.0.0`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,9 @@ void main() {
testWidgets('displayTickets', (WidgetTester _) async {
expect(plugin.displayTickets(), completes);
});

testWidgets('displayHome', (WidgetTester _) async {
expect(plugin.displayHome(), completes);
});
});
}
6 changes: 6 additions & 0 deletions intercom_flutter_web/lib/intercom_flutter_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ class IntercomFlutterWeb extends IntercomFlutterPlatform {
print("Launched Tickets space");
}

@override
Future<void> displayHome() async {
globalContext.callMethod('Intercom'.toJS, 'showSpace'.toJS, 'home'.toJS);
print("Launched Home space");
}

/// get the [window.intercomSettings]
Map<dynamic, dynamic> getIntercomSettings() {
if (globalContext.hasProperty('intercomSettings'.toJS).toDart) {
Expand Down
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.2
version: 1.1.3
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.0
intercom_flutter_platform_interface: ^2.0.1
uuid: ^4.2.1 # to get the random uuid for loginUnidentifiedUser in web
web: ^1.0.0

Expand Down

0 comments on commit df0cd0f

Please sign in to comment.