Skip to content

Commit

Permalink
[flutter_local_notifications] lookup callback after Flutter engine is…
Browse files Browse the repository at this point in the history
… created (#1751)

* lookup callback after Flutter engine is created

* Google Java Format

* add changelog entry for handle detaching from engine

* update to use static string defined for permission request in progress error message

Co-authored-by: github-actions <>
  • Loading branch information
MaikuB committed Oct 11, 2022
1 parent c9d3132 commit 341fa58
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
5 changes: 5 additions & 0 deletions flutter_local_notifications/CHANGELOG.md
@@ -1,3 +1,8 @@
# [12.0.2]

* [Android] changed callback lookup for notification actions to take place after Flutter engine to ensure callback cache has been initialised to find the callback. This is a follow-up to changes done in 12.0.1 in trying to address issue [1721](https://github.com/MaikuB/flutter_local_notifications/issues/1721)
* [Android] updated plugin to clean up resources after it is detached from Flutter engine. Thanks to PR from [Simon Ser](https://github.com/emersion)

# [12.0.1+1]

* Updated readme to indicate that the `timezone` package should be added as a direct dependency according to [this official lint rule](https://dart-lang.github.io/linter/lints/depend_on_referenced_packages.html)
Expand Down
Expand Up @@ -71,19 +71,22 @@ private void startEngine(Context context) {
return;
}

FlutterCallbackInformation dispatcherHandle = preferences.lookupDispatcherHandle();
if (dispatcherHandle == null) {
Log.w(TAG, "Callback information could not be retrieved");
return;
}

FlutterInjector injector = FlutterInjector.instance();
FlutterLoader loader = injector.flutterLoader();

loader.startInitialization(context);
loader.ensureInitializationComplete(context, null);

engine = new FlutterEngine(context);

/// This lookup needs to be done after creating an instance of `FlutterEngine` or lookup may
// fail
FlutterCallbackInformation dispatcherHandle = preferences.lookupDispatcherHandle();
if (dispatcherHandle == null) {
Log.w(TAG, "Callback information could not be retrieved");
return;
}

DartExecutor dartExecutor = engine.getDartExecutor();

initializeEventChannel(dartExecutor);
Expand Down
Expand Up @@ -1648,7 +1648,7 @@ private void cancelAllNotifications(Result result) {

public void requestPermission(@NonNull PermissionRequestListener callback) {
if (permissionRequestInProgress) {
callback.fail("Another permission request is already in progress");
callback.fail(PERMISSION_REQUEST_IN_PROGRESS_ERROR_MESSAGE);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion flutter_local_notifications/pubspec.yaml
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: 12.0.1+1
version: 12.0.2
homepage: https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications
issue_tracker: https://github.com/MaikuB/flutter_local_notifications/issues

Expand Down

0 comments on commit 341fa58

Please sign in to comment.