Skip to content

Commit ff0aa00

Browse files
MaikuBmattbajorek
andauthored
[flutter_local_notifications] added retrieval of dataMimeType and dataUri for active Android messaging style notification (#2661)
* Add dataMimeType and dataUri for Android * updated example app to read dataMimeType and dataUri of active message style notification * prepare for 19.4.0 release --------- Co-authored-by: Matthew Bajorek <[email protected]>
1 parent 56fbd45 commit ff0aa00

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

flutter_local_notifications/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [19.4.0]
2+
3+
* [Android] added ability to read `dataMimeType` and `dataUri` when calling `getActiveNotifications()` to read details of an active Android notification using the messaging style. Thanks to the PR from [Matt Bajorek](https://github.com/mattbajorek)
4+
15
## [19.3.1]
26

37
* [Windows] fixed issue [#2648](https://github.com/MaikuB/flutter_local_notifications/issues/2648) where non-ASCII characters in the notification payload were not being handled properly. Thanks to the PR from [yoyoIU](https://github.com/yoyo930021)

flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,7 @@ private void getActiveNotifications(Result result) {
16141614
activeNotificationPayload.put("body", notification.extras.getCharSequence("android.text"));
16151615
activeNotificationPayload.put(
16161616
"bigText", notification.extras.getCharSequence("android.bigText"));
1617+
16171618
activeNotificationsPayload.add(activeNotificationPayload);
16181619
}
16191620
result.success(activeNotificationsPayload);
@@ -2133,6 +2134,12 @@ private void getActiveNotificationMessagingStyle(MethodCall call, Result result)
21332134
msgPayload.put("text", msg.getText());
21342135
msgPayload.put("timestamp", msg.getTimestamp());
21352136
msgPayload.put("person", describePerson(msg.getPerson()));
2137+
if (msg.getDataUri() != null) {
2138+
msgPayload.put("dataUri", msg.getDataUri().toString());
2139+
}
2140+
if (msg.getDataMimeType() != null) {
2141+
msgPayload.put("dataMimeType", msg.getDataMimeType());
2142+
}
21362143
messagesPayload.add(msgPayload);
21372144
}
21382145
stylePayload.put("messages", messagesPayload);

flutter_local_notifications/example/lib/main.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2639,7 +2639,9 @@ class _HomePageState extends State<HomePage> {
26392639
children: <Widget>[
26402640
Text('text: ${msg.text}\n'
26412641
'timestamp: ${msg.timestamp}\n'
2642-
'person: ${_formatPerson(msg.person)}'),
2642+
'person: ${_formatPerson(msg.person)}\n'
2643+
'dataMimeType: ${msg.dataMimeType}\n'
2644+
'dataUri: ${msg.dataUri}'),
26432645
const Divider(color: Colors.black),
26442646
],
26452647
),

flutter_local_notifications/lib/src/platform_flutter_local_notifications.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,8 @@ class AndroidFlutterLocalNotificationsPlugin
533533
m['text'],
534534
DateTime.fromMillisecondsSinceEpoch(m['timestamp']),
535535
_personFromMap(m['person']),
536+
dataMimeType: m['dataMimeType'],
537+
dataUri: m['dataUri'],
536538
);
537539

538540
AndroidIcon<Object>? _iconFromMap(Map<dynamic, dynamic>? m) {

flutter_local_notifications/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: flutter_local_notifications
22
description: A cross platform plugin for displaying and scheduling local
33
notifications for Flutter applications with the ability to customise for each
44
platform.
5-
version: 19.3.1
5+
version: 19.4.0
66
homepage: https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications
77
issue_tracker: https://github.com/MaikuB/flutter_local_notifications/issues
88

0 commit comments

Comments
 (0)