@Override public void onMessageReceived(RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); PLog.d(ParseFCM.TAG, "onMessageReceived"); String pushId = remoteMessage.getData().get("push_id"); String timestamp = remoteMessage.getData().get("time"); String dataString = remoteMessage.getData().get("data"); String channel = remoteMessage.getData().get("channel"); JSONObject data = null; if (dataString != null) { try { data = new JSONObject(dataString); } catch (JSONException e) { PLog.e(ParseFCM.TAG, "Ignoring push because of JSON exception while processing: " + dataString, e); return; } } PushRouter.getInstance().handlePush(pushId, timestamp, channel, data); } }
@Override public void onMessageReceived(RemoteMessage remoteMessage) { Log.i(TAG, "Message data:" + remoteMessage.getData()); if (remoteMessage.getData().size() > 0) { if (MobiComPushReceiver.isMobiComPushNotification(remoteMessage.getData())) { Log.i(TAG, "Applozic notification processing..."); MobiComPushReceiver.processMessageAsync(this, remoteMessage.getData()); return; } } }
private static void logPushBundle(RemoteMessage remoteMessage) { Map<String, String> data = remoteMessage.getData(); Log.e(ExampleApplication.TAG, "Push Data:"); for (String key : data.keySet()) { String value = data.get(key); Log.e(ExampleApplication.TAG, " " + key + " : " + value); } Log.e(ExampleApplication.TAG, data.get("title") + ": " + data.get("body")); } }
@Override public void onMessageReceived(RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); final String requestId = remoteMessage.getData().get(ZD_REQUEST_ID_KEY); final String message = remoteMessage.getData().get(ZD_MESSAGE_KEY); if (StringUtils.hasLengthMany(requestId, message)) { handleZendeskSdkPush(requestId, message); } }
@Override public void onMessageReceived(RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); String message = remoteMessage.getData().get("message"); Log.d(TAG, "From: " + remoteMessage.getFrom()); Log.d(TAG, "Message: " + message); //Check first if notification related to Instabug or not if (Instabug.isInstabugNotification(remoteMessage.getData())) { //Shown notification related to Instabug Instabug.showNotification(remoteMessage.getData()); } else { sendNotification(message); } }
/** * Called when message is received. * * @param remoteMessage Object representing the message received from Firebase Cloud Messaging. */ @Override public void onMessageReceived(RemoteMessage remoteMessage) { Log.d(TAG, "Received onMessageReceived()"); Log.d(TAG, "Bundle data: " + remoteMessage.getData()); Log.d(TAG, "From: " + remoteMessage.getFrom()); // Check if message contains a data payload. if (remoteMessage.getData().size() > 0) { Map<String, String> data = remoteMessage.getData(); final int notificationId = (int) System.currentTimeMillis(); Voice.handleMessage(this, data, new MessageListener() { @Override public void onCallInvite(CallInvite callInvite) { VoiceFirebaseMessagingService.this.notify(callInvite, notificationId); VoiceFirebaseMessagingService.this.sendCallInviteToActivity(callInvite, notificationId); } @Override public void onError(MessageException messageException) { Log.e(TAG, messageException.getLocalizedMessage()); } }); } }
if (remoteMessage.getData().size() > 0) { Log.d(TAG, "Message data payload: " + remoteMessage.getData()); String title = remoteMessage.getData().get("title"); String message = remoteMessage.getData().get("text"); String username = remoteMessage.getData().get("username"); String uid = remoteMessage.getData().get("uid"); String fcmToken = remoteMessage.getData().get("fcm_token");
@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 remoteMessage) { super.onMessageReceived(remoteMessage); EMLog.e(TAG, "EMFCMMSGService#onMessageReceived:" + remoteMessage.toString()); if (remoteMessage.getData().size() > 0) { String message = remoteMessage.getData().get("alert"); Log.i(TAG, "onMessageReceived: " + message); EMLog.e(TAG, "EMFCMMSGService#onMessageReceived"); UIProvider.getInstance().getNotifier().sendNotification(message); } } }
@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); 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 } } }
Bitmap bitmap = getBitmapfromUrl(remoteMessage.getData().get("image-url")); likeIntent.putExtra(IMAGE_URL_EXTRA,remoteMessage.getData().get("image-url")); PendingIntent likePendingIntent = PendingIntent.getService(this, notificationId+1,likeIntent,PendingIntent.FLAG_ONE_SHOT); .setLargeIcon(bitmap) .setSmallIcon(R.mipmap.ic_launcher) .setContentTitle(remoteMessage.getData().get("title")) .setStyle(new NotificationCompat.BigPictureStyle() .setSummaryText(remoteMessage.getData().get("message")) .setContentText(remoteMessage.getData().get("message")) .setAutoCancel(true) .setSound(defaultSoundUri)
@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 } } }
String from_user_id = remoteMessage.getData().get("from_user_id");
/** * Creates a {@link Notification} object from @{@link RemoteMessage} by extracting parameters * from data * * @param remoteMessage {@link RemoteMessage} received from fo=irebase clud messaging * @return A {@link Notification} representing the notification received */ private Notification createNotificationObject(@NonNull RemoteMessage remoteMessage) { Map<String, String> receivedData = remoteMessage.getData(); Notification notification = new Notification(); notification.setTitle(receivedData.get(AppConstants.KEY_TITLE)); notification.setAction(receivedData.get(AppConstants.KEY_ACTION)); notification.setDescription(receivedData.get(AppConstants.KEY_DESCRIPTION)); notification.setFrom(receivedData.get(AppConstants.KEY_FROM)); notification.setType(receivedData.get(AppConstants.KEY_TYPE)); notification.setTimeStamp(System.currentTimeMillis() / 1000); notification.setExtra1(receivedData.get(AppConstants.KEY_EXTRA_1)); notification.setExtra2(receivedData.get(AppConstants.KEY_EXTRA_2)); return notification; }
@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. } }
@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.info("From: " + remoteMessage.getFrom()); String notificationBase64 = remoteMessage.getData().get("notification"); if (notificationBase64 == null) { log.info("Notification is null, ignoring."); return; } Notification notification; try { notification = Notification.ADAPTER.decode(Base64.decode(notificationBase64, 0)); } catch (IOException e) { log.warning("Error decoding notification, dropping.", e); return; } if (notification.debug_message != null) { App.i.getTaskRunner().runTask(() -> Toast.makeText(App.i, notification.debug_message, Toast.LENGTH_LONG).show(), Threads.UI); } // TODO: handle other kinds of toasts. }
@Override public void onMessageReceived(RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); Log.e(ExampleApplication.TAG, "onMessageReceived()"); logPushBundle(remoteMessage); final Map<String, String> data = remoteMessage.getData(); if (Apptentive.isApptentivePushNotification(data)) { Apptentive.buildPendingIntentFromPushNotification(new Apptentive.PendingIntentCallback() { @Override public void onPendingIntent(PendingIntent pendingIntent) { if (pendingIntent != null) { String title = Apptentive.getTitleFromApptentivePush(data); String body = Apptentive.getBodyFromApptentivePush(data); ApptentiveLog.e("Title: " + title); ApptentiveLog.e("Body: " + body); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(MyFirebaseMessagingService.this) .setSmallIcon(R.drawable.notification) .setContentTitle(title) .setContentText(body) .setAutoCancel(true) .setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notificationBuilder.build()); } } }, data); } }
final Notification notification = createNotification(message.getData()); if (notification == null) {