I am trying to read the notification data in app activity. If the app is closed, I am sending notification and opens app onclick. This works fine and I am getting data. I am extracting intent in onCreate.
But I don't know how can I read intent if the app is opened. onNewIntent() is not working.
if (!NotificationUtils.isAppIsInBackground(getApplicationContext())) {
// app is in foreground, broadcast the push message
Log.e("GROUND", "BACK");
Intent pushNotification = new Intent(AppConfig.PUSH_NOTIFICATION);
pushNotification.putExtra("message", message);
LocalBroadcastManager.getInstance(this).sendBroadcast(pushNotification);
// play notification sound
NotificationUtils notificationUtils = new NotificationUtils(getApplicationContext());
notificationUtils.playNotificationSound();
} else {
// app is in background, show the notification in notification tray
Log.e("GROUND", "FOR");
Intent resultIntent = new Intent(getApplicationContext(), SecurityMainActivity.class);
resultIntent.putExtra("message", message);
}