Apache Cordova: raising events from the web view

145
June 11, 2018, at 04:30 AM

new apache cordova dev here.

I have a very simple apache cordova app that is simply a shell for my web project.

In the onDeviceReady event I just go very simple and do:

var url = "http://www.app.com:3000/users/sign_in";

The app is working. Now I wanted my web app to raise notifications in the phone, so I imagined that I could raise an HTML event from my web app to the cordova app and then have the cordova app fire the native notification to the phone using a plugin.

This is nice because the web does not have to include any cordova files, i keep it detached from the cordova tech. It seems like a nice perk.

So I'm trying to dispatch an event from the web:

var customEvent = new CustomEvent("notification", { detail: { message: message, options: options }, bubbles: true });
document.dispatchEvent(customEvent);

And binding it on the cordova app.initialize:

document.addEventListener('notification', this.onNotification.bind(this), false);

But, when I bubble the event from the web, the cordova app is not receiving it. Upon further research, I found that the document object in the cordova app does not seem to be exactly the same than the document object in my web app.

My presumption was that this was very common, but I looked around and I couldn't find many people doing this. Is this possible (bubbling events from the web app to the cordova app)? if not, what is the best way for my web app to communicate with my cordova app?

READ ALSO
npm run build throws error code ELIFECYCLE

npm run build throws error code ELIFECYCLE

I've been following Wes Bos series "ES6 for everyone" for a while now and I got stuck on a webpack episodeWhenever I try to run "npm run build" command on my CMD i get this error:

1065
<Redux> state updated but nor re-render

<Redux> state updated but nor re-render

I just started leaning React Native + ReduxIt seems I successfully updated the state but the view does not change(not re-rendered)

103
Select and display an image from the filesystem with electron

Select and display an image from the filesystem with electron

I'm developing a little app in Electron from which I can upload an image to Instagram and I'm stuck at one of the first steps :/

199
how to get array of products added to cart php

how to get array of products added to cart php

I want to add "add to cart" to this code I know I am a noob programmer but guys, please help me and hints will be appreciated thanks this is the code to create products and display it I am using bootstrap and PHP its is roughly written code but I hope you guys can help me with it thanks

155