У меня проблема с push-уведомлениями Firebase.Вместо того, чтобы видеть уведомление, оно автоматически открывает действие, которое я поставил.Я хочу такое поведение, но после нажатия на уведомление.
Это мой код:
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
final String title = remoteMessage.getData().get("title");
final String message = remoteMessage.getData().get("body");
showNotifications(title, message);
}
private void showNotifications(String title, String msg) {
Intent i = new Intent(this, OrderDetailActivity.class);
i.putExtra("order_id", 99);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
i, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);
Notification notification = new NotificationCompat.Builder(this)
.setContentText(msg)
.setContentTitle(title)
.setContentIntent(pendingIntent)
.setSmallIcon(R.mipmap.ic_launcher_logo)
.build();
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.notify(NOTIFICATION_ID, notification);
try {
pendingIntent.send();
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
}