Skip to content

Commit

Permalink
Implement displayConversation on iOS and Android
Browse files Browse the repository at this point in the history
  • Loading branch information
theVinesh committed Aug 14, 2023
1 parent 925eb63 commit 1c012a3
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 2 deletions.
6 changes: 6 additions & 0 deletions intercom_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 7.8.4

* Bump Intercom iOS SDK version to 15.1.4
* Bump Intercom Android SDK version to 15.1.6
* Implemented `displayConversation` for all platforms.

## 7.8.3

* Bump Intercom iOS SDK version to 15.1.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ class IntercomFlutterPlugin : FlutterPlugin, MethodCallHandler, EventChannel.Str
result.success("displaying survey $surveyId")
}
}
"displayConversation" -> {
val conversationId = call.argument<String>("conversationId")
if (conversationId != null) {
Intercom.client().presentContent(IntercomContent.Conversation(conversationId))
result.success("displaying conversation $conversationId")
}
}
else -> result.notImplemented()
}
}
Expand Down
6 changes: 6 additions & 0 deletions intercom_flutter/ios/Classes/IntercomFlutterPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ - (void) handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
NSDictionary *message = call.arguments[@"message"];
[Intercom handleIntercomPushNotification:message];
result(@"handle push");
} else if([@"displayConversation" isEqualToString:call.method]) {
NSString *conversationId = call.arguments[@"conversationId"];
if(conversationId != (id)[NSNull null] && conversationId != nil) {
[Intercom presentContent:[IntercomContent conversationWithId:conversationId]];
result(@"displaying conversation");
}
}
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 @@ -281,4 +281,9 @@ class Intercom {
Future<void> displaySurvey(String surveyId) {
return IntercomFlutterPlatform.instance.displaySurvey(surveyId);
}

/// To display a Conversation, pass in a [conversationId] from your Intercom workspace.
Future<void> displayConversation(String conversationId) {
return IntercomFlutterPlatform.instance.displayConversation(conversationId);
}
}
4 changes: 2 additions & 2 deletions intercom_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: intercom_flutter
description: Flutter plugin for Intercom integration. Provides in-app messaging
and help-center Intercom services
version: 7.8.3
version: 7.8.4
homepage: https://github.com/v3rm0n/intercom_flutter

dependencies:
flutter:
sdk: flutter
flutter_web_plugins:
sdk: flutter
intercom_flutter_platform_interface: ^1.3.0
intercom_flutter_platform_interface: ^1.3.1
intercom_flutter_web: ^0.3.1

dev_dependencies:
Expand Down
8 changes: 8 additions & 0 deletions intercom_flutter/test/intercom_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,12 @@ void main() {
'surveyId': testSurveyId,
});
});

test('displayConversation', () async {
final String testConversationId = "123456";
await Intercom.instance.displayConversation(testConversationId);
expectMethodCall('displayConversation', arguments: {
'conversationId': testConversationId,
});
});
}
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 @@ -268,6 +268,12 @@ class IntercomFlutterWeb extends IntercomFlutterPlatform {
await js.context.callMethod('Intercom', ['startSurvey', surveyId]);
}

@override
Future<void> displayConversation(String conversationId) async {
await js.context
.callMethod('Intercom', ['showConversation', conversationId]);
}

/// get the [window.IntercomSettings]
js.JsObject getIntercomSettings() {
if (js.context.hasProperty('intercomSettings')) {
Expand Down

0 comments on commit 1c012a3

Please sign in to comment.