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


Java FirebaseMessaging.send方法代碼示例

本文整理匯總了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());
}
 
開發者ID:FrogSquare,項目名稱:GodotFireBase,代碼行數:20,代碼來源:Notification.java

示例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());
}
 
開發者ID:evollu,項目名稱:react-native-fcm,代碼行數:15,代碼來源:FIRMessagingModule.java

示例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");
    }
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:12,代碼來源:GcmActivity.java

示例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);
    }
}
 
開發者ID:fullstackreact,項目名稱:react-native-firestack,代碼行數:30,代碼來源:FirestackCloudMessaging.java

示例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());

}
 
開發者ID:ibm-bluemix-mobile-services,項目名稱:bms-clientsdk-android-push,代碼行數:14,代碼來源:MFPPush.java


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