Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Sean12

I am using Ejecta to run a game built using a canvas. I need to be able to send information from the javascript code back to the native iOS code. I've done this previously using a UIWebView and calling this method:

- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
    webView= theWebView;   
    if ([request.URL.absoluteString isEqualToString:@"fake://do_something"])
    {

    }
}

Is it possible to do something similar to this in Ejecta?

Thank you!

1 decade ago by dominic

Yes.

1 decade ago by Sean12

Quote from dominic
Yes.


How exactly do I implement this though? Create my own UIWebView in EJApp.m and js calls from index.js will be able to acces that webView?

1 decade ago by dominic

Well, the article has some example code. You create an Objective-C class with a function that does what you want and then call it from JavaScript. There's no WebView involved.

What do you want to do in native code? Maybe I can give you some more pointers.

1 decade ago by Sean12

The main app is built using phone gap and there are multiple games inside of the app that were originally built in HTML and javascript but weren't running smoothly. Then I came across Ejecta and rebuilt them using canvas. Basically after each game is finished the score needs to be passed back to native iOS because thats where its all databased.

1 decade ago by dominic

Ok. So... where's the problem now? :)

Again, just try the sample code from the article. Using the EJ_BIND_FUNCTION macro you can create a native Obj-C function that you can call from JavaScript.

1 decade ago by Sean12

Alright I see it now. Thank you!
Page 1 of 1
« first « previous next › last »