Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flutter_local_notifications] clean up for 9.5.0 release #1583

Merged
merged 1 commit into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion flutter_local_notifications/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# [9.5.0]

* [Android] added `getActiveNotificationMessagingStyle()` method to the `AndroidFlutterLocalNotificationsPlugin` class. This allows for getting the messaging style information of an active notification e.g. to append a message to an existing notification. Thanks to the PR from [Simon Ser](https://github.com/emersion)
* Updated readme to fix an issue where clicking on the Android setup and iOS setup sections from table of contents wouldn't go the appropriate section. Thanks to the PR from [HendrikF](https://github.com/HendrikF)

# [9.4.1]

* Calling `initialize()` on a platform with passing the appropriate initialisation settings for it will now throw an `ArgumentError`. Whilst this may be technically a breaking change, it's been done as a minor change as the call was already throwing an unhandled exception in these scenarios. This change is to help provide more information on why it fails. Documentation has also been updated to provide more on information on this as the intialisation settings for each platform are nullable so developers aren't forced to provide settings for platforms they don't target. Thanks to the PR from [Zlati Pehlivanov](https://github.com/talamaska)
* Updated docs to fix typos, adjust heading levels and use the term ["daylight saving time"](https://en.wikipedia.org/wiki/Daylight_saving_time) instead of "daylight savings". Thanks to the PR from [Ross Llewallyn](https://github.com/EnduringBeta)

# [9.4.0]
* [Android] Added `tag` to `ActiveNotification` that would allow for finding the notification's taf. Thanks to the PR from [Simon Ser](https://github.com/emersion)
* [Android] Added `tag` to `ActiveNotification` that would allow for finding the notification's tag. Thanks to the PR from [Simon Ser](https://github.com/emersion)

# [9.3.3]
* [macOS] Fixed issue [1507](https://github.com/MaikuB/flutter_local_notifications/issues/1507) where calling the `requestPermissions()` method of the `MacOSFlutterLocalNotificationsPlugin` class led to a crash. This will be coalesced to assume that the `boolean` parameters around the requested permissions default to `false` to be consistent with the iOS implementation. Note that in 10.0.0 the method will have a breaking change so that these parameters are non-nullable
Expand Down
27 changes: 12 additions & 15 deletions flutter_local_notifications/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,8 @@ class _HomePageState extends State<HomePage> {
TextButton(
child: const Text('Get messaging style'),
onPressed: () {
_getActiveNotificationMessagingStyle(activeNotification.id, activeNotification.tag);
_getActiveNotificationMessagingStyle(
activeNotification.id, activeNotification.tag);
},
),
const Divider(color: Colors.black),
Expand All @@ -2054,28 +2055,24 @@ class _HomePageState extends State<HomePage> {
if (messagingStyle == null) {
dialogContent = const Text('No messaging style');
} else {
dialogContent = SingleChildScrollView(child: Column(
dialogContent = SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
'person: ${_formatPerson(messagingStyle.person)}\n'
'conversationTitle: ${messagingStyle.conversationTitle}\n'
'groupConversation: ${messagingStyle.groupConversation}'
),
Text('person: ${_formatPerson(messagingStyle.person)}\n'
'conversationTitle: ${messagingStyle.conversationTitle}\n'
'groupConversation: ${messagingStyle.groupConversation}'),
const Divider(color: Colors.black),
if (messagingStyle.messages == null)
const Text('No messages'),
if (messagingStyle.messages == null) const Text('No messages'),
if (messagingStyle.messages != null)
for (final msg in messagingStyle.messages!)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'text: ${msg.text}\n'
'timestamp: ${msg.timestamp}\n'
'person: ${_formatPerson(msg.person)}'
),
Text('text: ${msg.text}\n'
'timestamp: ${msg.timestamp}\n'
'person: ${_formatPerson(msg.person)}'),
const Divider(color: Colors.black),
],
),
Expand Down Expand Up @@ -2112,7 +2109,7 @@ class _HomePageState extends State<HomePage> {
return 'null';
}

List<String> attrs = [];
final List<String> attrs = <String>[];
if (person.name != null) {
attrs.add('name: "${person.name}"');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:async';

import 'package:clock/clock.dart';

import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_local_notifications_platform_interface/flutter_local_notifications_platform_interface.dart';
Expand All @@ -10,8 +9,8 @@ import 'package:timezone/timezone.dart';
import 'helpers.dart';
import 'platform_specifics/android/active_notification.dart';
import 'platform_specifics/android/enums.dart';
import 'platform_specifics/android/initialization_settings.dart';
import 'platform_specifics/android/icon.dart';
import 'platform_specifics/android/initialization_settings.dart';
import 'platform_specifics/android/message.dart';
import 'platform_specifics/android/method_channel_mappers.dart';
import 'platform_specifics/android/notification_channel.dart';
Expand All @@ -20,7 +19,6 @@ import 'platform_specifics/android/notification_details.dart';
import 'platform_specifics/android/notification_sound.dart';
import 'platform_specifics/android/person.dart';
import 'platform_specifics/android/styles/messaging_style_information.dart';
import 'platform_specifics/android/styles/style_information.dart';
import 'platform_specifics/ios/enums.dart';
import 'platform_specifics/ios/initialization_settings.dart';
import 'platform_specifics/ios/method_channel_mappers.dart';
Expand Down Expand Up @@ -422,12 +420,15 @@ class AndroidFlutterLocalNotificationsPlugin
///
/// Only [DrawableResourceAndroidIcon] and [ContentUriAndroidIcon] are
/// supported for [AndroidIcon] fields.
Future<MessagingStyleInformation?> getActiveNotificationMessagingStyle(int id, { String? tag }) async {
final Map<dynamic, dynamic>? m =
await _channel.invokeMethod('getActiveNotificationMessagingStyle', {
'id': id,
'tag': tag,
});
Future<MessagingStyleInformation?> getActiveNotificationMessagingStyle(
int id, {
String? tag,
}) async {
final Map<dynamic, dynamic>? m = await _channel
.invokeMethod('getActiveNotificationMessagingStyle', <String, Object?>{
'id': id,
'tag': tag,
});
if (m == null) {
return null;
}
Expand All @@ -436,7 +437,9 @@ class AndroidFlutterLocalNotificationsPlugin
_personFromMap(m['person'])!,
conversationTitle: m['conversationTitle'],
groupConversation: m['groupConversation'],
messages: m['messages']?.map<Message>((m) => _messageFromMap(m))?.toList(),
messages:
// ignore: always_specify_types
m['messages']?.map<Message>((m) => _messageFromMap(m))?.toList(),
);
}

Expand All @@ -454,13 +457,11 @@ class AndroidFlutterLocalNotificationsPlugin
);
}

Message _messageFromMap(Map<dynamic, dynamic> m) {
return Message(
m['text'],
DateTime.fromMillisecondsSinceEpoch(m['timestamp']),
_personFromMap(m['person']),
);
}
Message _messageFromMap(Map<dynamic, dynamic> m) => Message(
m['text'],
DateTime.fromMillisecondsSinceEpoch(m['timestamp']),
_personFromMap(m['person']),
);

AndroidIcon<Object>? _iconFromMap(Map<dynamic, dynamic>? m) {
if (m == null) {
Expand Down
2 changes: 1 addition & 1 deletion flutter_local_notifications/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: flutter_local_notifications
description: A cross platform plugin for displaying and scheduling local
notifications for Flutter applications with the ability to customise for each
platform.
version: 9.4.1
version: 9.5.0
homepage: https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications

dependencies:
Expand Down