Cordova / Phonegap Globalization vs. navigator.language - javascript

I want to implement some mechanism to automatically selecting UI language for my Cordova application. The application is also served from the web (i.e. browser).
From what I see, I can either use the Cordova globalization API plugin (here) or, it seems that both Android and iOS support navigator.language which give the device language.
Is there any reason I should opt to use the Cordova plugin over the built in browser/Web View property?
Thanks!

After a series of searches and tests on real devices I can say that the two methods to retrieve the language of the device are more or less the same except for two small differences:
on iOS devices the user can choose separately the language and the region of the device. So, for example, it can choose as a language italian but as region USA. In this situation, the plugin will return the string it-US differently by the navigator.language property which will return the string it-IT (tested on iOS 11). If you have to know just the language this isn’t a big problem.
On Android, there is a bug because of which the navigator.language is not immediately updated. The new setting is available only after the application is killed. The plugin does not suffer os this bug. A workaround could be to use the navigator.languages property which is correctly updated (tested on Android 5.0.2).
If you have to know just the language you can use the information provided by navigator object without any problem.

Related

What features are available in a cordova web view?

What features (HTML, JS, CSS, Web APIs), outside of plugins, are available in a cordova web view ? I am making a web app, and then I use cordova to create an apk file. The web app works fine with chrome and firefox for android. But when I try the generated apk on the same android device and the emulator the JavaScript is obviously not executed because buttons have no effect.
The initial HTML and CSS display fine, and I think I use some JavaScript or HTML5 features that are not available yet on cordova web view, but I don't know what I can use and what I cannot. I had a look at the emulator's error log but I get nothing meaning-full.
For example is it possible to use es2015 without transpiling, esModules etc, but I don't know where to look it up. What is the difference between a webview browser and chrome/firefox for android.
Targeting Android 4 and later.
https://cordova.apache.org/
It's probably easiest to look at the architecture diagram: https://cordova.apache.org/docs/en/latest/guide/overview/index.html.
Cordova apps consist of a small wrapper around a WebView (this is a "window" of the default browser installed by your mobile OS, although you can swap it out for another: https://cordova.apache.org/docs/en/latest/guide/hybrid/webviews/), with access to the mobile device's features via plugins. So... to answer your questions:
You can use any technology that's supported by the mobile browser you're working in. https://caniuse.com is super helpful in this regard.
You will also find that Android 4.x's stock web browser is not that great -- some of the shiny new popover UI stuff (walkthrough help and light boxes) will render, but the z-order is all messed up when you try to click to the next item. I've run into other issues as well, but I can't remember them off the top of my head.
The Crosswalk project allows you to embed a Chrome browser web view in older Android versions (back to 4.x I think). Support for this project has been discontinued in the latest Cordova releases, as it's no longer necessary.

WebKit alternative for on Apple Watch? evaluateJavaScript()

I have a webpage and I want to interact via JavaScript with it (to get data and to perform input events) that means I want to load the webpage in background.
In iOS i could do this easily with WebKit and a webView + the evaluateJavaScript Method, but since I want to run this on Apple Watch and the fact that there isn't a WebKit framework for watchOS, I am looking for another way to do this.
Any ideas?
There is no way to run JavaScript code on watchOS at the moment. You should either port the code to Swift/Obj-C and run it natively on watchOS or you have to run the JS code in the iOS app, then send over the evaluated data to the Watch app using the WatchConnectivity framework.
Since there is no web browser on watchOS (and most likely there won't be one in the near future either), there would be no point in porting the WebKit framework to watchOS, so I suggest you find a permanent alternative for your problem.
As of watchOS 5:
Apple has ported WebKit to watchOS, which opens up a lot of possibilities. You can view web content from your watch.
Source: Apple introduces watchOS 5 | TechCrunch

How to know accessibility software is ON in mobile browser?

I would like to display/program my HTML page differently with and without accessibility feature is ON.
How to know accessibility software ( talkback in android , voicevoer in iOS) is ON in mobile browser ?
Is there any JavaScript variable available/object to know the above?
Observation
In Android Chrome browser, if accessibility is on, software is inserting couple of JavaScript files into browser. for example, chromeVoxChromePageScript.js, etc.
chromeVoxChromePageScript.js file has a cvox object.
we can keep if accessibility is on:
if(typeof cvox !== "undefined" ){
// specific code
}
is there any better way in iOS/android?
I don't believe there is a method in iOS. One of the main principles of Apple's iOS accessibility approach is:
Making standard UIKit controls and views accessible by default.
I.e. allowing developers to make what they create accessible, rather than needing a separate interface. Accessibility should be part of the mainstream.
Could you share the feature that you think needs to be separate?
The feature you found in Android is interesting, but does that work in Firefox? (FF is generally more reliable to use with Talkback.)

Trigger.IO how to find out device type with javascript

I'm currently developing a mobile app using Trigger.io. Since i only have one code for all platforms and devices, I need to get the device type (i.e Android v4.3, iOS 7). is there any built-in function for that? like forge.device or something like that? or should i rely on navigator.userAgent?
There was just a plugin released last week I think, will give you device and version
https://trigger.io/modules/platform/current/

Developing a cross-platform self-contained HTML application

I am thinking of building an application, kind of like TiddlyWiki in the sense that everything is self-contained in an HTML file, or at least in a bundle where a user won't have to install anything. It works on just about any browser, and on mobile phones (Android and iPhone), and in some browsers (e.g. Firefox), manages to save to the local filesystem without a plugin (albeit, it launches many security warnings, but there are other solutions for that). Other browsers happen to use a Java plugin to bypass this restriction.
Are there any technologies that exist that make this possible? HTML5's web storage sounds like it would be almost perfect, except that the data would be tied to the browser.
Any assistance would be appreciated (even if that just means editting / retagging the question to get more folks looking).
Whats about the fileapi: http://caniuse.com/#search=fileapi
I am just adding a relevant comment with this but not exactly an answer...
When you are saying that you want to develop application which contains everything... Then I would like to add about Titanium, PhoneGap, and others (Corona)...
This softwares provides JavaScript base which will be running on all the mobiles (if mobile applications), desktops (if desktop applications) and so on.... But Titanium (as i am working on it) works on the SDK of all the other languages for development...
Now TiddlyWiki, what i have understood from the link is that it is creating a web application or something like that which will work on all the other mobile devices. But this is NOT Good always, Since some application needs to be a NATIVE environment (which is supported by Titanium). Native applications will be much more faster than any other developed applications..

Categories

Resources