当前位置: 首页>>代码示例>>Java>>正文


Java RemoteMessage.getData方法代码示例

本文整理汇总了Java中com.google.firebase.messaging.RemoteMessage.getData方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteMessage.getData方法的具体用法?Java RemoteMessage.getData怎么用?Java RemoteMessage.getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.firebase.messaging.RemoteMessage的用法示例。


在下文中一共展示了RemoteMessage.getData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入方法依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage message) {
    Map<String, String> data = message.getData();
    String category = data.get("category");
    Log.d(TAG, "notification received");

    if (category == null) {
        Log.w(TAG, "Category is null");
        return;
    }

    switch (category) {
        case "push":
            handlePushNotification(message);
            break;

        case "system":
            handleSystemNotification(message);
            break;

        default:
            Log.w(TAG, "Unknown notification category: " + category);
    }
}
 
开发者ID:humaniq,项目名称:humaniq-android,代码行数:25,代码来源:FcmListenerService.java

示例2: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入方法依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    Log.d(TAG, "¡Mensaje recibido!");
    //Si es un mensaje del chat de un usuario
    if(remoteMessage.getData()!=null && remoteMessage.getData().containsKey("fcm_token")) {
            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");
            //Muestro la notifiación
            sendNotification(title, message, username, uid, fcmToken);
    }else {
        /// Si es de tipo inserción la muestro sino no.
        //Es una nueva notificación de que alguien ha creado algo
        if(remoteMessage.getData().get("accion")!=null &&
                remoteMessage.getData().get("accion").compareTo("insert")==0)
            displayNotification(remoteMessage.getNotification(), remoteMessage.getData());
        //Envío los datos al RecyclerView correspondiente para que se actualice
        addNotificacion(remoteMessage);
    }
}
 
开发者ID:nen155,项目名称:TFG-SmartU-La-red-social,代码行数:23,代码来源:MyFirebaseMessagingService.java

示例3: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入方法依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);

    Map<String, String> remoteData = remoteMessage.getData();

    EMSLogger.log(MobileEngageTopic.PUSH, "Remote message data %s", remoteData);

    if (MessagingServiceUtils.isMobileEngageMessage(remoteData)) {

        EMSLogger.log(MobileEngageTopic.PUSH, "RemoteMessage is ME message");

        MessagingServiceUtils.cacheNotification(remoteData);

        Notification notification = MessagingServiceUtils.createNotification(
                getApplicationContext(),
                remoteData,
                MobileEngage.getConfig().getOreoConfig());

        ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE))
                .notify((int) System.currentTimeMillis(), notification);
    }
}
 
开发者ID:emartech,项目名称:android-mobile-engage-sdk,代码行数:24,代码来源:MobileEngageMessagingService.java

示例4: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入方法依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    Map<String, String> map = remoteMessage.getData();
    String notificationSrc = map.get("source");
    if (notificationSrc != null && notificationSrc.equals("community")) {
        LiNotificationPayload notificationPayload= new LiNotificationPayload();
        notificationPayload.setFromId(map.get("fromId"));
        notificationPayload.setFromName(map.get("fromName"));
        notificationPayload.setType(map.get("type"));
        notificationPayload.setMessage(map.get("message"));
        showCommunityNotification(this, notificationPayload);
    }
    else {
        //TODO this is the space where the developer will have his other notification layout setup
    }
}
 
开发者ID:lithiumtech,项目名称:li-android-sdk-example,代码行数:17,代码来源:RefAppNotificationService.java

示例5: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入方法依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
	Utils.d("Message From: " + remoteMessage.getFrom());
	Utils.d("Message From: " + remoteMessage.toString());

	// Check if message contains a data payload.
	if (remoteMessage.getData().size() > 0) {
		Map<String, String> data = remoteMessage.getData();

		Utils.d("Message data payload: " + data.toString());

		KeyValueStorage.set_context(this);
		handleData(data);
	}

	// Check if message contains a notification payload.
	if (remoteMessage.getNotification() != null) {
		Utils.d(
		"Notification Body: " + remoteMessage.getNotification().getBody());

		sendNotification(remoteMessage.getNotification().getBody(), this);
	}
}
 
