Fix to only close the correct app rather than all background-mode apps

If you had two apps using this plugin running, clicking "Close" on a notification for one would close both.
This commit is contained in:
Nathan Kerr 2019-03-29 16:09:45 -07:00
parent 0e9b95013d
commit 9c88bba925
2 changed files with 2 additions and 2 deletions

View File

@ -82,7 +82,7 @@ public class BackgroundMode extends CordovaPlugin {
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
IntentFilter filter = new IntentFilter();
filter.addAction("com.backgroundmode.close");
filter.addAction("com.backgroundmode.close" + cordova.getContext().getPackageName());
cordova.getActivity().registerReceiver(receiver, filter);
}

View File

@ -208,7 +208,7 @@ public class ForegroundService extends Service {
if (settings.optBoolean("allowClose", false)) {
final Intent clostAppIntent = new Intent("com.backgroundmode.close");
final Intent clostAppIntent = new Intent("com.backgroundmode.close" + pkgName);
final PendingIntent closeIntent = PendingIntent.getBroadcast(context, 1337, clostAppIntent, 0);
final String closeIconName = settings.optString("closeIcon", "power");
NotificationCompat.Action.Builder closeAction = new NotificationCompat.Action.Builder(getIconResId(closeIconName), settings.optString("closeTitle", "Close"), closeIntent);