darryncampbell / darryncampbell-cordova-plugin-intent

General purpose intent shim layer for cordova appliations on Android. Handles various techniques for sending and receiving intents.
MIT License
86 stars 130 forks source link

Clarification re: Unregistering previous broadcast receivers #131

Closed mattdsteele closed 2 years ago

mattdsteele commented 2 years ago

I'm looking for more details regarding this line in the documentation, under Android Quirks:

Any existing broadcast receiver is unregistered when this method is called. To register for multiple types of broadcast, specify multiple filters.

I'm not sure I understand why this restriction is in place. From what I can tell, there's no limitation at the OS level for registering multiple BroadcastReceiver elements: https://developer.android.com/guide/components/broadcasts#receiving-broadcasts

In particular, this limitation is causing issues in one of our applications, where we have different subsystems of the app, developed by different teams, that need to register separate receivers; and are currently overriding each other.

With the current setup, we'll have to create a new abstraction to ensure we only call intentShim.registerBroadcastReceiver once, but I'd like to avoid this if possible, as it adds a layer of indirection.

Any further technicolor as to why receivers are unregistered would be helpful as we start developing this out. Thank you!

darryncampbell commented 2 years ago

Hi @mattdsteele , that is just how the plugin was implemented, there is no reason it could not be modified to support multiple receivers as you describe but I have no plans to do so myself.

Any further technicolor as to why receivers are unregistered would be helpful as we start developing this out

It was just less work :)

mattdsteele commented 2 years ago

Thanks for the context; I'll work on submitting a pull request for this.