From 9e65d58cff06a862cf39bb9295b74695356b9054 Mon Sep 17 00:00:00 2001 From: Deepak Goyal Date: Thu, 14 Nov 2024 01:53:04 +0530 Subject: [PATCH] Update intercom-android 15.11.1 and intercom-ios 18.2.0 (#482) --- intercom_flutter/CHANGELOG.md | 7 +++++ intercom_flutter/README.md | 6 +++-- intercom_flutter/android/build.gradle | 2 +- .../maido/intercom/IntercomFlutterPlugin.kt | 13 +++++++++ intercom_flutter/example/ios/Podfile | 2 +- .../ios/Classes/IntercomFlutterPlugin.m | 27 +++++++++++++++++++ intercom_flutter/ios/intercom_flutter.podspec | 2 +- intercom_flutter/lib/intercom_flutter.dart | 10 +++++++ intercom_flutter/pubspec.yaml | 6 ++--- .../CHANGELOG.md | 5 ++++ .../intercom_flutter_platform_interface.dart | 11 ++++++++ .../lib/method_channel_intercom_flutter.dart | 12 +++++++++ .../pubspec.yaml | 2 +- .../method_channel_intercom_flutter_test.dart | 16 +++++++++++ intercom_flutter_web/CHANGELOG.md | 4 +++ intercom_flutter_web/README.md | 2 ++ intercom_flutter_web/pubspec.yaml | 4 +-- 17 files changed, 120 insertions(+), 11 deletions(-) diff --git a/intercom_flutter/CHANGELOG.md b/intercom_flutter/CHANGELOG.md index 11c68e8c..1022611c 100755 --- a/intercom_flutter/CHANGELOG.md +++ b/intercom_flutter/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 9.2.0 + +* Bump Intercom Android SDK version to 15.11.1 +* Bump Intercom iOS SDK version to 18.2.0 +* Added API `isUserLoggedIn`. +* Added API `fetchLoggedInUserAttributes`. + ## 9.1.1 * Bump Intercom iOS SDK version to 18.1.0 diff --git a/intercom_flutter/README.md b/intercom_flutter/README.md index c79bf24c..7ba554c0 100755 --- a/intercom_flutter/README.md +++ b/intercom_flutter/README.md @@ -5,10 +5,10 @@ Flutter wrapper for Intercom [Android](https://github.com/intercom/intercom-android), [iOS](https://github.com/intercom/intercom-ios), and [Web](https://developers.intercom.com/installing-intercom/docs/basic-javascript) projects. -- Uses Intercom Android SDK Version `15.10.3`. +- Uses Intercom Android SDK Version `15.11.1`. - The minimum Android SDK `minSdk` required is 21. - The compile Android SDK `compileSdk` required is 34. -- Uses Intercom iOS SDK Version `18.1.0`. +- Uses Intercom iOS SDK Version `18.2.0`. - The minimum iOS target version required is 15. - The Xcode version required is 15. @@ -149,6 +149,8 @@ But you can pre-define some Intercom settings, if you want (optional). - [ ] handlePush - [ ] displayCarousel - [ ] displayHelpCenterCollections +- [ ] isUserLoggedIn +- [ ] fetchLoggedInUserAttributes ## Using Intercom keys with `--dart-define` diff --git a/intercom_flutter/android/build.gradle b/intercom_flutter/android/build.gradle index 422fd278..fced3645 100644 --- a/intercom_flutter/android/build.gradle +++ b/intercom_flutter/android/build.gradle @@ -50,6 +50,6 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'io.intercom.android:intercom-sdk:15.10.3' + implementation 'io.intercom.android:intercom-sdk:15.11.1' implementation 'com.google.firebase:firebase-messaging:23.3.1' } diff --git a/intercom_flutter/android/src/main/kotlin/io/maido/intercom/IntercomFlutterPlugin.kt b/intercom_flutter/android/src/main/kotlin/io/maido/intercom/IntercomFlutterPlugin.kt index f7257a96..187b7afe 100644 --- a/intercom_flutter/android/src/main/kotlin/io/maido/intercom/IntercomFlutterPlugin.kt +++ b/intercom_flutter/android/src/main/kotlin/io/maido/intercom/IntercomFlutterPlugin.kt @@ -256,6 +256,19 @@ class IntercomFlutterPlugin : FlutterPlugin, MethodCallHandler, EventChannel.Str Intercom.client().present(IntercomSpace.Home) result.success("Launched Home space") } + "isUserLoggedIn" -> { + result.success(Intercom.client().isUserLoggedIn()) + } + "fetchLoggedInUserAttributes" -> { + val reg = Intercom.client().fetchLoggedInUserAttributes() + val map = reg?.attributes?.toMap() ?: mutableMapOf() + if(reg != null){ + // put the user_id and email from registration + map["user_id"] = reg.userId + map["email"] = reg.email + } + result.success(map) + } else -> result.notImplemented() } } diff --git a/intercom_flutter/example/ios/Podfile b/intercom_flutter/example/ios/Podfile index 10f3c9b4..f17bddc9 100644 --- a/intercom_flutter/example/ios/Podfile +++ b/intercom_flutter/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -platform :ios, '13.0' +platform :ios, '15.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/intercom_flutter/ios/Classes/IntercomFlutterPlugin.m b/intercom_flutter/ios/Classes/IntercomFlutterPlugin.m index e7f21f17..d40e284c 100644 --- a/intercom_flutter/ios/Classes/IntercomFlutterPlugin.m +++ b/intercom_flutter/ios/Classes/IntercomFlutterPlugin.m @@ -231,6 +231,33 @@ - (void) handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result } else if([@"displayHome" isEqualToString:call.method]) { [Intercom presentIntercom:home]; result(@"Presented home space"); + } else if([@"isUserLoggedIn" isEqualToString:call.method]) { + if([Intercom isUserLoggedIn]) { + result(@(YES)); + }else{ + result(@(NO)); + } + } else if([@"fetchLoggedInUserAttributes" isEqualToString:call.method]) { + ICMUserAttributes *data = [Intercom fetchLoggedInUserAttributes]; + if(data != (id)[NSNull null]){ + NSDictionary *attributes = data.attributes; + NSMutableDictionary *map = [attributes mutableCopy]; + + // Add custom attributes + map[@"custom_attributes"] = data.customAttributes; + + // Add companies + if (data.companies) { + NSMutableArray *companiesArray = [NSMutableArray array]; + for (ICMCompany *company in data.companies) { + [companiesArray addObject:[company attributes]]; + } + map[@"companies"] = companiesArray; + } + + result(map); + } + result([NSMutableDictionary dictionary]); } else { result(FlutterMethodNotImplemented); diff --git a/intercom_flutter/ios/intercom_flutter.podspec b/intercom_flutter/ios/intercom_flutter.podspec index 930dad79..1f6cd2b6 100644 --- a/intercom_flutter/ios/intercom_flutter.podspec +++ b/intercom_flutter/ios/intercom_flutter.podspec @@ -17,6 +17,6 @@ A new flutter plugin project. s.dependency 'Flutter' s.dependency 'Intercom' s.static_framework = true - s.dependency 'Intercom', '18.1.0' + s.dependency 'Intercom', '18.2.0' s.ios.deployment_target = '15.0' end diff --git a/intercom_flutter/lib/intercom_flutter.dart b/intercom_flutter/lib/intercom_flutter.dart index c3f394c0..23b5cae0 100755 --- a/intercom_flutter/lib/intercom_flutter.dart +++ b/intercom_flutter/lib/intercom_flutter.dart @@ -277,4 +277,14 @@ class Intercom { Future displayHome() { return IntercomFlutterPlatform.instance.displayHome(); } + + /// Determine if a user is currently logged in to Intercom. + Future isUserLoggedIn() { + return IntercomFlutterPlatform.instance.isUserLoggedIn(); + } + + /// Retrieve the details of the currently logged in user. + Future> fetchLoggedInUserAttributes() { + return IntercomFlutterPlatform.instance.fetchLoggedInUserAttributes(); + } } diff --git a/intercom_flutter/pubspec.yaml b/intercom_flutter/pubspec.yaml index 772d4c86..8d9fede8 100644 --- a/intercom_flutter/pubspec.yaml +++ b/intercom_flutter/pubspec.yaml @@ -1,7 +1,7 @@ name: intercom_flutter description: Flutter plugin for Intercom integration. Provides in-app messaging and help-center Intercom services -version: 9.1.1 +version: 9.2.0 homepage: https://github.com/v3rm0n/intercom_flutter dependencies: @@ -9,8 +9,8 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter - intercom_flutter_platform_interface: ^2.0.1 - intercom_flutter_web: ^1.1.3 + intercom_flutter_platform_interface: ^2.0.2 + intercom_flutter_web: ^1.1.4 dev_dependencies: flutter_test: diff --git a/intercom_flutter_platform_interface/CHANGELOG.md b/intercom_flutter_platform_interface/CHANGELOG.md index 03010529..fa4e7b51 100755 --- a/intercom_flutter_platform_interface/CHANGELOG.md +++ b/intercom_flutter_platform_interface/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 2.0.2 + +* Added method `isUserLoggedIn`. +* Added method `fetchLoggedInUserAttributes`. + ## 2.0.1 * Added method `displayHome`. diff --git a/intercom_flutter_platform_interface/lib/intercom_flutter_platform_interface.dart b/intercom_flutter_platform_interface/lib/intercom_flutter_platform_interface.dart index 1ecac9ab..9065fd32 100644 --- a/intercom_flutter_platform_interface/lib/intercom_flutter_platform_interface.dart +++ b/intercom_flutter_platform_interface/lib/intercom_flutter_platform_interface.dart @@ -267,4 +267,15 @@ abstract class IntercomFlutterPlatform extends PlatformInterface { Future displayHome() { throw UnimplementedError('displayHome() has not been implemented.'); } + + /// Determine if a user is currently logged in to Intercom. + Future isUserLoggedIn() { + throw UnimplementedError('isUserLoggedIn() has not been implemented.'); + } + + /// Retrieve the details of the currently logged in user. + Future> fetchLoggedInUserAttributes() { + throw UnimplementedError( + 'fetchLoggedInUserAttributes() has not been implemented.'); + } } diff --git a/intercom_flutter_platform_interface/lib/method_channel_intercom_flutter.dart b/intercom_flutter_platform_interface/lib/method_channel_intercom_flutter.dart index 430ba925..43ab113b 100644 --- a/intercom_flutter_platform_interface/lib/method_channel_intercom_flutter.dart +++ b/intercom_flutter_platform_interface/lib/method_channel_intercom_flutter.dart @@ -241,6 +241,18 @@ class MethodChannelIntercomFlutter extends IntercomFlutterPlatform { await _channel.invokeMethod('displayHome'); } + @override + Future isUserLoggedIn() async { + return await _channel.invokeMethod('isUserLoggedIn') ?? false; + } + + @override + Future> fetchLoggedInUserAttributes() async { + var attributes = Map.from( + await _channel.invokeMethod('fetchLoggedInUserAttributes') ?? {}); + return attributes; + } + /// 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]. diff --git a/intercom_flutter_platform_interface/pubspec.yaml b/intercom_flutter_platform_interface/pubspec.yaml index bf1a5218..0e086936 100644 --- a/intercom_flutter_platform_interface/pubspec.yaml +++ b/intercom_flutter_platform_interface/pubspec.yaml @@ -1,6 +1,6 @@ name: intercom_flutter_platform_interface description: A common platform interface for the intercom_flutter plugin. -version: 2.0.1 +version: 2.0.2 homepage: https://github.com/v3rm0n/intercom_flutter dependencies: diff --git a/intercom_flutter_platform_interface/test/method_channel_intercom_flutter_test.dart b/intercom_flutter_platform_interface/test/method_channel_intercom_flutter_test.dart index 76a57392..f5dae9cf 100644 --- a/intercom_flutter_platform_interface/test/method_channel_intercom_flutter_test.dart +++ b/intercom_flutter_platform_interface/test/method_channel_intercom_flutter_test.dart @@ -439,6 +439,22 @@ void main() { [isMethodCall('displayHome', arguments: null)], ); }); + + test('isUserLoggedIn', () async { + await intercom.isUserLoggedIn(); + expect( + log, + [isMethodCall('isUserLoggedIn', arguments: null)], + ); + }); + + test('fetchLoggedInUserAttributes', () async { + await intercom.fetchLoggedInUserAttributes(); + expect( + log, + [isMethodCall('fetchLoggedInUserAttributes', arguments: null)], + ); + }); }); } diff --git a/intercom_flutter_web/CHANGELOG.md b/intercom_flutter_web/CHANGELOG.md index d14983ca..7807dc3e 100755 --- a/intercom_flutter_web/CHANGELOG.md +++ b/intercom_flutter_web/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.1.4 + +* Updated dependency `intercom_flutter_platform_interface: ^2.0.2`. + ## 1.1.3 * Implemented method `displayHome`. diff --git a/intercom_flutter_web/README.md b/intercom_flutter_web/README.md index c8e14acc..c7a9dec9 100755 --- a/intercom_flutter_web/README.md +++ b/intercom_flutter_web/README.md @@ -26,6 +26,8 @@ But you can pre-define some Intercom settings, if you want (optional). - handlePush - displayCarousel - displayHelpCenterCollections +- isUserLoggedIn +- fetchLoggedInUserAttributes [1]: ../intercom_flutter diff --git a/intercom_flutter_web/pubspec.yaml b/intercom_flutter_web/pubspec.yaml index 56689e4c..a649ce79 100644 --- a/intercom_flutter_web/pubspec.yaml +++ b/intercom_flutter_web/pubspec.yaml @@ -1,6 +1,6 @@ name: intercom_flutter_web description: Web platform implementation of intercom_flutter -version: 1.1.3 +version: 1.1.4 homepage: https://github.com/v3rm0n/intercom_flutter flutter: @@ -15,7 +15,7 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter - intercom_flutter_platform_interface: ^2.0.1 + intercom_flutter_platform_interface: ^2.0.2 uuid: ^4.2.1 # to get the random uuid for loginUnidentifiedUser in web web: ^1.0.0