Page MenuHomePhabricator

D6295.id21037.diff
No OneTemporary

D6295.id21037.diff

diff --git a/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java b/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java
--- a/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java
+++ b/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java
@@ -3,6 +3,7 @@
import android.app.ActivityManager;
import android.app.Notification;
import android.app.NotificationManager;
+import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
@@ -12,6 +13,7 @@
import androidx.core.app.NotificationCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import app.comm.android.ExpoUtils;
+import app.comm.android.MainActivity;
import app.comm.android.R;
import app.comm.android.fbjni.CommSecureStore;
import app.comm.android.fbjni.GlobalDBSingleton;
@@ -191,6 +193,9 @@
Bundle data = new Bundle();
data.putString(THREAD_ID_KEY, threadID);
+ PendingIntent startMainActivityAction =
+ this.createStartMainActivityAction(message);
+
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this.getApplicationContext())
.setDefaults(Notification.DEFAULT_ALL)
@@ -202,10 +207,25 @@
.setLargeIcon(BitmapFactory.decodeResource(
this.getApplicationContext().getResources(),
R.mipmap.ic_launcher))
- .setAutoCancel(true);
+ .setAutoCancel(true)
+ .setContentIntent(startMainActivityAction);
+
if (title != null) {
notificationBuilder = notificationBuilder.setContentTitle(title);
}
notificationManager.notify(id, id.hashCode(), notificationBuilder.build());
}
+
+ private PendingIntent createStartMainActivityAction(RemoteMessage message) {
+ Intent intent =
+ new Intent(this.getApplicationContext(), MainActivity.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
+ intent.putExtra("message", message);
+
+ return PendingIntent.getActivity(
+ this.getApplicationContext(),
+ message.getData().get(NOTIF_ID_KEY).hashCode(),
+ intent,
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
+ }
}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 16, 8:47 PM (18 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2503260
Default Alt Text
D6295.id21037.diff (2 KB)

Event Timeline