@Override public void onMessageReceived(RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); Log.d("Msg", "Message received ["+remoteMessage+"]"); // Create Notification Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 1410, intent, PendingIntent.FLAG_ONE_SHOT); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_name) .setContentTitle("Message") .setContentText(remoteMessage.getNotification().getBody()) .setAutoCancel(true) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(1410, notificationBuilder.build()); } }
@Override public void onMessageReceived(RemoteMessage remoteMessage) { if (remoteMessage.getNotification() != null){ //log it up } notifyUser(remoteMessage.getFrom(), remoteMessage.getNotification().getBody()); }
@Override public void onMessageReceived(RemoteMessage remoteMessage) { //Displaying data in log //It is optional Log.d(TAG, "From: " + remoteMessage.getFrom()); Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody()); //Calling method to generate notification sendNotification(remoteMessage.getNotification().getBody()); }
@Override public void onMessageReceived(RemoteMessage remoteMessage) { //super.onMessageReceived(remoteMessage); Log.d(TAG, "From: " + remoteMessage.getFrom()); Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody()); enviarNotificacion(remoteMessage); }
/** * Called when message is received. * * @param remoteMessage Object representing the message received from Firebase Cloud Messaging. */ // [START receive_message] @Override public void onMessageReceived(RemoteMessage remoteMessage) { // TODO(developer): Handle FCM messages here. // If the application is in the foreground handle both data and notification messages here. // Also if you intend on generating your own notifications as a result of a received FCM // message, here is where that should be initiated. See sendNotification method below. Log.d(TAG, "From: " + remoteMessage.getFrom()); Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody()); sendNotification(remoteMessage.getNotification().getBody()); } // [END receive_message]
super.onMessageReceived(remoteMessage); String notification_title = remoteMessage.getNotification().getTitle(); String notification_message = remoteMessage.getNotification().getBody(); String click_action = remoteMessage.getNotification().getClickAction();
@Override public void onMessageReceived(RemoteMessage remoteMessage) { Log.e(TAG, "From: " + remoteMessage.getFrom()); if (remoteMessage == null) return; // Check if message contains a notification payload. if (remoteMessage.getNotification() != null) { Log.e(TAG, "Notification Body: " + remoteMessage.getNotification().getBody()); handleNotification(remoteMessage.getNotification().getBody()); } // Check if message contains a data payload. if (remoteMessage.getData().size() > 0) { Log.e(TAG, "Data Payload: " + remoteMessage.getData().toString()); try { JSONObject json = new JSONObject(remoteMessage.getData().toString()); handleDataMessage(json); } catch (Exception e) { Log.e(TAG, "Exception: " + e.getMessage()); } } }
@Override public void onMessageReceived(RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); Log.d("AnyAudioFirebase", "message rec"); // if payloads available if (remoteMessage.getData().size() > 0) { Log.d("AnyAudioFirebase", "message received"); AnyAudioPushHandler.getInstance(this) .setNotificationPayload(remoteMessage.getNotification()) .handlePush(remoteMessage.getData()); } }
@Override public void onMessageReceived(RemoteMessage message) { RemoteMessage.Notification notification = message.getNotification(); if (notification != null) { String title = notification.getTitle(); String body = notification.getBody(); // Post your own notification using NotificationCompat.Builder // or send the information to your UI } // Listing 11-31: Receiving data using the Firebase Messaging Service Map<String,String> data = message.getData(); if (data != null) { String value = data.get("your_key"); // Post your own Notification using NotificationCompat.Builder // or send the information to your UI } } }
.setSmallIcon(R.drawable.notificacion) .setContentTitle("Notificacion") .setContentText(remoteMessage.getNotification().getBody()) .setAutoCancel(true) .setSound(sonido)
@Override public void onMessageReceived(RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); if (remoteMessage != null) { // check if message contains a data payload if (remoteMessage.getData() != null && remoteMessage.getData().size() > 0) { Notification notification = createNotificationObject(remoteMessage); storeNotification(notification); raiseSystemNotification(notification); } // Check if message contains a notification payload if (remoteMessage.getNotification() != null) { // TODO: Decide if any action is needed here } } }
@Override public void onMessageReceived(RemoteMessage remoteMessage) { // If the application is in the foreground handle both data and notification messages here. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { createNotificationChannel(getApplicationContext()); } // Ignore notifications if alerts are disabled in settings. if (!areAlertsEnabled()) { return; } // Check if message contains a data payload. if (remoteMessage.getData().size() > 0) { Map<String, String> data = remoteMessage.getData(); switch (data.get(TYPE_KEY)) { case CGA_TYPE: onCgaMessageReceived(data); break; case SCORES_UPDATE_TYPE: onScoresUpdateReceived(data); break; } } // Check if message contains a notification payload. if (remoteMessage.getNotification() != null) { // Handle notification. } }