Tengo un módulo nativo de reacción personalizado que tiene un SDK que inicia una actividad. Quiero ejecutar el código JS mientras la actividad del SDK se ejecuta a través de un evento/devolución de llamada "onFormSubmit".
Mi módulo nativo tiene un servicio que usa la actividad:
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 } } // ... }En mi módulo nativo:
// ... @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 ) } // ...Parece que la actividad principal (la aplicación de Android) obtiene el "fondo" del estado de la aplicación cuando el módulo nativo abre la actividad. Sospecho que eso hace que se suspenda la actividad principal porque aparece el siguiente error cuando se supone que se ejecuta mi evento JS:
W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([3,"onFormSubmit",{"data":"***"}]) Quiero poder ejecutar onFormSubmit mientras se ejecuta la actividad del SDK y LUEGO cerrar la actividad del SDK. Quiero poder realizar solicitudes de red en la parte JS con onFormSubmit para poder reutilizar la lógica de mis solicitudes. Hay alguna manera de hacer esto?