Getting mobile device hardware information via javascript - javascript

via Javascript you can get a lot of information about your hardware and other components about your system, like shown here
With mobile devices you are not getting that much information. I'n not asking how to find out the mobile device name, that's easy, or even the udid. I want to know, if I can access some device characteristics, like some sort of installed plugins used by the browser, or new developments on this topic.
On this site I discovered, that I can access the battery status, Or with window.navigator.mozVibrate([200]); I can activate the vibrate function. So far both work only on firefox mobile (android).
An interesting information would be about the built in camera, something like how much megapixel does it have, or does it have a flash light? Or what kind of cpu (single-, dual-, or quad-core) is built in?
To sum it up: what hardware information can I get about a mobile device (iOS/Android/Windows Phone) via javascript?
Thanks for any hints!

You may be able to get a limited set of information about the device by using PhoneGap i.e. placing the PhoneGap script on your server and checking the appropriate values if the device is mobile. Check this link: http://docs.phonegap.com/en/2.0.0/cordova_device_device.md.html#Device

Related

Create an extension to the browser to acces local scanner

I would like to access a special hardware (a penta scanner, for the wisest ;) ) from a web page.
The aim is to retrieve the information from the scanner and compute it on server side.
The problem here, is that I have to summon functions from a DLL that has to be on the client side. I have two leads for that:
Develop a COM DLL and use ActiveX
Try to get through a homemade extension for a web browser in order to communicate with the local DLLs.
I've tried the first option, and I got stuck and I've posted another thread about it. Anyway, even if it works, there are too many constraints about it (as to use IE or the fact that even Microsoft is not fond of this feature and banned it from edge).
The second method is something that I found on another forum but, I do not understand how I can interact with a browser extension (whatever the browser).
So what I am asking is:
Is it possible to use a web browser extension as a medium to a local DLL and if so, would you be so kind as to give a hint about how to do ar anything that might look like a start about how to do it (even just some key words to use on google, since mine didn't get anything)....
Thanks.
Based on my understanding, the motive to develop an Extensions is to enhance the feature and functionality for particular web browser.
You cannot control any hardware devices like printer or scanner with it.
So if your goal is to control the scanner from your web page with the help of any kind of extension than I think you cannot do this with Extension.

Signal Strength of Bluetooth devices using Web-Bluetooth

I am looking to obtain the bluetooth strength (RSSI or similar) of a signal using a web-based application (in this case attempting with the Web-Bluetooth API). From what I've seen this feature is not supported in a browser (yet at least).
The result was intended to be used on a mobile device rather than a desktop but if there is a solution for either I am unaware at the current minute. Since I cannot see much on the matter of it other than it working within downloaded/compiled mobile apps (which I guess I will have to resort to if this is completely unachievable).
This would also apply to if HTML5 p2p connection strength if that was an obtainable value as well.
Maybe I have completely missed something out and my googling skills are terrible, otherwise any relevant links / information is appreciated :)
I recently implemented the watchAdvertisements() API that will enable the page to listen for advertisement packets from the device. When a packet is received, an advertisementreceived Event is fired on the device, and the Event contains the RSSI and TX Power of the device. You can give this API a try by enabling chrome://flags/#enable-experimental-web-platform-features in Chrome 85.0.4165 or higher.

Allow access to weblink only via native iOS and Android apps

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.

Allow access only from mobile and tablet devices

My client has very specific request. He wants to block all "classic" computers (desktop/notebook).
So if I access the website from iPhone, Android or tablet it displays everything (the different resolutions I can hadle via responsive design). But when somebody from Mac or Windows or Linux (I know that Android is also based on gnu/linux ;) ) access the web, he gets only a message that "this web is only for mobile devices"or something like taht.
But I am not sure how to "ban" mac os, win, linux etc.
Could javascript(jQuery) library e.g. Modernizr or other do such specific condition "just mobile devices"?
What about Windows 8 :( ?
i am really thankful for any advice, because I have never had such request before?
I think you could do this in several ways.
Either you check via javascript, but then you if somebody would turn off javascript you would be screwed again because they could take a look at the website:
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
// some code..
}
or you could check it via modernizr, but I don't know exactly how to do it in modernizr and you would also have the problem of turned off javascript code,
or you could download a script that is suitable for your case via:
http://detectmobilebrowsers.com/
another thing you could do is checking the screen resolution but, then we are back at the javascript case.
According to MSDN, Windows adds Tablet PC to the browser user agent if it is a tablet.
I suggest not doing this via javascript, because as states above: if javascript is disabled, people will be able to visit your site.

How can I redirect mobile devices to a different URL?

I want to check whether the user is viewing my site from a mobile device or PC. If it's a mobile device, I want to redirect my site URL like Google does...
If possible I would like to implement this in JavaScript. How can I do this?
You typically use the User-Agent header to detect the browser.
Here's JavaScript code that does basically that (only for mainstream browsers though, you'd have to add the Mobile User-Agents)
http://www.quirksmode.org/js/detect.html
And here's a list of mobile browser identifiers
http://www.zytrax.com/tech/web/mobile_ids.html
The list is not complete and will never be, given the rate new mobiles appear on the market, but what I did back when I did it is to store all received user agents in a database, and then look for them to classify them as mobile and which brand/model.
What you can't rely on though is JavaScript, it's better done in server code (not all mobile browsers execute JavaScript).
There is a related question here on SO but I couldn't find it.
See this existing question.
You will have better luck doing this server side, as many mobile browsers don't even support JavaScript. Basically you want to check the user agent and compare to a list of known mobile browsers.
Here is a simple answer for this query. This won't detect the mobile browser, but it redirects the page to our mobile.html page, through the following script;
Find out the browser window size and redirect it..
winWidth=document.all?document.body.clientwidth:window.innderwidth;
if (winwidth<800)
{
window.location.replace("mobile.html");
}

Categories

Resources