Skip to content

Commit 1f31b06

Browse files
committed
Pull request #97: Ffortes MCA-4564 iOS 13 and Chat example improvements
Merge in MML/infobip-mobile-messaging-flutter from ffortes-MCA-4564-DemoChatImprovements to main Squashed commit of the following: commit 783d16f4c03a6dfb05cadfc1edd465859dbc2306 Author: Francisco Fortes <[email protected]> Date: Wed Mar 26 15:40:25 2025 +0100 reorganized imports commit a27ff78f10bda1ffc676d3a32a43e2f928c9d771 Author: Francisco Fortes <[email protected]> Date: Wed Mar 26 13:29:07 2025 +0100 fix in tabulation commit c8fb3bf2c977dcbaf99fd2c240c334e7c509f556 Author: Francisco Fortes <[email protected]> Date: Wed Mar 26 13:20:54 2025 +0100 mmVersion updated commit 88897598b21fd5ac78b4d55b911d52b3c00d81b4 Author: Francisco Fortes <[email protected]> Date: Wed Mar 26 11:32:41 2025 +0100 Readme changed commit 7a67ff4610b013e87ae56f4617a31cca26b4752e Author: Francisco Fortes <[email protected]> Date: Wed Mar 26 11:10:27 2025 +0100 iOS 12 cleanup commit df8db10da2eafef07ace2debd45e7f70582bea96 Author: Francisco Fortes <[email protected]> Date: Wed Mar 26 10:51:00 2025 +0100 MCA-4564 Chat options in a single dialog + shouldHandleKeyboardAppearance moved to chat customization commit 63f79ca97e00c756425fe97d86ad9c41b3571586 Author: Francisco Fortes <[email protected]> Date: Tue Mar 25 13:08:13 2025 +0100 MCA-4564 sorting out chat content in the example app
1 parent 415ae9d commit 1f31b06

16 files changed

+286
-143
lines changed

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The document describes plugin integration steps for your Flutter project.
1111

1212
For iOS project:
1313
- Xcode 16.x
14-
- Minimum deployment target 12.0
14+
- Minimum deployment target 13.0
1515

1616
For Android project:
1717
- Android Studio
@@ -42,7 +42,7 @@ $ pub get infobip_mobilemessaging
4242
4. Configure platforms
4343

