Skip to content

Commit dc141cb

Browse files
committed
Pull request #98: aboldyrev MM-7257 androidsounds
Merge in MML/infobip-mobile-messaging-flutter from aboldyrev/MM-7257-androidsounds to main Squashed commit of the following: commit 26062dd216ed30aeba0a60c52dd1a5c4be6b34da Author: Alexander Boldyrev <alexander.boldyrev@infobip.com> Date: Tue Apr 8 17:32:56 2025 +0300 custom notification channel
1 parent d929446 commit dc141cb

File tree

7 files changed

+49
-6
lines changed

7 files changed

+49
-6
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ android {
3131
}
3232

3333
dependencies {
34-
def mmVersion = '13.9.1'
34+
def mmVersion = '13.9.3'
3535
//flutter and mm dependencies clash
3636
implementation ("org.jetbrains.kotlin:kotlin-stdlib-jdk8") {
3737
version {

android/src/main/java/org/infobip/plugins/mobilemessaging/flutter/common/Configuration.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public void setConfigurationId(String configurationId) {
3131

3232
public static class AndroidSettings {
3333
String notificationIcon;
34+
String notificationChannelId;
35+
String notificationChannelName;
36+
String notificationSound;
3437
boolean multipleNotifications;
3538
String notificationAccentColor;
3639
FirebaseOptions firebaseOptions;
@@ -43,6 +46,18 @@ public void setNotificationIcon(String notificationIcon) {
4346
this.notificationIcon = notificationIcon;
4447
}
4548

49+
public String getNotificationChannelId() {
50+
return notificationChannelId;
51+
}
52+
53+
public String getNotificationChannelName() {
54+
return notificationChannelName;
55+
}
56+
57+
public String getNotificationSound() {
58+
return notificationSound;
59+
}
60+
4661
public boolean isMultipleNotifications() {
4762
return multipleNotifications;
4863
}

android/src/main/java/org/infobip/plugins/mobilemessaging/flutter/common/InitHelper.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,20 @@ public MobileMessaging.Builder configurationBuilder() {
8282
if (androidSettings != null && androidSettings.isMultipleNotifications()) {
8383
notificationBuilder.withMultipleNotifications();
8484
}
85+
8586
if (androidSettings != null && androidSettings.getNotificationAccentColor() != null) {
8687
int color = Color.parseColor(androidSettings.getNotificationAccentColor());
8788
notificationBuilder.withColor(color);
8889
}
8990

91+
if (androidSettings != null && androidSettings.getNotificationChannelId() != null && !androidSettings.getNotificationChannelId().isEmpty()
92+
&& androidSettings.getNotificationChannelName() != null && !androidSettings.getNotificationChannelName().isEmpty()
93+
&& androidSettings.getNotificationSound() != null && !androidSettings.getNotificationSound().isEmpty()) {
94+
builder.withCustomNotificationChannel(androidSettings.getNotificationChannelId(),
95+
androidSettings.getNotificationChannelName(),
96+
androidSettings.getNotificationSound());
97+
}
98+
9099
if (configuration.isInAppChatEnabled()) {
91100
InAppChat chat = InAppChat.getInstance(context);
92101
chat.activate();

android/src/main/java/org/infobip/plugins/mobilemessaging/flutter/infobip_mobilemessaging/InfobipMobilemessagingPlugin.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
import org.infobip.mobile.messaging.SuccessPending;
3636
import org.infobip.mobile.messaging.User;
3737
import org.infobip.mobile.messaging.chat.InAppChat;
38-
import org.infobip.mobile.messaging.chat.core.widget.LivechatWidgetLanguage;
3938
import org.infobip.mobile.messaging.chat.core.InAppChatEvent;
39+
import org.infobip.mobile.messaging.chat.core.MultithreadStrategy;
40+
import org.infobip.mobile.messaging.chat.core.widget.LivechatWidgetLanguage;
4041
import org.infobip.mobile.messaging.inbox.Inbox;
4142
import org.infobip.mobile.messaging.inbox.InboxMapper;
4243
import org.infobip.mobile.messaging.inbox.MobileInbox;
@@ -65,7 +66,6 @@
6566
import org.json.JSONArray;
6667
import org.json.JSONException;
6768
import org.json.JSONObject;
68-
import org.infobip.mobile.messaging.chat.core.MultithreadStrategy;
6969

7070
import java.util.ArrayList;
7171
import java.util.Arrays;
@@ -557,9 +557,7 @@ public void onResult(org.infobip.mobile.messaging.mobileapi.Result<User, MobileM
557557
}
558558
}
559559
});
560-
} catch (IllegalArgumentException e) {
561-
resultCallbacks.error(ErrorCodes.PERSONALIZE.getErrorCode(), e.getMessage(), e.getLocalizedMessage());
562-
} catch (JSONException e) {
560+
} catch (IllegalArgumentException | JSONException e) {
563561
resultCallbacks.error(ErrorCodes.PERSONALIZE.getErrorCode(), e.getMessage(), e.getLocalizedMessage());
564562
}
565563
}

lib/models/configurations/configuration.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ class AndroidSettings {
7777
/// A resource name for a status bar icon (without extension), located in '/platforms/android/app/src/main/res/mipmap'
7878
final String? notificationIcon;
7979

80+
/// Custom notification channel ID.
81+
final String? notificationChannelId;
82+
83+
/// Custom notification channel name.
84+
final String? notificationChannelName;
85+
86+
/// A resource name for the custom sound name (without extension), located in '/android/app/src/main/res/raw'
87+
final String? notificationSound;
88+
8089
/// Should multiple notifications in status bar be shown. By default only the latest notification is shown.
8190
final bool? multipleNotifications;
8291

@@ -87,6 +96,9 @@ class AndroidSettings {
8796
AndroidSettings({
8897
this.firebaseOptions,
8998
this.notificationIcon,
99+
this.notificationChannelId,
100+
this.notificationChannelName,
101+
this.notificationSound,
90102
this.multipleNotifications,
91103
this.notificationAccentColor,
92104
});
@@ -95,6 +107,9 @@ class AndroidSettings {
95107
Map<String, dynamic> toJson() => {
96108
'firebaseOptions': firebaseOptions?.toJson(),
97109
'notificationIcon': notificationIcon,
110+
'notificationChannelId': notificationChannelId,
111+
'notificationChannelName': notificationChannelName,
112+
'notificationSound': notificationSound,
98113
'multipleNotifications': multipleNotifications,
99114
'notificationAccentColor': notificationAccentColor,
100115
};

test/utils/json_test_stubs.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Map<String, dynamic> get configurationExampleJson => {
1313
'gcmSenderId': null,
1414
'storageBucket': null,
1515
},
16+
'notificationChannelId': 'custom-notification-channel-id',
17+
'notificationChannelName': 'Custom Name',
18+
'notificationSound': 'mewmewpewpew',
1619
'notificationIcon': 'icon.png',
1720
'multipleNotifications': true,
1821
'notificationAccentColor': '#ABCDEF',

test/utils/models_examples.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Configuration get configurationModelExample => Configuration(
1616
projectId: 'project-123ab',
1717
),
1818
notificationIcon: 'icon.png',
19+
notificationChannelId: 'custom-notification-channel-id',
20+
notificationChannelName: 'Custom Name',
21+
notificationSound: 'mewmewpewpew',
1922
multipleNotifications: true,
2023
notificationAccentColor: '#ABCDEF',
2124
),

0 commit comments

Comments
 (0)