Skip to content

Ionic 5 + Capacitor - How to implement external broadcaster ?  #72

@givemesumthing

Description

@givemesumthing

How to implement external broadcaster , i.e. send data from one app to another ?

I have tried :-

From App 1 :-

        let options1 = {
          filterActions: ['com.example.APPS_TOKEN'],
          extras: {
            'param1': 'abc',
            'param2': 'xyz'
          }
        };
      if (this.platform.is('android') && this.platform.is('capacitor')) {
        var isGlobal = true
        this.broadcaster.fireNativeEvent("APPS_TOKEN", isGlobal, options1).then(res => {
          console.log("event fired!");
        })

And in App 2 :-

 let listener = function( e ) {
      console.log( "APPS_TOKEN received! userInfo: " + JSON.stringify(e)  );
    }
    
    this.broadcaster.addEventListener( "APPS_TOKEN").subscribe( listener );
    

But here data is not being sent to second app .

Is there a sample or documentation for it ?
Also, do we need to set up anything in AndroidManifest.xml file ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions