1

I'm trying to pass data into React Native from native Android. The data is an array of objects which consist of actions that should be dispatched. Example

{
  "actions: [
    { 
      "authenticationType: "strong",
      "type: "AUTHENTICATION_URL",
      "url: "https://foo.bar/",
    },
  ],
}

I'm trying to use the com.facebook.react.bridge.Arguments class to do something like

val arguments = Arguments.createMap().apply {
  putString("path", "general/authentication")  
  putArray("actions",
           Arguments.fromList(listOf(
                   mapOf("authenticationType" to "strong",
                         "type" to "AUTHENTICATION_URL",
                         "url" to url
                   ))))
}

but it only results in

09-14 20:08:53.996 10437 10437 I zygote  : Thread[1,tid=10437,Native,Thread*=0xb18da000,peer=0x73d2f568,"main"] recursive attempt to load library "/data/app/com.getdreams-MO6VYrPeHVgAkBP2ori8SA==/lib/x86/libfb.so"

Unsure how to create that array of javascript objects.

Has anyone any suggestion of how to perhaps use com.facebook.react.bridge.Arguments in a better way?

1 Answer 1

2

I did solve this only moments later by using the Arguments class, like so

val action = Arguments.makeNativeMap(
  mutableMapOf("authenticationType" to "strong",
               "type" to "AUTHENTICATION_URL",
               "url" to url) as Map<String, Any>)

val actionArray = Arguments.makeNativeArray(listOf(action))

val arguments = Arguments.createMap().apply {
    putString("path", "general/authentication")
    putArray("actions",actionArray)
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.