From 22721a013bdd10d5eb395ba18453585f5f3f1f7f Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 31 Aug 2020 23:07:20 +0200 Subject: rebuild the ios platform and the plugins --- .../src/android/OnNotificationOpenReceiver.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 StoneIsland/plugins/cordova-plugin-firebasex/src/android/OnNotificationOpenReceiver.java (limited to 'StoneIsland/plugins/cordova-plugin-firebasex/src/android/OnNotificationOpenReceiver.java') diff --git a/StoneIsland/plugins/cordova-plugin-firebasex/src/android/OnNotificationOpenReceiver.java b/StoneIsland/plugins/cordova-plugin-firebasex/src/android/OnNotificationOpenReceiver.java new file mode 100644 index 00000000..818382ef --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-firebasex/src/android/OnNotificationOpenReceiver.java @@ -0,0 +1,36 @@ +package org.apache.cordova.firebase; + +import android.app.PendingIntent; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Bundle; +import android.util.Log; + +public class OnNotificationOpenReceiver extends BroadcastReceiver { + + // Called on tapping foreground notification + @Override + public void onReceive(Context context, Intent intent) { + try{ + PackageManager pm = context.getPackageManager(); + + Intent launchIntent = pm.getLaunchIntentForPackage(context.getPackageName()); + launchIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); + + Bundle data = intent.getExtras(); + if(!data.containsKey("messageType")) data.putString("messageType", "notification"); + data.putString("tap", FirebasePlugin.inBackground() ? "background" : "foreground"); + + Log.d(FirebasePlugin.TAG, "OnNotificationOpenReceiver.onReceive(): "+data.toString()); + + FirebasePlugin.sendMessage(data, context); + + launchIntent.putExtras(data); + context.startActivity(launchIntent); + }catch (Exception e){ + FirebasePlugin.handleExceptionWithoutContext(e); + } + } +} -- cgit v1.2.3-70-g09d2