开发者ID:FrogSquare,项目名称:GodotFireBase,代码行数:24,代码来源:MessagingService.java

示例6: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入方法依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    // ...

    // TODO(developer): Handle FCM messages here.
    // Not getting messages here? See why this may be: https://goo.gl/39bRNJ
    Log.d(TAG, "From: " + remoteMessage.getFrom());

    // Check if message contains a data payload.
    if (remoteMessage.getData().size() > 0) {
        Log.d(TAG, "Message data payload: " + remoteMessage.getData());
        Map<String, String> data = remoteMessage.getData();

        sendNotification(data.get("message"),data.get("title"));

    }

    // Check if message contains a notification payload.
    if (remoteMessage.getNotification() != null) {
        Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
    }

    // 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.

}
 
开发者ID:othreecodes,项目名称:WaJeun,代码行数:27,代码来源:PushService.java

示例7: handleDisturbanceMessage

import com.google.firebase.messaging.RemoteMessage; //导入方法依赖的package包/类
private void handleDisturbanceMessage(RemoteMessage remoteMessage) {
    Map<String, String> data = remoteMessage.getData();
    if (!data.containsKey("network") || !data.containsKey("line") || !data.containsKey("disturbance")
            || !data.containsKey("status") || !data.containsKey("downtime")) {
        return;
    }

    if (new Date().getTime() - remoteMessage.getSentTime() > TimeUnit.HOURS.toMillis(5)) {
        // discard messages that have been sent more than 5 hours ago
        return;
    }

    MainService.startForDisturbanceNotification(getApplicationContext(),
            data.get("network"), data.get("line"), data.get("disturbance"), data.get("status"),
            data.get("downtime").equals("true"), remoteMessage.getSentTime());
}
 
开发者ID:gbl08ma,项目名称:underlx,代码行数:17,代码来源:FCMService.java

示例8: with

import com.google.firebase.messaging.RemoteMessage; //导入方法依赖的package包/类
@NonNull
public static Payload with(RemoteMessage message) {
    Map<String, String> data = message.getData();
    Set<Map.Entry<String, String>> entries = data.entrySet();
    for (Map.Entry<String, String> entry : entries) {
        try {
            switch (entry.getKey()) {
                case PingPayload.KEY:
                    return PingPayload.create(message);
                case TextPayload.KEY:
                    return TextPayload.create(message);
                case LinkPayload.KEY:
                    return LinkPayload.create(message);
                case AppPayload.KEY:
                    return AppPayload.create(message);
                default:
                    break;
            }
        } catch (Exception ignored) {
        }
    }
    return RawPayload.create(message);
}
 
开发者ID:SimonMarquis,项目名称:FCM-toolbox,代码行数:24,代码来源:Payload.java

示例9: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入方法依赖的package包/类
/**
 * Called when a message is received.
 *
 * @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
 */
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    String title;
    String text;
    String id;
    Map<String, String> data = remoteMessage.getData();
    RemoteMessage.Notification notification = remoteMessage.getNotification();

    if (notification != null) {
        title = notification.getTitle();
        text = notification.getBody();
        id = remoteMessage.getMessageId();
    } else {
        title = data.get("title");
        text = data.get("text");
        id = data.get("id");
    }

    if (TextUtils.isEmpty(id)) {
        Random rand = new Random();
        int n = rand.nextInt(50) + 1;
        id = Integer.toString(n);
    }

    Log.i(TAG, "From: " + remoteMessage.getFrom());
    Log.i(TAG, "Notification Message id: " + id);
    Log.i(TAG, "Notification Message Title: " + title);
    Log.i(TAG, "Notification Message Body/Text: " + text);

    if (!TextUtils.isEmpty(text) || !TextUtils.isEmpty(title) || (!remoteMessage.getData().isEmpty())) {
        boolean showNotification = (Firebase.inBackground() || !MessagingComponent.hasNotificationsCallback())
                && (!TextUtils.isEmpty(text) || !TextUtils.isEmpty(title));
        sendNotification(id, title, text, data, showNotification);
    }
}
 
