當前位置: 首頁>>代碼示例>>Java>>正文


Java RemoteMessage.getFrom方法代碼示例

本文整理匯總了Java中com.google.firebase.messaging.RemoteMessage.getFrom方法的典型用法代碼示例。如果您正苦於以下問題:Java RemoteMessage.getFrom方法的具體用法?Java RemoteMessage.getFrom怎麽用?Java RemoteMessage.getFrom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.firebase.messaging.RemoteMessage的用法示例。


在下文中一共展示了RemoteMessage.getFrom方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //導入方法依賴的package包/類
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    String from = remoteMessage.getFrom();
    switch (from) {
        case "/topics/disturbances":
            handleDisturbanceMessage(remoteMessage);
            break;
        case "/topics/disturbances-debug":
            if (BuildConfig.DEBUG) {
                handleDisturbanceMessage(remoteMessage);
            }
            break;
        default:
            if (from.startsWith("/topics/announcements-")) {
                handleAnnouncementMessage(remoteMessage);
            } else if (BuildConfig.DEBUG && from.startsWith("/topics/announcements-debug-")) {
                handleAnnouncementMessage(remoteMessage);
            }
            break;
    }
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:22,代碼來源:FCMService.java

示例2: 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

示例3: buildMessage

import com.google.firebase.messaging.RemoteMessage; //導入方法依賴的package包/類
private static CharSequence buildMessage(@Nullable RemoteMessage message) {
    if (message == null) {
        return null;
    }

    Truss truss = new Truss();
    final Map<String, String> data = message.getData();
    final String messageId = message.getMessageId();
    if (messageId != null) {
        truss.pushSpan(new StyleSpan(Typeface.BOLD)).append("Id: ").popSpan().append(messageId).append('\n');
    }
    final String messageType = message.getMessageType();
    if (messageType != null) {
        truss.pushSpan(new StyleSpan(Typeface.BOLD)).append("Type: ").popSpan().append(messageType).append('\n');
    }
    final String from = message.getFrom();
    if (from != null) {
        truss.pushSpan(new StyleSpan(Typeface.BOLD)).append("From: ").popSpan().append(from).append('\n');
    }
    final String to = message.getTo();
    if (to != null) {
        truss.pushSpan(new StyleSpan(Typeface.BOLD)).append("To: ").popSpan().append(to).append('\n');
    }
    truss.pushSpan(new StyleSpan(Typeface.BOLD)).append("Time: ").popSpan().append(String.valueOf(message.getSentTime())).append('\n');
    truss.pushSpan(new StyleSpan(Typeface.BOLD)).append("Ttl: ").popSpan().append(message.getTtl()).append('\n');

    Set<String> strings = data.keySet();
    for (String key : strings) {
        truss.append('\n');
        String value = data.get(key);
        truss.pushSpan(new StyleSpan(Typeface.BOLD));
        truss.append(key).append(":\n");
        truss.popSpan();
        try {
            final JSONObject json = new JSONObject(value);
            truss.append(json.toString(2));
        } catch (JSONException e) {
            truss.append(value);
        }
    }

    return truss.build();
}
 
開發者ID:SimonMarquis,項目名稱:FCM-toolbox,代碼行數:44,代碼來源:FcmPayloadActivity.java

示例4: onMessageReceived

import com.google.firebase.messaging.RemoteMessage; //導入方法依賴的package包/類
@Override
public void onMessageReceived(RemoteMessage message) {
    String from = message.getFrom();
    data = message.getData();
    if (PoleNotificationService.onMessageReceived(message, mContext)){
        generateNotification(data);
    }
}
 
開發者ID:poletalks,項目名稱:Pole-Beacon-Android-SDK,代碼行數:9,代碼來源:MyFcmListenerService.java

示例5: onMessageReceived

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

	String from = remoteMessage.getFrom();
	switch (from) {
		case "/topics/v1":
		case "/topics/debug":
			Map<String, String> data = remoteMessage.getData();
			process(data);
			break;
	}
}
 
開發者ID:lambdasoup,項目名稱:blockvote,代碼行數:14,代碼來源:BlockvoteFirebaseMessagingService.java


注:本文中的com.google.firebase.messaging.RemoteMessage.getFrom方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。