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] fix crash occurring for notification actions that don't have a callback to handle them #1739

Merged
merged 2 commits into from
Oct 8, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions flutter_local_notifications/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# [12.0.1]

* [Android][iOS] fixed issue [1721](https://github.com/MaikuB/flutter_local_notifications/issues/1721) where a crash occurs upon tapping on a notification action fbut the `onDidReceiveBackgroundNotificationResponse` optional callback hasn't been specified.

# [12.0.0]

* Bumped `dbus` dependency via `flutter_local_notifications_linux`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ 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();

Expand All @@ -80,7 +86,6 @@ private void startEngine(Context context) {
engine = new FlutterEngine(context);
DartExecutor dartExecutor = engine.getDartExecutor();

FlutterCallbackInformation dispatcherHandle = preferences.lookupDispatcherHandle();
initializeEventChannel(dartExecutor);

String dartBundlePath = loader.findAppBundlePath();
Expand Down
14 changes: 7 additions & 7 deletions flutter_local_notifications/ios/Classes/FlutterEngineManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,22 @@ - (void)startEngineIfNeeded:(ActionEventSink *)actionEventSink
NSNumber *dispatcherHandle =
[_persistentState objectForKey:@"dispatcher_handle"];

backgroundEngine =
[[FlutterEngine alloc] initWithName:@"FlutterLocalNotificationsIsolate"
project:nil
allowHeadlessExecution:true];

FlutterCallbackInformation *info = [FlutterCallbackCache
lookupCallbackInformation:[dispatcherHandle longValue]];

if (!info) {
NSLog(@"callback information could not be retrieved");
abort();
NSLog(@"Callback information could not be retrieved");
return;
}

NSString *entryPoint = info.callbackName;
NSString *uri = info.callbackLibraryPath;

backgroundEngine =
[[FlutterEngine alloc] initWithName:@"FlutterLocalNotificationsIsolate"
project:nil
allowHeadlessExecution:true];

dispatch_async(dispatch_get_main_queue(), ^{
FlutterEventChannel *channel = [FlutterEventChannel
eventChannelWithName:
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: 12.0.0
version: 12.0.1
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