Skip to content

Commit

Permalink
Pull request #77: Jdzubak MCA-4071 contextual data
Browse files Browse the repository at this point in the history
Merge in MML/infobip-mobile-messaging-flutter from jdzubak-MCA-4071-contextual-data to main

Squashed commit of the following:

commit 91f0ec38125e6c931477934d7d39d490c3b7927c
Author: Maksym Svitlovskyi <[email protected]>
Date:   Wed Jul 31 14:26:30 2024 +0200

    Send contextual data - iOS part

commit da30e84b5588b5f378c8d1294cfc77b8d1fc6d92
Author: Jakub Dzubak <[email protected]>
Date:   Mon Jul 29 14:10:37 2024 +0200

    MCA-4086 Send contextual data - Android part

commit c7cf213981acbf62c57ba898611d94bf46f8e661
Author: Jakub Dzubak <[email protected]>
Date:   Mon Jul 29 13:33:17 2024 +0200

    MCA-4086 Send contextual data - Android part
  • Loading branch information
Svitlovskyi committed Aug 1, 2024
1 parent c61c4f3 commit 3972cb8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ android {
def withWebRTCUI = getRootProjectProperty('withWebRTCUI', false)

dependencies {
def mmVersion = '12.8.0'
def mmVersion = '12.9.0'
//flutter and mm dependencies clash
implementation ("org.jetbrains.kotlin:kotlin-stdlib-jdk8") {
version {
Expand Down
8 changes: 2 additions & 6 deletions example/lib/screens/homepage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,9 @@ class _HomePageState extends State<HomePage> {
},
),
ListTile(
title: const Text('Show chat screen and Send Contextual Data'),
title: const Text('Send Contextual Data and Show chat screen'),
onTap: () {
Future.delayed(const Duration(milliseconds: 3000), () {
// Metadata must be sent after chat is presented, so we delay it
InfobipMobilemessaging.sendContextualData(
"{ demoKey: 'InAppChat Metadata Value' }", false);
});
InfobipMobilemessaging.sendContextualData("{ demoKey: 'InAppChat Metadata Value' }", false);
InfobipMobilemessaging.showChat();
},
),
Expand Down
6 changes: 5 additions & 1 deletion ios/Classes/SwiftInfobipMobilemessagingPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ public class SwiftInfobipMobilemessagingPlugin: NSObject, FlutterPlugin {
message: "Cannot resolve data or allMultiThreadStrategy from arguments",
details: nil ))
}

if let chatVc = SwiftInfobipMobilemessagingPlugin.chatVC {
chatVc.sendContextualData(data, multiThreadStrategy: multiThreadStrategy ? .ALL : .ACTIVE) { error in
if let error = error {
Expand All @@ -527,8 +528,11 @@ public class SwiftInfobipMobilemessagingPlugin: NSObject, FlutterPlugin {
return result(Constants.resultSuccess)
}
}
} else if let inAppChat = MobileMessaging.inAppChat {
inAppChat.sendContextualData(data, multiThreadStrategy: multiThreadStrategy ? .ALL : .ACTIVE)
return result(Constants.resultSuccess)
} else {
MMLogDebug("[InAppChat] could find chat view controller to send contextual data to")
MMLogDebug("[InAppChat] Cannot send context data, inAppChat service does not exist and ChatViewController is not present.")
}
}

Expand Down
10 changes: 5 additions & 5 deletions ios/infobip_mobilemessaging.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ A new flutter plugin project.
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.dependency "MobileMessaging/Core", "12.9.0"
s.dependency "MobileMessaging/Geofencing", "12.9.0"
s.dependency "MobileMessaging/InAppChat", "12.9.0"
s.dependency "MobileMessaging/Inbox", "12.9.0"
s.dependency "MobileMessaging/Core", "12.10.0"
s.dependency "MobileMessaging/Geofencing", "12.10.0"
s.dependency "MobileMessaging/InAppChat", "12.10.0"
s.dependency "MobileMessaging/Inbox", "12.10.0"
if defined?($WebRTCUIEnabled)
s.dependency "MobileMessaging/WebRTCUI", "12.9.0"
s.dependency "MobileMessaging/WebRTCUI", "12.10.0"
end
s.platform = :ios, '12.0'

Expand Down
3 changes: 3 additions & 0 deletions lib/chat_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ class ChatViewController {
}

/// Set contextual data of the chat.
/// If the function is called when the chat is loaded data will be sent immediately, otherwise they will be sent to the chat once it is loaded.
/// Every function invocation will overwrite the previous contextual data.
/// See [ChatViewEvent.chatLoaded] to detect if chat is loaded.
/// Parameter [data] in JSON string format
/// Parameter [allMultiThreadStrategy] multithread strategy flag, true -> ALL, false -> ACTIVE
void sendContextualData(String data, bool allMultiThreadStrategy) async {
Expand Down
5 changes: 5 additions & 0 deletions lib/models/chat_view_event.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
///ChatView events you can observer and react to.
///To listen to event you need to register:
///```dart
///ChatViewController.on(ChatViewEvent.chatLoaded, (bool controlsEnabled) => {});
///```
class ChatViewEvent {
final String eventName;

Expand Down

0 comments on commit 3972cb8

Please sign in to comment.