Search in sources :

Example 1 with FirebaseMessaging

use of com.google.firebase.messaging.FirebaseMessaging in project react-native-fcm by evollu.

the class FIRMessagingModule method send.

@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());
}
Also used : ReadableMapKeySetIterator(com.facebook.react.bridge.ReadableMapKeySetIterator) RemoteMessage(com.google.firebase.messaging.RemoteMessage) FirebaseMessaging(com.google.firebase.messaging.FirebaseMessaging) ReactMethod(com.facebook.react.bridge.ReactMethod)

Aggregations

ReactMethod (com.facebook.react.bridge.ReactMethod)1 ReadableMapKeySetIterator (com.facebook.react.bridge.ReadableMapKeySetIterator)1 FirebaseMessaging (com.google.firebase.messaging.FirebaseMessaging)1 RemoteMessage (com.google.firebase.messaging.RemoteMessage)1