Как хранить Firebase Notification и отображать новые действия при нажатии на уведомление - PullRequest
0 голосов
/ 28 января 2019

Я использую удаленное оповещение Firebase Cloud Messaging for Android, ниже приведен код для вашей справки.Я хочу открыть определенное действие по щелчку Уведомления и хочу показать сообщение уведомлений в окне оповещения.

Но когда я нажимаю на Уведомление, оно открывает Основную активностьВ коде вы можете видеть, что я передаю Other.class , но все равно он не работает ...

Я что-то пропустил?Что-то не так в коде?

Также помогите мне достичь 2-й функциональности, т.е. Как показать сообщение с уведомлением в AlertBox / DialogBox

    public class MyFirebaseMessagingService extends FirebaseMessagingService {

@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    Intent intent=new Intent(this,Other.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent=PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);//new PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);
    NotificationCompat.Builder notificationBuilder= new NotificationCompat.Builder(this);
    notificationBuilder.setContentTitle("FCM NOTIFICATION");
    notificationBuilder.setContentText(Objects.requireNonNull(remoteMessage.getNotification()).getBody());
    notificationBuilder.setAutoCancel(true);
    notificationBuilder.setSmallIcon(R.mipmap.ic_launcher);
    notificationBuilder.setContentIntent(pendingIntent);
    NotificationManager notificationManager =(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    assert notificationManager != null;
    notificationManager.notify(0,notificationBuilder.build());

   }
}
...