Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile extensions #59

Open
obastemur opened this issue Aug 11, 2015 · 4 comments
Open

Mobile extensions #59

obastemur opened this issue Aug 11, 2015 · 4 comments

Comments

@obastemur
Copy link
Member

We need an interface triggered by JXcore JavaScript to set the details for native extensions used by mobile application.

This item is under development and the expected usage is as shared below;

Mobile.loadNativeExtension(String class, String method_definition, Object options)

class (String): Name of the class
method_name (String): sub method name
options: (Object) list of platform specific options

Important: This will be a breaking change for the applications using their own extension.

@tillmannheigel
Copy link

This is a very interesting feature. At the moment I'm trying to load a native extension from the node server side of my application. Is this the right approach to do this?

  1. Register method from UI to jxcore instance (index.js)
    jxcore('someNativeExtension').register(someTriggerMethod);

(where the trigger does something like cordova.exec(...);)

  1. Start Node (index.js)
    jxcore('app.js').loadMainFile(callback);

(after this step I move to another index.html, that is served by express.js:
=> window.open('http://localhost:8080/apps/backend/index.html','_blank');)

  1. Call method from Node (app.js)
    Mobile('someNativeExtension').call();

But this snippet doesn't work, because it seems, that cordova.js isn't present, after I get on to another page. Do you have Any Idea, how to fix this?

@obastemur
Copy link
Member Author

That index.html also has an initialization logic written for cordova + jxcore right ?

@tillmannheigel
Copy link

Hi, there is'nt any initalization logic in the backend/index.html, because it is served by express.js. I can't reach cordova.js, which is located in my www directory. The Express.js is serving only www/jx/client/ directory.

I tried to reach window.cordova, but it's undefined. But I can reach this._cordovaNative. Does this help at all?

Thx for your help!
Tillmann

@ktrzeciaknubisa
Copy link
Member

@tillmannheigel The reason is probably cross-domain security (or same-origin policy) between the two windows. The window.cordova cannot work in new window, probably more proper would be window.parent.cordova. However this still fall under the mentioned restrictions.

There may be available workarounds though. You may try to implement Cross-window messaging with postMessage. Probably the logic would be: window B sends postMessage to window A, and from there you may call Mobile('someNativeExtension').call(); etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants