Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

215
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!