[go: nahoru, domu]

Skip to content

Commit

Permalink
[flutter_local_notifications] [flutter_local_notifications_platform_i…
Browse files Browse the repository at this point in the history
…nterface] timezone, macOS support, various new features and fixes (#830)

* initial working version of tzSchedule method on android and ios

* add SR-310 ABP and use in plugin, add tests, update example  and update iOS side

* WIP on repeating scheduled notifications

* updates to triggers

* change alias used for timezone imports

* fix test for tzSchedule

* update example app dependencies and ios project

* fix imports and remove ScheduledNotificationRepeatTrigger related code

* deprecate schedule,  bump Gradle plugin and update example app

* add ability to specify repeat frequency for scheduled notification

* update docs around grouping notifications

* refactor ios code

* update id used in example for weekly notification

* rename tzSchedule to zonedSchedule and fix tests

* add androidAllowWhileIdle to periodicallyShow

* cleanup usages of dynamics for maps

* update InitializationSettings and NotificationDetails to have named parameters

* hide toMap and update API docs for classes with notification details

* bumped e2e dependency and update code to work with it

* hide toMap from Time class

* update code using different linter ruleset

* hide additional android examples when run on other platforms

* update enum values to lower camel casing

* update enum values in platform interface

* have platform interface using rules from root analysis_options.yaml

* updated podspec details

* fix plugin version

* remove macOS-related conditions

* add assertions to IOSInitializationSettings

* add support for macOS 10.14+, cleanup examples

* update API docs for OS version specific properties

* refactor macos plugin and put OS X version at class level

* Revert "refactor macos plugin and put OS X version at class level"

This reverts commit 59b1712.

* bump plugin interface to 2.0.0-beta.1

* add support for older macOS versions using NSUserNotification APIs

* update changelog to mention macOS support

* add ability to specify how to interpret scheduled date on older iOS versions

* refactor date validation and update API docs

* revert example app back to use local timezone and scheduled duration

* apply formatting to plugin methods

* update documentation and code related to docs

* more documentation updates and update Proguard rules

* fix example app code for schedule 10 AM notification and rearrange cancel code

* add info on more changes

* update readme in usage of example app

* bump AGP to 4.0 and use desugaring to access Java time APIs

* add details on enabling desugaring and iOS presentation options

* refactor string constants for method call arguments on macOS

* fix error message on Android when sound raw cannot be found

* refactor macOS method call logic

* refactor iOS code

* Revert "bump AGP to 4.0 and use desugaring to access Java time APIs"

This reverts commit 40f0021.

* fix logic in receiver to repeat zoned scheduled notifications

* update readme to mention fix for invalid source resource error and update notes on how zonedSchedule works on Android

* include macOS on note about restrictions on notification sounds

* clean up changelog

* ignore macOS example Podfile-related files

* bump plugin_platform_interface dependency

* update to use beta platform interface

* parse date interpretation on iOS

* add note to readme on methods that aren't implemented

* update changelog about Dart SDK dependency being bumped

* remove redundant ios classes

* restore android timestamp fix to ensure consumers of older plugin versions will still have scheduled notifications shown

* add tests for macOS

* add ability to specify subtitle for an iOS notification

* add todo for testing periodicallyShow

* update testing section of readme and move it

* fix how launch notification details are read on android

* fix casing of changelog entry

* fix issue where ThreeTenABP lib wasn't initialised

* bump e2e dev dependency

* fix initialisation of ThreeTen Android Backport library when notifications are being rescheduled

* [flutter_local_notifications] Adds support for Android's getActiveNotifications (#704)

* Adds support for Android's getActiveNotifications

* Updates button label after new demo page layout

* fix e2e test code

* update CI script to include code analysis

* Improves getActiveNotifications implementation: Adds README usage, adds model documentation, renames file, updates error message

* Updates code style and documentation

* Adds basic test

* try no-pub option for fixing analysis task

* analyze platform interface code from within the directory

* add analysis task for plugin and update dependencies

* revert cirrus script

* amend API docs

Co-authored-by: Michael Bui <25263378+MaikuB@users.noreply.github.com>

* [flutter_local_notifications] cleanup code and API docs (#708)

* fix and update API docs

* cleanup Java code around checking Android versions

* remove use of dyancmi

* remove redundant conditional in example code

* bump plugin and updated more docs

* fix grammar in API docs

* fix Android version mentioned in example app for getActiveNotifications

* update wording in changelog

* mention Android versions that getActiveNotifications is compatible with in changelog

* fix grammar for error message related to calling getActiveNotifications

* fix macOS code quality issues (#734)

* [flutter_local_notifications] Android Full-Screen Notification (#730)

* added full-screen support for android

* addressed some PR comments

* removed wakelock

* added full-screen intent notification to example

* fullScreen -> fullScreenIntent

* android fixes

* _showFullScreenNotification now uses zonedSchedule

* doc fix

* reverted unneeded format change in main.dart

* dart analysis fixes

* README - nit: use sentence casing instead of title casing

* Update main.dart

* Update main.dart

* removed imports

* format code

* configure priority and importance

Co-authored-by: Michael Bui <25263378+MaikuB@users.noreply.github.com>

* bump version for 1.5.0-beta.7 release (#762)

* [flutter_local_notifications] null checking mainActivity before .getIntent() (#763)

* bump version (#765)

* [flutter_local_notifications] Add Null-Safety to FullScreen Intent Check (#781)

* Add Null-Safety to FullScreen Intent Check (#780)

* use helper method to remove nested if condition

Co-authored-by: Michael Bui <25263378+MaikuB@users.noreply.github.com>

* [flutter_local_notifications] bump version to 1.5.0-beta.9  (#800)

* bump version

* fix changelog entry

* [flutter_local_notifications] Added table of contents (#808)

* 📝 Added table of contents

* 📝 Updated TOC

* remove kvm_script that isn't needed on cirrus anymore

Co-authored-by: Michael Bui <25263378+MaikuB@users.noreply.github.com>

* [flutter_local_notifications] bump compile SDK to 30 and ability to specify shortcut id (#820)

* bump plugin to use compile SDK version 30 for Android

* add ability to specify shortcut id

* bump plugin version

* [flutter_local_notifications] updates to static analysis and plugin versions (#829)

* update example app and readme to match repo linter rules

* updates to changelog and versions for stable release

* remove development team info

Co-authored-by: Vincent <vkammerer@gmail.com>
Co-authored-by: Nadav Fima <nadavfima@gmail.com>
Co-authored-by: Jonas Bornold <jonas@bornold.se>
Co-authored-by: Sebastian Faust <sebastian.faust1997@gmail.com>
Co-authored-by: Ascênio <Ascenio@users.noreply.github.com>
  • Loading branch information
6 people committed Oct 4, 2020
1 parent 76b8791 commit e4e45a1
Show file tree
Hide file tree
Showing 108 changed files with 6,291 additions and 2,294 deletions.
164 changes: 164 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
linter:
rules:
- always_declare_return_types
- always_put_control_body_on_new_line
- always_put_required_named_parameters_first
- always_require_non_null_named_parameters
- always_specify_types
- annotate_overrides
- avoid_annotating_with_dynamic
- avoid_as
- avoid_bool_literals_in_conditional_expressions
- avoid_catches_without_on_clauses
- avoid_catching_errors
- avoid_classes_with_only_static_members
- avoid_double_and_int_checks
- avoid_empty_else
- avoid_equals_and_hash_code_on_mutable_classes
- avoid_escaping_inner_quotes
- avoid_field_initializers_in_const_classes
- avoid_function_literals_in_foreach_calls
- avoid_implementing_value_types
- avoid_init_to_null
- avoid_js_rounded_ints
- avoid_null_checks_in_equality_operators
# - avoid_positional_boolean_parameters
- avoid_print
- avoid_private_typedef_functions
- avoid_redundant_argument_values
- avoid_relative_lib_imports
- avoid_renaming_method_parameters
- avoid_return_types_on_setters
- avoid_returning_null
- avoid_returning_null_for_future
- avoid_returning_null_for_void
- avoid_returning_this
- avoid_setters_without_getters
- avoid_shadowing_type_parameters
- avoid_single_cascade_in_expression_statements
- avoid_slow_async_io
- avoid_types_as_parameter_names
# - avoid_types_on_closure_parameters
- avoid_unnecessary_containers
- avoid_unused_constructor_parameters
- avoid_void_async
- avoid_web_libraries_in_flutter
- await_only_futures
- camel_case_extensions
- camel_case_types
- cancel_subscriptions
- cascade_invocations
- close_sinks
# - comment_references
- constant_identifier_names
- control_flow_in_finally
- curly_braces_in_flow_control_structures
# - diagnostic_describe_all_properties
- directives_ordering
- empty_catches
- empty_constructor_bodies
- empty_statements
- file_names
- flutter_style_todos
- hash_and_equals
- implementation_imports
- invariant_booleans
- iterable_contains_unrelated_type
- join_return_with_assignment
- leading_newlines_in_multiline_strings
- library_names
- library_prefixes
- lines_longer_than_80_chars
- list_remove_unrelated_type
- literal_only_boolean_expressions
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- no_duplicate_case_values
- no_logic_in_create_state
- no_runtimeType_toString
- non_constant_identifier_names
- null_closures
- one_member_abstracts
- only_throw_errors
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- parameter_assignments
- prefer_adjacent_string_concatenation
- prefer_asserts_in_initializer_lists
# - prefer_asserts_with_message
- prefer_collection_literals
- prefer_conditional_assignment
- prefer_const_constructors
- prefer_const_constructors_in_immutables
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
- prefer_constructors_over_static_methods
- prefer_contains
- prefer_equal_for_default_values
- prefer_expression_function_bodies
- prefer_final_fields
- prefer_final_in_for_each
- prefer_final_locals
- prefer_for_elements_to_map_fromIterable
- prefer_foreach
- prefer_function_declarations_over_variables
- prefer_generic_function_type_aliases
- prefer_if_elements_to_conditional_expressions
- prefer_if_null_operators
- prefer_initializing_formals
- prefer_inlined_adds
- prefer_int_literals
- prefer_interpolation_to_compose_strings
- prefer_is_empty
- prefer_is_not_empty
- prefer_is_not_operator
- prefer_iterable_whereType
# - prefer_mixin
- prefer_null_aware_operators
- prefer_relative_imports
- prefer_single_quotes
- prefer_spread_collections
- prefer_typing_uninitialized_variables
- prefer_void_to_null
- provide_deprecation_message
# - public_member_api_docs
- recursive_getters
- slash_for_doc_comments
- sort_child_properties_last
- sort_constructors_first
- sort_pub_dependencies
- sort_unnamed_constructors_first
- test_types_in_equals
- throw_in_finally
- type_annotate_public_apis
- type_init_formals
- unawaited_futures
# - unnecessary_await_in_return
- unnecessary_brace_in_string_interps
- unnecessary_const
- unnecessary_getters_setters
# - unnecessary_lambdas
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_raw_strings
- unnecessary_statements
- unnecessary_string_escapes
- unnecessary_string_interpolations
- unnecessary_this
- unrelated_type_equality_checks
- unsafe_html
- use_full_hex_values_for_flutter_colors
- use_function_type_syntax_for_parameters
- use_key_in_widget_constructors
- use_raw_strings
- use_rethrow_when_possible
- use_setters_to_change_properties
- use_string_buffers
- use_to_and_as_if_applicable
- valid_regexps
- void_checks
3 changes: 2 additions & 1 deletion flutter_local_notifications/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/
pubspec.lock

# Android related
**/android/**/gradle-wrapper.jar
Expand Down
48 changes: 41 additions & 7 deletions flutter_local_notifications/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
# [1.5.0]

* Added macOS implementation of the plugin
* The `schedule`, `showDailyAtTime` and `showWeeklyAtDayAndTime` methods has been marked as a deprecated due to problems with time zones, particularly when it comes to daylight savings.
* Added the `zonedSchedule` method to the plugin that allows for scheduling notifications to occur on a specific date and time relative a specific time zone. This can be used to schedule daily and weekly notifications as well. The example app has been updated to demonstrate its usage. Note that to support time zone-based scheduling, the plugin now depends on the `timezone` package so that an instance of the `TZDateTime` class is required to the specify the time the notification should occur. This should work in most cases as it is IANA-based and native platforms have time zones that are IANA-based as well. To support time zone aware dates on older versions of Android (which use older Java APIs), the plugin depends on the [ThreeTen Android Backport library](https://github.com/JakeWharton/ThreeTenABP). Once Flutter's support for Android Studio 4.0 and Android Gradle plugin 4.0 has stabilised, the plugin will be updated to make use of [desugaring](https://developer.android.com/studio/releases/gradle-plugin#j8-library-desugaring) instead of relying on the ThreeTen Android Backport library.
* [Android] Fixed issue [670] where `getNotificationAppLaunchDetails()` behaved inconsistently depending on if it was called before or after `initialize()`
* [Android] Added the `getActiveNotifications()` method to the `AndroidFlutterLocalNotificationsPlugin` class thanks to the PR from [Vincent Kammerer](https://github.com/vkammerer). This can be used to query the active notifications and is only applicable to Android 6.0 or newer
* [Android] Fixed an issue where the error message for an invalid source resource wasn't formatted correctly to include the name of the specified resource
* [Android] Added `androidAllowWhileIdle` boolean argument to the `periodicallyShow` method. When set to true, this changes how recurring notifications are shown so that the Android `AlarmManager` API is used to schedule a notification with exact timing. When the notification appears, the next one is scheduled after that. This is get around the limitations where the `AlarmManager` APIs don't provide a way for work to be repeated with precising timing regardless of the power mode.
The example app has been updated to include these changes so that it can be used as a reference as well
* [Android] Added support for full-screen notifications via the `fullScreenIntent` argument that has been added to the `AndroidNotificationDetails` class. Thanks to the PR from [Nadav Fima](https://github.com/nadavfima)
* [Android] Bumped compile SDK to 30 (Android 11)
* [Android] Added ability to specify shortcut id that can be used for conversations. See https://developer.android.com/guide/topics/ui/conversations for more info. Note the plugin doesn't provide the ability to publish shortcuts so developers will likely need to look into writing their own code to do so and save the shortcut id so that it can be linked to notifications
* [iOS] Updated the details in the plugin's podspec file
* [iOS] Added ability to specify a subtitle for a notification via the `subtitle` property of the `IOSNotificationDetails` class. This property is only application to iOS versions 10 or newer
* **Breaking change** The `InitializationSettings` and `NotificationDetails` classes no longer have positional parameters but now have named parameters called `android` and `iOS` for passing in data specific to Android and iOS. There `macOS` named parameter has also been added for passing data specific to macOS
* **Breaking change** The `toMap` method that was used internally to transfer data over platform channels is no longer publicly accessible
* **Breaking change** All enum values have been renamed to follow lower camel case convention. This affects the following enums
* `Day`
* `AndroidNotificationChannelAction`
* `Importance` (note: as `default` is a keyword, what use to be `Default` is now `defaultImportance`)
* `Priority` (note: as `default` is a keyword, what use to be `Default` is now `defaultPriority`)
* `GroupAlertBehavior`
* `NotificationVisibility`
* `RepeatInterval`
* **Breaking change** assertions have been added to the `IOSInitializationSettings` constructor to prevent null values being passed in
* Updated example app so that code for demonstrating functionality that is specific to a platform are only visible when running on the appropriate platform
* Bumped Android dependencies
* Updated example app's Proguard rules file to match latest configuration required by GSON
* Bumped lower bound of Dart SDK dependency to 2.6
* Updated and fixed wording in API docs
* Readme now has a table of contents. Thanks to the PR from [Ascênio](https://github.com/Ascenio)


# [1.4.4+5]

* Updated the `platform` package version range constraint so that 3.x null safety releases could be used (currently used in Flutter 1.22 stable)
Expand Down Expand Up @@ -46,8 +80,8 @@

Please note that there are a number of breaking changes in this release to improve the developer experience when using the plugin APIs. The changes should hopefully be straightforward but please through the changelog carefully just in case. The steps migrate your code has been covered below but the Git history of the example application's `main.dart` file can also be used as reference.

* [Android] **BREAKING CHANGE** The `style` property of the `AndroidNotificationDetails` class has been removed as it was redundant. No changes are needed unless your application was displaying media notifications (i.e. `style` was set to `AndroidNotificationStyle.Media`). If this is the case, you can migrate your code by setting the `styleInformation` property of the `AndroidNotificationDetails` to an instance of the `MediaNotificationStyleInformation` class. This class is a new addition in this release
* [Android] **BREAKING CHANGE** The `AndroidNotificationSound` abstract class has been introduced to represent Android notification sounds. The `sound` property of the `AndroidNotificationDetails` class has changed from being a `String` type to an `AndroidNotificationSound` type. In this release, the `AndroidNotificationSound` has the following subclasses
* [Android] **Breaking change** The `style` property of the `AndroidNotificationDetails` class has been removed as it was redundant. No changes are needed unless your application was displaying media notifications (i.e. `style` was set to `AndroidNotificationStyle.Media`). If this is the case, you can migrate your code by setting the `styleInformation` property of the `AndroidNotificationDetails` to an instance of the `MediaNotificationStyleInformation` class. This class is a new addition in this release
* [Android] **Breaking change** The `AndroidNotificationSound` abstract class has been introduced to represent Android notification sounds. The `sound` property of the `AndroidNotificationDetails` class has changed from being a `String` type to an `AndroidNotificationSound` type. In this release, the `AndroidNotificationSound` has the following subclasses

* `RawResourceAndroidNotificationSound`: use this when the sound is raw resource associated with the Android application. Previously, this was the only type of sound supported so applications using the plugin prior to 1.4.0 can migrate their application by using this class. For example, if your previous code was

Expand All @@ -70,7 +104,7 @@ Please note that there are a number of breaking changes in this release to impro
```

* `UriAndroidNotificationSound`: use this when a URI refers to the sound on the Android device. This is a new feature being supported as part of this release. Developers may need to write their code to access native Android APIs (e.g. the `RingtoneManager` APIs) to obtain the URIs they need.
* [Android] **BREAKING CHANGE** The `BitmapSource` enum has been replaced by the newly `AndroidBitmap` abstract class and its subclasses. This removes the need to specify the name/path of the bitmap and the source of the bitmap as two separate properties (e.g. the `largeIcon` and `largeIconBitmapSource` properties of the `AndroidNotificationDetails` class). This change affects the following classes
* [Android] **Breaking change** The `BitmapSource` enum has been replaced by the newly `AndroidBitmap` abstract class and its subclasses. This removes the need to specify the name/path of the bitmap and the source of the bitmap as two separate properties (e.g. the `largeIcon` and `largeIconBitmapSource` properties of the `AndroidNotificationDetails` class). This change affects the following classes

* `AndroidNotificationDetails`: the `largeIcon` is now an `AndroidBitmap` type instead of a `String` and the `largeIconBitmapSource` property has been removed
* `BigPictureStyleInformation`: the `largeIcon` is now an `AndroidBitmap` type instead of a `String` and the `largeIconBitmapSource` property has been removed. The `bigPicture` is now a `AndroidBitmap` type instead of a `String` and the `bigPictureBitmapSource` property has been removed
Expand Down Expand Up @@ -102,7 +136,7 @@ Please note that there are a number of breaking changes in this release to impro
largeIcon: DrawableResourceAndroidBitmap('sample_large_icon'),
)
```
* [Android] **BREAKING CHANGE** The `IconSource` enum has been replaced by the newly added `AndroidIcon` abstract class and its subclasses. This change was done for similar reasons in replacing the `BitmapSource` enum. This only affects the `Person` class, which is used when displaying each person in a messaging-style notification. Here the `icon` property is now an `AndroidIcon` type instead of a `String` and the `iconSource` property has been removed.
* [Android] **Breaking change** The `IconSource` enum has been replaced by the newly added `AndroidIcon` abstract class and its subclasses. This change was done for similar reasons in replacing the `BitmapSource` enum. This only affects the `Person` class, which is used when displaying each person in a messaging-style notification. Here the `icon` property is now an `AndroidIcon` type instead of a `String` and the `iconSource` property has been removed.

The following describes how each `IconSource` value maps to the `AndroidIcon` subclasses

Expand All @@ -128,7 +162,7 @@ Please note that there are a number of breaking changes in this release to impro
```

The `AndroidIcon` also has a `BitmapAssetAndroidIcon` subclass to enables the usage of bitmap icons that have been registered as a Flutter asset via the `pubspec.yaml` file.
* [Android] **BREAKING CHANGE** All properties in the `AndroidNotificationDetails`, `DefaultStyleInformation` and `InboxStyleInformation` classes have been made `final`
* [Android] **Breaking change** All properties in the `AndroidNotificationDetails`, `DefaultStyleInformation` and `InboxStyleInformation` classes have been made `final`
* The `DefaultStyleInformation` class now implements the `StyleInformation` class instead of extending it
* Where possible, classes in the plugins have been updated to provide `const` constructors
* Updates to API docs and readme
Expand All @@ -137,7 +171,7 @@ Please note that there are a number of breaking changes in this release to impro

# [1.3.0]

* [iOS] **BREAKING CHANGE** Plugin will now throw a `PlatformException` if there was an error returned upon calling the native [`addNotificationRequest`](https://developer.apple.com/documentation/usernotifications/unusernotificationcenter/1649508-addnotificationrequest) method. Previously the error was logged on the native side the using [`NSLog`](https://developer.apple.com/documentation/foundation/1395275-nslog) function.
* [iOS] **Breaking change** Plugin will now throw a `PlatformException` if there was an error returned upon calling the native [`addNotificationRequest`](https://developer.apple.com/documentation/usernotifications/unusernotificationcenter/1649508-addnotificationrequest) method. Previously the error was logged on the native side the using [`NSLog`](https://developer.apple.com/documentation/foundation/1395275-nslog) function.
* [iOS] Added ability to associate notifications with attachments. Only applicable to iOS 10+ where the UserNotification APIs are used. Thanks to the PR from [Pavel Sipaylo](https://github.com/psipaylo)
* Updated readme on using `firebase_messaging` together with `flutter_local_notifications` to let the community that `firebase_messaging` 6.0.13 can be used to resolve compatibility issues around callbacks when both plugins are used together

Expand Down Expand Up @@ -560,7 +594,7 @@ Please note that there are a number of breaking changes in this release to impro

## [0.1.2]

* [Android] Bug fix in calculating when to show a scheduled notification. Ensure scheduled Android notifications will remain scheduled even after rebooting.
* [Android] Bug fix in calculating when to show a scheduled notification. Ensure scheduled Android notifications will remain scheduled even after rebooting.

## [0.1.1]

Expand Down
Loading

0 comments on commit e4e45a1

Please sign in to comment.