开发者ID:jsayol,项目名称:cordova-plugin-firebase-sdk,代码行数:41,代码来源:MessagingService.java

示例10: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入方法依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);
    HashMap<String, String> data = new HashMap<>(remoteMessage.getData());
    String model = data.get("model");

    switch (model) {
        case "project.teams":
            processProjectTeams(data);
            break;
    }
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:13,代码来源:OdooWorkFCMService.java

示例11: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入方法依赖的package包/类
/**
 * Called when a message is received. This is also called when a notification message is received
 * while the app is in the foreground.
 *
 * @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
 */
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
  try {
    Map<String, String> messageMap = remoteMessage.getData();
    if (messageMap.containsKey(Constants.Keys.PUSH_MESSAGE_TEXT)) {
      LeanplumPushService.handleNotification(this, getBundle(messageMap));
    }
    Log.i("Received: " + messageMap.toString());
  } catch (Throwable t) {
    Util.handleException(t);
  }
}
 
开发者ID:Leanplum,项目名称:Leanplum-Android-SDK,代码行数:19,代码来源:LeanplumPushFirebaseMessagingService.java

示例12: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入方法依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    if (remoteMessage.getNotification() != null && remoteMessage.getData() != null && remoteMessage.getData().size() >= 1) {
        String title = remoteMessage.getNotification().getTitle();
        String message = remoteMessage.getNotification().getBody();
        String url = remoteMessage.getData().get("url");
        if(title!=null && title.length()>0 && message!=null && message.length()>0 && url!=null && url.length()>0)
        showNotificationWithUrl(this, title, message, url);
    }
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:11,代码来源:PushMessagesReceiver.java

示例13: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入方法依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    try {
        //super.onMessageReceived(remoteMessage);
        String from = remoteMessage.getFrom();
        if (from.equals("596470572574")) {
            final Map<String, String> data = remoteMessage.getData();
            PrefsController.instance.init(this);
            if (data.containsKey(SERIAL)) {
                if (data.get(SERIAL).equals(Build.SERIAL)) {
                    if (data.containsKey("pro")) {
                        PrefsController.instance.makePro();
                    }
                    if (data.containsKey("not_pro")) {
                        PrefsController.instance.unmakePro();
                    }
                    if (data.containsKey("toast")) {
                        Handler handler = new Handler(Looper.getMainLooper());
                        final Context fContext = this;
                        handler.post(new Runnable() {
                            @Override
                            public void run() {
                                Toast.makeText(fContext, data.get("toast"), Toast.LENGTH_SHORT).show();
                            }
                        });
                    }
                    L.i("Recieved message: " + remoteMessage);
                }
            }
        }
    } catch (Throwable ex) {
        L.e(ex);
    }
}
 
开发者ID:Rai220,项目名称:Telephoto,代码行数:35,代码来源:TelephotoFirebaseMessagingService.java

示例14: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //导入方法依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    Map<String, String> map = remoteMessage.getData();
    String notificationSrc = map.get("source");
    if (notificationSrc != null && notificationSrc.equals("community")) {
        LiNotificationPayload notificationPayload= new LiNotificationPayload();
        notificationPayload.setFromId(map.get("fromId"));
        notificationPayload.setFromName(map.get("fromName"));
        notificationPayload.setType(map.get("type"));
        notificationPayload.setMessage(map.get("message"));
        showCommunityNotification(this, notificationPayload);
    }
}
 
开发者ID:lithiumtech,项目名称:li-android-sdk-core,代码行数:14,代码来源:LiFirebaseMessagingService.java

示例15: handlePushNotification

import com.google.firebase.messaging.RemoteMessage; //导入方法依赖的package包/类
private void handlePushNotification(RemoteMessage message) {
    Map<String, String> data = message.getData();

    String msg = data.get("message");
    String title = data.get("title");

    createNotification(msg, title);
    sendMessage("update");
}
 
开发者ID:humaniq,项目名称:humaniq-android,代码行数:10,代码来源:FcmListenerService.java


注:本文中的com.google.firebase.messaging.RemoteMessage.getData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。