Skip to content

Commit

Permalink
[fix] remove TaskStackBuilder, it's useless and cause to relaunch the…
Browse files Browse the repository at this point in the history
… cordova activity even if the app is alive in background
  • Loading branch information
stephane padovani committed Nov 26, 2022
1 parent 34bc471 commit bfc4214
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/cordova-plugin-local-notification-12.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@

#### Important notice

If the app is in background, it must not be launched but put in foreground.
<del>If the app is in background, it must not be launched but put in foreground.
To avoid launching the app in this case, add the following in your config.xml file:
`<preference name="AndroidLaunchMode" value="singleInstance"/>`
`<preference name="AndroidLaunchMode" value="singleInstance"/>`</del>

Not need anymore, and it's better to avoid because it can cause issues with the cordova camera plugin.
See https://stackoverflow.com/questions/10831562/camera-always-returns-resultcode-as-0


#### To install

Expand Down
4 changes: 2 additions & 2 deletions src/android/notification/Builder.java
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ private void applyContentReceiver(NotificationCompat.Builder builder) {
}

PendingIntent contentIntent =
LaunchUtils.getTaskStackPendingIntent(context, intent, notificationId);
LaunchUtils.getActivityPendingIntent(context, intent, notificationId);
builder.setContentIntent(contentIntent);
}

Expand Down Expand Up @@ -474,7 +474,7 @@ private PendingIntent getPendingIntentForAction (Action action) {
intent.putExtras(extras);
}

return LaunchUtils.getTaskStackPendingIntent(context, intent, notificationId);
return LaunchUtils.getActivityPendingIntent(context, intent, notificationId);
}

/**
Expand Down
10 changes: 0 additions & 10 deletions src/android/notification/util/LaunchUtils.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.appplant.cordova.plugin.notification.util;

import android.app.PendingIntent;
import android.app.TaskStackBuilder;
import android.content.Context;
import android.content.Intent;

Expand Down Expand Up @@ -34,15 +33,6 @@ public static PendingIntent getActivityPendingIntent(Context context,
return PendingIntent.getActivity(context, notificationId, intent, getIntentFlags());
}

public static PendingIntent getTaskStackPendingIntent(Context context,
Intent intent,
int notificationId) {
TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context);
taskStackBuilder.addNextIntentWithParentStack(intent);
return taskStackBuilder.getPendingIntent(notificationId, getIntentFlags());
}


/***
* Launch main intent from package.
*/
Expand Down

0 comments on commit bfc4214

Please sign in to comment.