本文整理匯總了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;
}
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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;
}
}