bsorrentino / cordova-broadcaster

Cordova Plugin to allow message exchange between javascript and native (and viceversa)
MIT License
113 stars 53 forks source link

how to use this plugin in Ionic2? #9

Closed Coder7777 closed 7 years ago

Coder7777 commented 7 years ago

very less doc to descript how to use cordova broadcaster in Ionic2? Could please offer a full demo?

mebibou commented 7 years ago

Same way you would use it in ionic 1

bsorrentino commented 7 years ago

Hi

I don't use Ionic 1/2 for app development, so I haven't tech details about what you are asking

I don't think that, for using such plugin in ionic, there are particular issues ... however if you gather Help & HowTo related it, please share with me

mebibou commented 7 years ago

So basically you can do:

ionic plugin add add cordova-plugin-broadcaster

Then in your code just use the JS samples as provided, like window.broadcaster.addEventListener('eventName', event => console.log(event));. If typescript complains about broadcaster not defined on Windows, just declare the interface like:

interface Windows {
  broadcaster: any;
}

FYI, I submitted a PR to add the Broadcaster support in ionic native

bsorrentino commented 7 years ago

Looks great ... I'll watch the progress

bsorrentino commented 7 years ago

such plugin has been added to ionic-native distribution How to is available here