Skip to content

Commit

Permalink
Update intercom-android 15.11.1 and intercom-ios 18.2.0 (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepak786 authored Nov 13, 2024
1 parent f2fe4de commit 9e65d58
Show file tree
Hide file tree
Showing 17 changed files with 120 additions and 11 deletions.
7 changes: 7 additions & 0 deletions intercom_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions intercom_flutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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`

Expand Down
2 changes: 1 addition & 1 deletion intercom_flutter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Any>()
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()
}
}
Expand Down
2 changes: 1 addition & 1 deletion intercom_flutter/example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
27 changes: 27 additions & 0 deletions intercom_flutter/ios/Classes/IntercomFlutterPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -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<NSString *, id> *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);
Expand Down
2 changes: 1 addition & 1 deletion intercom_flutter/ios/intercom_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions intercom_flutter/lib/intercom_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,14 @@ class Intercom {
Future<void> displayHome() {
return IntercomFlutterPlatform.instance.displayHome();
}

/// Determine if a user is currently logged in to Intercom.
Future<bool> isUserLoggedIn() {
return IntercomFlutterPlatform.instance.isUserLoggedIn();
}

/// Retrieve the details of the currently logged in user.
Future<Map<String, dynamic>> fetchLoggedInUserAttributes() {
return IntercomFlutterPlatform.instance.fetchLoggedInUserAttributes();
}
}
6 changes: 3 additions & 3 deletions intercom_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
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:
flutter:
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:
Expand Down
5 changes: 5 additions & 0 deletions intercom_flutter_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 2.0.2

* Added method `isUserLoggedIn`.
* Added method `fetchLoggedInUserAttributes`.

## 2.0.1

* Added method `displayHome`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,15 @@ abstract class IntercomFlutterPlatform extends PlatformInterface {
Future<void> displayHome() {
throw UnimplementedError('displayHome() has not been implemented.');
}

/// Determine if a user is currently logged in to Intercom.
Future<bool> isUserLoggedIn() {
throw UnimplementedError('isUserLoggedIn() has not been implemented.');
}

/// Retrieve the details of the currently logged in user.
Future<Map<String, dynamic>> fetchLoggedInUserAttributes() {
throw UnimplementedError(
'fetchLoggedInUserAttributes() has not been implemented.');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,18 @@ class MethodChannelIntercomFlutter extends IntercomFlutterPlatform {
await _channel.invokeMethod('displayHome');
}

@override
Future<bool> isUserLoggedIn() async {
return await _channel.invokeMethod<bool>('isUserLoggedIn') ?? false;
}

@override
Future<Map<String, dynamic>> fetchLoggedInUserAttributes() async {
var attributes = Map<String, dynamic>.from(
await _channel.invokeMethod<Map>('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].
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.1
version: 2.0.2
homepage: https://github.com/v3rm0n/intercom_flutter

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

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

test('fetchLoggedInUserAttributes', () async {
await intercom.fetchLoggedInUserAttributes();
expect(
log,
<Matcher>[isMethodCall('fetchLoggedInUserAttributes', 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.4

* Updated dependency `intercom_flutter_platform_interface: ^2.0.2`.

## 1.1.3

* Implemented method `displayHome`.
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 @@ -26,6 +26,8 @@ But you can pre-define some Intercom settings, if you want (optional).
- handlePush
- displayCarousel
- displayHelpCenterCollections
- isUserLoggedIn
- fetchLoggedInUserAttributes

[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.3
version: 1.1.4
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.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

Expand Down

0 comments on commit 9e65d58

Please sign in to comment.