4444
- **iOS**
45-
1. Update the `ios/Podfile` with iOS deployment target platform 12.0 - `platform :ios, '12.0'` if needed, and perform in Terminal `cd ios && pod update `
45+
1. Update the `ios/Podfile` with iOS deployment target platform 13.0 - `platform :ios, '13.0'` if needed, and perform in Terminal `cd ios && pod update `
4646
2. Import MobileMessaging `@import MobileMessaging;` and add `[MobileMessagingPluginApplicationDelegate install];` into `<ProjectName>/ios/Runner/AppDelegate.m` (this is required for OS callbacks such as `didRegisterForRemoteNotifications` to be intercepted by native MobileMessaging SDK) :
4747
```objc
4848
...

Diff for: example/ios/Podfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Uncomment this line to define a global platform for your project
2-
platform :ios, '12.0'
2+
platform :ios, '13.0'
33
$WebRTCUIEnabled = true
44

55
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.

Diff for: example/ios/Runner.xcodeproj/project.pbxproj

+9-9
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@
497497
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
498498
GCC_WARN_UNUSED_FUNCTION = YES;
499499
GCC_WARN_UNUSED_VARIABLE = YES;
500-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
500+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
501501
MTL_ENABLE_DEBUG_INFO = NO;
502502
OTHER_SWIFT_FLAGS = "";
503503
SDKROOT = iphoneos;
@@ -524,7 +524,7 @@
524524
"COCOAPODS=1",
525525
);
526526
INFOPLIST_FILE = Runner/Info.plist;
527-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
527+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
528528
LD_RUNPATH_SEARCH_PATHS = (
529529
"$(inherited)",
530530
"@executable_path/Frameworks",
@@ -546,7 +546,7 @@
546546
CODE_SIGN_ENTITLEMENTS = "$(PROJECT_DIR)/MobileMessagingNotificationExtension.entitlements";
547547
DEVELOPMENT_TEAM = T6U248P7YM;
548548
INFOPLIST_FILE = "$(PROJECT_DIR)/NotificationExtension/MobileMessagingNotificationServiceExtension.plist";
549-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
549+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
550550
LD_RUNPATH_SEARCH_PATHS = "@executable_path/../../Frameworks";
551551
PRODUCT_BUNDLE_IDENTIFIER = "org.infobip.plugins.mobilemessaging.flutter.notification-extension";
552552
PRODUCT_NAME = MobileMessagingNotificationExtension;
@@ -564,7 +564,7 @@
564564
CODE_SIGN_ENTITLEMENTS = "$(PROJECT_DIR)/MobileMessagingNotificationExtension.entitlements";
565565
DEVELOPMENT_TEAM = T6U248P7YM;
566566
INFOPLIST_FILE = "$(PROJECT_DIR)/NotificationExtension/MobileMessagingNotificationServiceExtension.plist";
567-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
567+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
568568
LD_RUNPATH_SEARCH_PATHS = "@executable_path/../../Frameworks";
569569
PRODUCT_BUNDLE_IDENTIFIER = "org.infobip.plugins.mobilemessaging.flutter.notification-extension";
570570
PRODUCT_NAME = MobileMessagingNotificationExtension;
@@ -618,7 +618,7 @@
618618
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
619619
GCC_WARN_UNUSED_FUNCTION = YES;
620620
GCC_WARN_UNUSED_VARIABLE = YES;
621-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
621+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
622622
MTL_ENABLE_DEBUG_INFO = YES;
623623
ONLY_ACTIVE_ARCH = YES;
624624
OTHER_SWIFT_FLAGS = "";
@@ -669,7 +669,7 @@
669669
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
670670
GCC_WARN_UNUSED_FUNCTION = YES;
671671
GCC_WARN_UNUSED_VARIABLE = YES;
672-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
672+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
673673
MTL_ENABLE_DEBUG_INFO = NO;
674674
OTHER_SWIFT_FLAGS = "";
675675
SDKROOT = iphoneos;
@@ -698,7 +698,7 @@
698698
"COCOAPODS=1",
699699
);
700700
INFOPLIST_FILE = Runner/Info.plist;
701-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
701+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
702702
LD_RUNPATH_SEARCH_PATHS = (
703703
"$(inherited)",
704704
"@executable_path/Frameworks",
@@ -731,7 +731,7 @@
731731
"COCOAPODS=1",
732732
);
733733
INFOPLIST_FILE = Runner/Info.plist;
734-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
734+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
735735
LD_RUNPATH_SEARCH_PATHS = (
736736
"$(inherited)",
737737
"@executable_path/Frameworks",
@@ -753,7 +753,7 @@
753753
CODE_SIGN_ENTITLEMENTS = "$(PROJECT_DIR)/MobileMessagingNotificationExtension.entitlements";
754754
DEVELOPMENT_TEAM = T6U248P7YM;
755755
INFOPLIST_FILE = "$(PROJECT_DIR)/NotificationExtension/MobileMessagingNotificationServiceExtension.plist";
756-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
756+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
757757
LD_RUNPATH_SEARCH_PATHS = "@executable_path/../../Frameworks";
758758
PRODUCT_BUNDLE_IDENTIFIER = "org.infobip.plugins.mobilemessaging.flutter.notification-extension";
759759
PRODUCT_NAME = MobileMessagingNotificationExtension;

Diff for: example/lib/chat_customization.dart

+2
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,6 @@ Object customBranding = mmconfiguration.ChatCustomization(
5454
chatInputSeparatorLineColor: '#BDBDBD',
5555
chatInputSeparatorLineVisible: true,
5656
chatInputCursorColor: '#9E9E9E',
57+
shouldHandleKeyboardAppearance: true,
5758
);
59+

Diff for: example/lib/chat_examples.dart

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
import 'dart:developer';
2+
import 'dart:io';
3+
4+
import 'package:flutter/material.dart';
5+
import 'package:flutter/services.dart';
6+
import 'package:infobip_mobilemessaging/infobip_mobilemessaging.dart';
7+
import 'package:infobip_mobilemessaging/models/configurations/configuration.dart' as mmconf;
8+
9+
import '../chat_customization.dart' as chat_customization;
10+
import '../main.dart';
11+
import '../utils/language.dart';
12+
import '../screens/screen_chat_view.dart';
13+
import '../screens/screen_chat_safearea.dart';
14+
15+
class ChatExamples {
16+
17+
static Future<void> handleKeyboardAppearance(bool isHandledNatively) async {
18+
if (Platform.isIOS) {
19+
Object customization = mmconf.ChatCustomization(
20+
shouldHandleKeyboardAppearance: isHandledNatively,
21+
);
22+
InfobipMobilemessaging.setChatCustomization(customization);
23+
}
24+
}
25+
26+
static showChatExamplesDialog(BuildContext context) {
27+
final children = <Widget>[
28+
SimpleDialogOption(
29+
child: Text('Show chat screen'),
30+
onPressed: () {
31+
// InfobipMobilemessaging.setJwt('your JWT'); // Comment out to automatically log-in using authentication
32+
handleKeyboardAppearance(true);
33+
InfobipMobilemessaging.showChat();
34+
},
35+
),
36+
SimpleDialogOption(
37+
child: Text('Show chat screen customized'),
38+
onPressed: () {
39+
InfobipMobilemessaging.setChatCustomization(
40+
chat_customization.customBranding,
41+
);
42+
InfobipMobilemessaging.setWidgetTheme('dark');
43+
InfobipMobilemessaging.showChat();
44+
},
45+
),
46+
SimpleDialogOption(
47+
child: Text('Set Chat Language'),
48+
onPressed: () {
49+
ChatExamples.showChatLanguageDialog(context);
50+
},
51+
),
52+
SimpleDialogOption(
53+
child: Text('Show Chat View Only'),
54+
onPressed: () {
55+
handleKeyboardAppearance(false);
56+
ChatExamples.showChatViewOnlyDialog(context, false);
57+
},
58+
),
59+
SimpleDialogOption(
60+
child: Text('Show Chat View With SafeArea'),
61+
onPressed: () {
62+
handleKeyboardAppearance(false);
63+
ChatExamples.showChatViewOnlyDialog(context, true);
64+
},
65+
),
66+
SimpleDialogOption(
67+
child: Text('Enable calls'),
68+
onPressed: () {
69+
log('Enabling calls');
70+
try {
71+
InfobipMobilemessaging.enableChatCalls();
72+
} catch (e) {
73+
log('Failed to enable calls. $e');
74+
}
75+
},
76+
),
77+
SimpleDialogOption(
78+
child: Text('Disable calls'),
79+
onPressed: () {
80+
log('Disabling calls');
81+
try {
82+
InfobipMobilemessaging.disableCalls();
83+
} catch (e) {
84+
log('Failed to disable calls. $e');
85+
}
86+
},
87+
),
88+
];
89+
90+
SimpleDialog dialog = SimpleDialog(
91+
title: const Text('Choose Chat Example'),
92+
children: children,
93+
);
94+
95+
showDialog(
96+
context: context,
97+
builder: (BuildContext context) => dialog,
98+
);
99+
}
100+
101+
static showChatLanguageDialog(BuildContext context) {
102+
final children = <Widget>[];
103+
104+
// Languages imported from utils/languages
105+
for (var language in languages) {
106+
children.add(
107+
SimpleDialogOption(
108+
child: Text(language.name),
109+
onPressed: () {
110+
InfobipMobilemessaging.setLanguage(language.code);
111+
Navigator.pop(context, true);
112+
},
113+
),
114+
);
115+
}
116+
117+
// set up the SimpleDialog
118+
SimpleDialog dialog = SimpleDialog(
119+
title: const Text('Choose Chat Language'),
120+
children: children,
121+
);
122+
123+
// show chat languages dialog
124+
showDialog(
125+
context: context,
126+
builder: (BuildContext context) => dialog,
127+
);
128+
}
129+
130+
static showChatViewOnlyDialog(BuildContext context, bool withSafeArea) {
131+
final children = <Widget>[];
132+
133+
if (withSafeArea) {
134+
showDialog(
135+
context: context,
136+
builder: (BuildContext context) => const ChatViewDemoSafeArea(),
137+
);
138+
} else {
139+
showDialog(
140+
context: context,
141+
builder: (BuildContext context) => const ChatViewDemo(),
142+
);
143+
}
144+
}
145+
}

Diff for: example/lib/main.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
2222

2323
final mmconf.Configuration ibConfig = mmconf.Configuration(
2424
applicationCode: 'your_app_code',
25-
inAppChatEnabled: false,
25+
inAppChatEnabled: true,
2626
fullFeaturedInAppsEnabled: true,
2727
defaultMessageStorage: true,
2828
androidSettings: mmconf.AndroidSettings(

Diff for: example/lib/screens/homepage.dart

+7-84
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import '../main.dart';
1414
import '../utils/language.dart';
1515
import '../widgets/demo_tile.dart';
1616
import '../widgets/page.dart';
17+
import '../chat_examples.dart';
1718

1819
class HomePage extends StatefulWidget {
1920
const HomePage({super.key});
@@ -275,35 +276,6 @@ class _HomePageState extends State<HomePage> {
275276
_showDialog('Deleted First', str);
276277
}
277278

278-
showChatLanguageDialog(BuildContext context) {
279-
final children = <Widget>[];
280-
281-
// Languages imported from utils/languages
282-
for (var language in languages) {
283-
children.add(
284-
SimpleDialogOption(
285-
child: Text(language.name),
286-
onPressed: () {
287-
InfobipMobilemessaging.setLanguage(language.code);
288-
Navigator.pop(context, true);
289-
},
290-
),
291-
);
292-
}
293-
294-
// set up the SimpleDialog
295-
SimpleDialog dialog = SimpleDialog(
296-
title: const Text('Choose Chat Language'),
297-
children: children,
298-
);
299-
300-
// show chat languages dialog
301-
showDialog(
302-
context: context,
303-
builder: (BuildContext context) => dialog,
304-
);
305-
}
306-
307279
@override
308280
Widget build(BuildContext context) => Scaffold(
309281
appBar: AppBar(
@@ -312,6 +284,12 @@ class _HomePageState extends State<HomePage> {
312284
body: ListView(
313285
children: [
314286
...pages.map((d) => DemoTile(demo: d)),
287+
ListTile(
288+
title: const Text('Chat Examples'),
289+
onTap: () {
290+
ChatExamples.showChatExamplesDialog(context);
291+
},
292+
),
315293
ListTile(
316294
title: const Text('Depersonalize'),
317295
onTap: () {
@@ -378,39 +356,6 @@ class _HomePageState extends State<HomePage> {
378356
_showDialog('Library Events', _getLibraryEvents());
379357
},
380358
),
381-
ListTile(
382-
title: const Text('Set Chat Language'),
383-
onTap: () {
384-
showChatLanguageDialog(context);
385-
},
386-
),
387-
ListTile(
388-
title: const Text('Show chat screen'),
389-
onTap: () {
390-
// InfobipMobilemessaging.setJwt('your JWT'); // Comment out to automatically log-in using authentication
391-
InfobipMobilemessaging.showChat();
392-
},
393-
),
394-
ListTile(
395-
title: const Text('Show chat screen customized'),
396-
onTap: () {
397-
InfobipMobilemessaging.setChatCustomization(
398-
chat_customization.customBranding,
399-
);
400-
InfobipMobilemessaging.setWidgetTheme('dark');
401-
InfobipMobilemessaging.showChat();
402-
},
403-
),
404-
ListTile(
405-
title: const Text('Send Contextual Data and Show chat screen'),
406-
onTap: () {
407-
InfobipMobilemessaging.sendContextualDataWithStrategy(
408-
"{ demoKey: 'InAppChat Metadata Value' }",
409-
ChatMultithreadStrategies.ACTIVE,
410-
);
411-
InfobipMobilemessaging.showChat();
412-
},
413-
),
414359
ListTile(
415360
title: const Text('Send Event'),
416361
onTap: () {
@@ -477,28 +422,6 @@ class _HomePageState extends State<HomePage> {
477422
_showDialog('DeleteAll', 'All messages deleted');
478423
},
479424
),
480-
ListTile(
481-
title: const Text('Enable calls'),
482-
onTap: () {
483-
log('Enabling calls');
484-
try {
485-
InfobipMobilemessaging.enableChatCalls();
486-
} catch (e) {
487-
log('Failed to enable calls. $e');
488-
}
489-
},
490-
),
491-
ListTile(
492-
title: const Text('Disable calls'),
493-
onTap: () {
494-
log('Disabling calls');
495-
try {
496-
InfobipMobilemessaging.disableCalls();
497-
} catch (e) {
498-
log('Failed to disable calls. $e');
499-
}
500-
},
501-
),
502425
],
503426
),
504427
);

0 commit comments

Comments
 (0)