Differential D7193 Diff 24569 native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java
Changeset View
Changeset View
Standalone View
Standalone View
native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | public class CommNotificationsHandler extends FirebaseMessagingService { | ||||
public static final String RESCIND_ID_KEY = "rescindID"; | public static final String RESCIND_ID_KEY = "rescindID"; | ||||
public static final String TITLE_KEY = "title"; | public static final String TITLE_KEY = "title"; | ||||
public static final String PREFIX_KEY = "prefix"; | public static final String PREFIX_KEY = "prefix"; | ||||
public static final String BODY_KEY = "body"; | public static final String BODY_KEY = "body"; | ||||
public static final String MESSAGE_INFOS_KEY = "messageInfos"; | public static final String MESSAGE_INFOS_KEY = "messageInfos"; | ||||
public static final String THREAD_ID_KEY = "threadID"; | public static final String THREAD_ID_KEY = "threadID"; | ||||
public static final String TOKEN_EVENT = "TOKEN_EVENT"; | public static final String TOKEN_EVENT = "TOKEN_EVENT"; | ||||
public static final String FOREGROUND_MESSAGE_EVENT = | public static final String MESSAGE_EVENT = "MESSAGE_EVENT"; | ||||
"FOREGROUND_MESSAGE_EVENT"; | |||||
@Override | @Override | ||||
public void onCreate() { | public void onCreate() { | ||||
super.onCreate(); | super.onCreate(); | ||||
CommSecureStore.getInstance().initialize( | CommSecureStore.getInstance().initialize( | ||||
ExpoUtils.createExpoSecureStoreSupplier(this.getApplicationContext())); | ExpoUtils.createExpoSecureStoreSupplier(this.getApplicationContext())); | ||||
notificationManager = (NotificationManager)this.getSystemService( | notificationManager = (NotificationManager)this.getSystemService( | ||||
Context.NOTIFICATION_SERVICE); | Context.NOTIFICATION_SERVICE); | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | if (rawMessageInfosString != null && sqliteFile.exists()) { | ||||
GlobalDBSingleton.scheduleOrRun(() -> { | GlobalDBSingleton.scheduleOrRun(() -> { | ||||
MessageOperationsUtilities.storeMessageInfos( | MessageOperationsUtilities.storeMessageInfos( | ||||
sqliteFile.getPath(), rawMessageInfosString); | sqliteFile.getPath(), rawMessageInfosString); | ||||
}); | }); | ||||
} else if (rawMessageInfosString != null) { | } else if (rawMessageInfosString != null) { | ||||
Log.w("COMM", "Database not existing yet. Skipping notification"); | Log.w("COMM", "Database not existing yet. Skipping notification"); | ||||
} | } | ||||
if (this.isAppInForeground()) { | Intent intent = new Intent(MESSAGE_EVENT); | ||||
Intent intent = new Intent(FOREGROUND_MESSAGE_EVENT); | |||||
intent.putExtra("message", message); | intent.putExtra("message", message); | ||||
localBroadcastManager.sendBroadcast(intent); | localBroadcastManager.sendBroadcast(intent); | ||||
if (this.isAppInForeground()) { | |||||
return; | return; | ||||
} | } | ||||
this.displayNotification(message); | this.displayNotification(message); | ||||
} | } | ||||
private boolean isAppInForeground() { | private boolean isAppInForeground() { | ||||
return ProcessLifecycleOwner.get().getLifecycle().getCurrentState() == | return ProcessLifecycleOwner.get().getLifecycle().getCurrentState() == | ||||
Lifecycle.State.RESUMED; | Lifecycle.State.RESUMED; | ||||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |