本文整理汇总了Java中com.google.firebase.messaging.FirebaseMessaging.send方法的典型用法代码示例。如果您正苦于以下问题:Java FirebaseMessaging.send方法的具体用法?Java FirebaseMessaging.send怎么用?Java FirebaseMessaging.send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.firebase.messaging.FirebaseMessaging
的用法示例。
在下文中一共展示了FirebaseMessaging.send方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendMessage
import com.google.firebase.messaging.FirebaseMessaging; //导入方法依赖的package包/类
public void sendMessage (final String data) {
FirebaseMessaging fm = FirebaseMessaging.getInstance();
String token = FirebaseInstanceId.getInstance().getToken();
String msgID = DigestUtils.sha1Hex(token + System.currentTimeMillis());
String SENDER_ID = "someID";
RemoteMessage.Builder RMBuilder =
new RemoteMessage.Builder(SENDER_ID + "@gcm.googleapis.com");
RMBuilder.setMessageId(msgID);
Map<String, Object> mapData = Utils.jsonToMap(data);
for (Map.Entry<String, Object> entry : mapData.entrySet()) {
RMBuilder.addData(entry.getKey(), entry.getValue().toString());
}
fm.send(RMBuilder.build());
}
示例2: send
import com.google.firebase.messaging.FirebaseMessaging; //导入方法依赖的package包/类
@ReactMethod
public void send(String senderId, ReadableMap payload) throws Exception {
FirebaseMessaging fm = FirebaseMessaging.getInstance();
RemoteMessage.Builder message = new RemoteMessage.Builder(senderId + "@gcm.googleapis.com")
.setMessageId(UUID.randomUUID().toString());
ReadableMapKeySetIterator iterator = payload.keySetIterator();
while (iterator.hasNextKey()) {
String key = iterator.nextKey();
String value = getStringFromReadableMap(payload, key);
message.addData(key, value);
}
fm.send(message.build());
}
示例3: fmSend
import com.google.firebase.messaging.FirebaseMessaging; //导入方法依赖的package包/类
private static void fmSend(Bundle data) {
final FirebaseMessaging fm = FirebaseMessaging.getInstance();
if (senderid != null) {
fm.send(new RemoteMessage.Builder(senderid + "@gcm.googleapis.com")
.setMessageId(Integer.toString(msgId.incrementAndGet()))
.setData(JoH.bundleToMap(data))
.build());
} else {
Log.wtf(TAG, "senderid is null");
}
}
示例4: send
import com.google.firebase.messaging.FirebaseMessaging; //导入方法依赖的package包/类
@ReactMethod
public void send(String senderId, String messageId, String messageType, ReadableMap params, final Callback callback) {
FirebaseMessaging fm = FirebaseMessaging.getInstance();
RemoteMessage.Builder remoteMessage = new RemoteMessage.Builder(senderId);
remoteMessage.setMessageId(messageId);
remoteMessage.setMessageType(messageType);
ReadableMapKeySetIterator iterator = params.keySetIterator();
while (iterator.hasNextKey()) {
String key = iterator.nextKey();
ReadableType type = params.getType(key);
if (type == ReadableType.String) {
remoteMessage.addData(key, params.getString(key));
Log.d(TAG, "Firebase send: " + key);
Log.d(TAG, "Firebase send: " + params.getString(key));
}
}
try {
fm.send(remoteMessage.build());
WritableMap res = Arguments.createMap();
res.putString("status", "success");
callback.invoke(null, res);
} catch(Exception e) {
Log.e(TAG, "Error sending message", e);
WritableMap error = Arguments.createMap();
error.putString("code", e.toString());
error.putString("message", e.toString());
callback.invoke(error);
}
}
示例5: run
import com.google.firebase.messaging.FirebaseMessaging; //导入方法依赖的package包/类
@Override
public void run() {
FirebaseMessaging fcm = FirebaseMessaging.getInstance();
AtomicInteger msgId = new AtomicInteger();
String id = Integer.toString(msgId.incrementAndGet());
fcm.send(new RemoteMessage.Builder(gcmSenderId+"@gcm.googleapis.com")
.setMessageId(id)
.addData(ACTION, DISMISS_NOTIFICATION)
.addData(NID, nid)
.build());
}