Skip to content

Commit

Permalink
[flutter_local_notifications] guard code getting intent from activity…
Browse files Browse the repository at this point in the history
… in case activity doesn't exist (#761)

* add guard on getting intent from activity

* revise changelog entry

* revise changelog entry

* fix changelog entry for 1.4.4+4

* fix grammar
  • Loading branch information
MaikuB committed Aug 20, 2020
1 parent 8c41860 commit 8fe0bd6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
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 @@
# [1.4.4+4]

* [Android] Fix issue [759](https://github.com/MaikuB/flutter_local_notifications/issues/759) by guarding code on getting the intent from the activity in case there isn't an activity that could cause `initialize()` and `getNotificationAppLaunchDetails()` to fail when called from the background

# [1.4.4+3]

* [Android] Fix issue [751](https://github.com/MaikuB/flutter_local_notifications/issues/751) where the `onSelectNotification` callback could be called again after the user has tapped on a notification, sent the application to the background and returned to the app via the Recents screen. This issue could have previously called `getNotificationAppLaunchDetails()` to mistakenly report that a notification launched the app when it's called again as part of the application being resumed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,8 +832,7 @@ private void show(MethodCall call, Result result) {
private void getNotificationAppLaunchDetails(Result result) {
Map<String, Object> notificationAppLaunchDetails = new HashMap<>();
String payload = null;
Intent intent = mainActivity.getIntent();
Boolean notificationLaunchedApp = !initialized && mainActivity != null && SELECT_NOTIFICATION.equals(intent.getAction()) && !launchedActivityFromHistory(intent);
Boolean notificationLaunchedApp = !initialized && mainActivity != null && SELECT_NOTIFICATION.equals(mainActivity.getIntent().getAction()) && !launchedActivityFromHistory(mainActivity.getIntent());
notificationAppLaunchDetails.put(NOTIFICATION_LAUNCHED_APP, notificationLaunchedApp);
if (notificationLaunchedApp) {
payload = mainActivity.getIntent().getStringExtra(PAYLOAD);
Expand All @@ -853,9 +852,8 @@ private void initialize(MethodCall call, Result result) {
editor.putString(DEFAULT_ICON, defaultIcon);
editor.commit();

Intent intent = mainActivity.getIntent();
if (mainActivity != null && !launchedActivityFromHistory(intent)) {
sendNotificationPayloadMessage(intent);
if (mainActivity != null && !launchedActivityFromHistory(mainActivity.getIntent())) {
sendNotificationPayloadMessage(mainActivity.getIntent());
}
initialized = true;
result.success(true);
Expand Down
2 changes: 1 addition & 1 deletion flutter_local_notifications/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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: 1.4.4+3
version: 1.4.4+4
homepage: https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications

dependencies:
Expand Down

0 comments on commit 8fe0bd6

Please sign in to comment.