Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

223
Vistas
React Native native module - trigger JS event from launched Activity?

I have a custom react-native module that has an SDK which launches an activity. I want to execute JS code while the SDK's activity is running via an "onFormSubmit" event/callback.

My native module has a service that the activity uses:

class MyService : SDKService() {
  companion object {
    private var instance: MyService? = null

    fun getInstance() : MyService? {
      return instance
    }
  }
  // ...

  override fun onSDKFormSubmitRequest(actionState: SDKActionState<*>, formJSON: JSONObject) {
    val instance = MyModule.getInstance()
    val event = RNUtils.jsonToWritableMap(formJSON)

    if (event != null && instance != null) {
      instance.onFormSubmit(event, this) // <-- the important part
    }
  }
  // ...
}

In my native module:

// ...
  @ReactMethod
  fun onFormSubmit(event: WritableMap, service: MyService) {
    this._service = service
    this.reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent( // <-- the important part
      this._view!!.id,
      "onFormSubmit",
      event
    )
  }
// ...

It seems the main activity (the android app) gets app state "background" when the native module opens the activity. I suspect that causes the main activity to be suspended because I get the following error when my JS event is supposed to run:

W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([3,"onFormSubmit",{"data":"***"}])

I want to be able to run the onFormSubmit while the SDK's activity is running and THEN close the SDK's activity. I want to be able to make network requests in the JS part with onFormSubmit so I can reuse my requests logic. Is there some way to do this?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda