You built your app in Sencha Touch, loaded it in a web view wrapper in PhoneGAP.
Now how would your Sencha Touch web app access data from PhoneGAP? since its in a web view?
Example you used PhoneGAP to get UDID, or device contact list etc, how are you suppose to send that to sencha? since its in a webview? Possible? If not what do you do?
An Intent? There is nothing more universal in Android than an Intent.
So Sencha Touch part issues an intent. Your PhoneGap HTML5 WebView catches this Intent. A WebView is still in an Activity. Its just a different type of activity I believe. So the activity webview can processed data/generate data based input or whatever and send out in the bundle of an Intent. Either side could also store in SQLite or SharedPreferences, and just use the intent to notify of the data change or request. Also consider startActivityForResult(intent) to get data back.
First for all Sencha Touch is just the framework you use to build your app.
It doesn't control your application.
If you are using Phonegap as your Webview wrapper. By the way Sencha now also offer a "Native Wrapper".
You would call the various javascript api's which Phonegap will map to its native counterpart. Depending which api you called and if any data was returned you can handle this in a callback.
That's about it, there is need send anything to Sencha as you describe it.
Its more a callback centered just like javascript.
The following links might help you.
http://www.sencha.com/learn/a-sencha-touch-mvc-application-with-phonegap/
http://robertdougan.com/posts/packaging-sencha-touch-2-with-phonegap-cordova
Related
Google oAuth is not supported in android webView. Google recommends to use chrome custom tab for proceeding oAuth. I have also requirements of js call from my web app to native. How to configure to call native methods from web app using chrome custom tab in android similarly like js interface in webView?
Update 1
This mod Chang marked the post as duplicate but the post is different. I don't want to run any JS in my web app from native. I want to invoke method from web app to my native code via JS interface. Is there any way for CCT?
Based on Can I Inject Javascript Code into Chrome Custom Tabs the answer appears to be no.
Chrome Custom Tab is based on Chrome itself and has the same security model. The web content is only allowed access to the Web APIs (camera, device orientation, etc.) and has no access to the native app. At best the native app can capture a URI.
Even the Chrome Custom Tab documentation state that the way for a native app to handle content:
Some URLs can be handled by native applications. If the user has the Twitter app installed and clicks on a link to a tweet. She expects that the Twitter application will handle it.
Before opening an url from your application, check if a native alternative is available and use it.
Implies that either a native app handles a URL or not. My interpretation of Chrome Custom Tab is a skinnable Chrome component adjacent to the native app rather than internal to a native app like a WebView where a Javascript bridge exists.
Your desire for a Javascript bridge from a web app would mean that there would be a arbitrary way for any website code to interact outside of the web container. The rational as to why that is not allowed is given as the responses in the first link.
I'm developing an universal application using Cordova.
I want to add some features, for example authentication via Touch ID (fingerprint auth). In order to do this it's requested not to use a framework/library from Github/Internet so I want to do it in native code (Objective-C for iOS, Java for Android etc).
My problem is: since my app is a standard client application which uses HTML, Javascript (AngularJs) and CSS, how can I invoke some native code within the app life cycle? For example, if I'm inside a specific page (HTML) of my application, can I call an Objective-C method which implements the fingerprint authentication?
Any help is appreciated!
I have website link at which I have designed a html/javascript web app. I used iOS and Android app to create an app that encapsulates the web app.
Is there a way to block access to the website link and only allow access to the website link only thru the native apps calling the link.
In short safari, IE, Chrome must not be able to access the link, but the iPhone & Android app should be able to access it.
Is there some way to tell that the app is accessing the site and not the phone or pc browsers.
I am sure there a number of ways to implement this.
Thanks,
It depends on how is the web app implemented. Since native Web Views are pretty much the wrapper for the standard browser (Safari/Chrome), you will find it tough to filter it based on that.
What you can do, however, is to add an extra GET variable (for ex. &ref=youruniquecodehere) or a custom User-Agent, based on which you will be able to identify, whether your application authorized the request (with a proper access code) or if it's a generic request using browser.
However, both of these options can still be bypassed if researched, although it'd require slightly more time. Not sure whether a solution that would work in 100% of cases exists.
Hope that helps, please correct me if I'm wrong.
I'm building a web app using Three.js (Javascript) and it's VR capabilities for mobile devices (android particullary). The issue I'm facing is that after some time screen gets dimmed and turned off. I was trying to find an API to keep the display on, but couldn't find any mention about it. However, if you go to http://vr.chromeexperiments.com/ and run any of those demos, the screen will be always on. I was trying to study their code but didn't find the solution. How do they do it? Thanks
Add a flag in the onCreate method of your activity.
#Override
protected void onCreate(Bundle b) {
super.onCreate(b);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
Read more here.
If you are running the app from any Browser (like chrome) is not possible to keep the screen awaken since you can't modify the device behavior via Javascript.
You can either get a third party app like KeepScreenOn (https://play.google.com/store/apps/details?id=com.nbondarchuk.android.keepscn&hl=es_419) to do that job or wrap the app inside a Webview using a hybrid App framework like PhoneGap or maybe Titanium. There you can use plug ins to do that job as well (like this one: https://build.phonegap.com/plugins/355)
I'm quite new to xcode, because I mostly work with JS and HTML5. I've decided to create a simple webview app that enables me to work with JS and HTML5 (going to put it on Github asap)
Now my question is about accessing certian iPhone features that I cannot use in Safari or Chrome (the reason why I'm creating this).
So the question is: is this possible? for example, I can't access the camera (as a fullscreen background I mean) in an iOS browser, but can I use it in webview?
You need any method of communicating between UIWebView and the containing app. There are libraries out there that do just that, some better some less. In case you do not want them... So to outline the techniques to do that:
App talking to the webView - using [webView stringByEvaluatingJavaScript:...]
Webview talking to the app - using url directives. Which is essentialy window.location = ... with custom fake urls, and then parsing the NSURLs in the delegate method webView:shouldStartLoadWithRequest:navigationType: and of course returning NO to prevent actually navigating to your fake urls.
If you find that you are missing consecutive URL requests, you could write a JS function that takes the URLs, puts them all in an array, pops one by one and sending them to the browser in a setTimeout(..., 0).
You need to use something like this - Cordova or PhoneGap ( Both are the same thing )
"Apache Cordova is a set of device APIs that allow a mobile app developer to access native device function such as the camera or accelerometer from JavaScript. Combined with a UI framework such as jQuery Mobile or Dojo Mobile or Sencha Touch, this allows a smartphone app to be developed with just HTML, CSS, and JavaScript."
Here is a description of all the device features cordova or phonegap allow you to use - Plugin API's
Yes, is it possible, but using a web app container like Phonegap.
If you need more info how install it visit this web.