Capacitor V3: Plugin addEventListener and triggerJSEvent lacking and don't work as described

Damn, this forum is like a graveyard sometimes. Either that or no one actually knows what they’re doing.

So yeah, I ended up doing the following:

  1. Override the load() function in your plugin class
  2. Store a reference to the bridge object
  3. Use that reference to call the trigger events instead.

e.g in your main plugin class:


public class MyPlugin extends Plugin {

    Bridge myBridge;


    @Override
    public void load() {   
        myBridge = bridge;
    }

    @PluginMethod
    public void someCall(PluginCall call) { 
        // do whatever you're doing.
        myBridge.triggerJSEvent(....)
    }

}
3 Likes