Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3256423
D6295.id21037.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D6295.id21037.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D6295: Modify notification displayed from Java so that it opens the app when clicked
Attached
Detach File
Event Timeline
Log In to Comment