Search in sources :

Example 6 with ReadableMapKeySetIterator

use of com.facebook.react.bridge.ReadableMapKeySetIterator 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)

Example 7 with ReadableMapKeySetIterator

use of com.facebook.react.bridge.ReadableMapKeySetIterator in project react-native-fbsdk by facebook.

the class FBGraphRequestModule method buildParameters.

private Bundle buildParameters(ReadableMap parameterMap) {
    Bundle parameters = new Bundle();
    ReadableMapKeySetIterator keyIterator = parameterMap.keySetIterator();
    while (keyIterator.hasNextKey()) {
        String key = keyIterator.nextKey();
        ReadableMap parameter = parameterMap.getMap(key);
        if (parameter.hasKey("string")) {
            parameters.putString(key, parameter.getString("string"));
        }
    }
    return parameters;
}
Also used : ReadableMapKeySetIterator(com.facebook.react.bridge.ReadableMapKeySetIterator) Bundle(android.os.Bundle) ReadableMap(com.facebook.react.bridge.ReadableMap)

Example 8 with ReadableMapKeySetIterator

use of com.facebook.react.bridge.ReadableMapKeySetIterator in project react-native-fbsdk by facebook.

the class Utility method buildShareOpenGraphAction.

public static ShareOpenGraphAction buildShareOpenGraphAction(ReadableMap shareOpenGraphActionMap) {
    ShareOpenGraphAction.Builder contentBuilder = new ShareOpenGraphAction.Builder();
    contentBuilder.setActionType(shareOpenGraphActionMap.getString("actionType"));
    ReadableMap properties = shareOpenGraphActionMap.getMap("_properties");
    ReadableMapKeySetIterator keySetIterator = properties.keySetIterator();
    while (keySetIterator.hasNextKey()) {
        String key = keySetIterator.nextKey();
        ReadableMap entry = properties.getMap(key);
        contentBuilder.putObject(key, buildShareOpenGraphObject(entry.getMap("value")));
    }
    return contentBuilder.build();
}
Also used : ReadableMapKeySetIterator(com.facebook.react.bridge.ReadableMapKeySetIterator) ShareOpenGraphAction(com.facebook.share.model.ShareOpenGraphAction) ReadableMap(com.facebook.react.bridge.ReadableMap)

Example 9 with ReadableMapKeySetIterator

use of com.facebook.react.bridge.ReadableMapKeySetIterator in project react-native-fbsdk by facebook.

the class Utility method buildShareOpenGraphObject.

public static ShareOpenGraphObject buildShareOpenGraphObject(ReadableMap entry) {
    ShareOpenGraphObject.Builder contentBuilder = new ShareOpenGraphObject.Builder();
    ReadableMap value = entry.getMap("_properties");
    ReadableMapKeySetIterator keySetIterator = value.keySetIterator();
    while (keySetIterator.hasNextKey()) {
        String key = keySetIterator.nextKey();
        ReadableMap subEntry = value.getMap(key);
        switch(subEntry.getString("type")) {
            case "number":
                contentBuilder.putDouble(key, subEntry.getDouble("value"));
                break;
            case "open-graph-object":
                contentBuilder.putObject(key, buildShareOpenGraphObject(subEntry.getMap("value")));
                break;
            case "photo":
                contentBuilder.putPhoto(key, buildSharePhoto(subEntry.getMap("value")));
                break;
            case "string":
                contentBuilder.putString(key, subEntry.getString("value"));
                break;
        }
    }
    return contentBuilder.build();
}
Also used : ReadableMapKeySetIterator(com.facebook.react.bridge.ReadableMapKeySetIterator) ShareOpenGraphObject(com.facebook.share.model.ShareOpenGraphObject) ReadableMap(com.facebook.react.bridge.ReadableMap)

Aggregations

ReadableMapKeySetIterator (com.facebook.react.bridge.ReadableMapKeySetIterator)9 ReadableMap (com.facebook.react.bridge.ReadableMap)4 Bundle (android.os.Bundle)3 Uri (android.net.Uri)1 GLException (android.opengl.GLException)1 ReactMethod (com.facebook.react.bridge.ReactMethod)1 ReadableArray (com.facebook.react.bridge.ReadableArray)1 ReadableType (com.facebook.react.bridge.ReadableType)1 ShareOpenGraphAction (com.facebook.share.model.ShareOpenGraphAction)1 ShareOpenGraphObject (com.facebook.share.model.ShareOpenGraphObject)1 FirebaseMessaging (com.google.firebase.messaging.FirebaseMessaging)1 RemoteMessage (com.google.firebase.messaging.RemoteMessage)1 FloatBuffer (java.nio.FloatBuffer)1 IntBuffer (java.nio.IntBuffer)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 JSONObject (org.json.JSONObject)1