Activity Camera FirefoxOS - javascript

I am developing an app for Firefox OS which is supposed to load the camera when
an element is touched.
I had a search on the internet but I could not find a way to do such thing unless I was to start a "web activity" and let the user choose an application to pick.
I would like to force the camera application to start and not let the user choose the app to launch. Is there a way? (I really hope so!)
Thank you for the answer in advance!
Lorenzo

Launching the camera (app) and getting access to the camera (hardware) are two different things - depending on your needs, you may need the Camera API (as suggested by Jack) to pull images/video off the device camera hardware, or you might just want to launch the built-in camera app, so the user can interact with it (without requiring to retrieve any result, like a photo, from this interaction).
Unfortunately, both use cases are currently restricted by the permission system of Firefox OS.
Direct hardware access to the camera requires a "Certified" level permission, which prevents it to be used in third party applications. If you need this feature, your best chance is to wait until WebRTC (the getUserMedia() API) lands on Firefox OS devices, which will give you direct access to camera and microphone hardware in third-party applications (there are already some experiments on early Nightly builds of FxOS that use the WebRTC getUserMedia API on actual devices, so you it shouldn't take long before it is available to end users, too). Keep an eye on bug 750011 to follow implementation progress.
The other use case is launching the built-in camera application itself from your app. To launch an installed App on the device you need a reference to its App object, invoking the App object's .launch() method launches the selected app. Unfortunately though, currently the only way to acquiring said app object seems to be via the Apps.mgmt.getAll() function call, which lists all the installed apps on your device - scanning the list you would be able to pick the Camera app, and use its launch() method to launch it. You could see this in action in Kevin Grandon's "Matchscreen" homescreen-experiment. Unfortunately the permission system has the last word in this use case too, as the Apps.mgmt object calls, too require a "Certified" level permission (the webapps-manage permission). That is one of the main reasons why third party homescreens (like the one by Matteo D'Ignazio) can't function and actually launch apps currently. There is an ongoing discussion on relaxing the requirements on this, though, and there is work ongoing regarding third party home screens, so (in time) this should also be resolved.

As seen on the mdn page explaining App permissions, camera API is not available to third-party developers yet, but there are plans for it happening in the future.
Note: The reason that camera is limited to certified apps is that the sandbox that apps run in prevents access to the camera hardware. Our goal is to make it available to third party apps as soon as possible, but we don't have time to do that in the initial release.

You can use webRTC(getUserMedia API) in FxOS to access camera as in modern desktop browser after half a year. It will be a preffered way rather than the obsolete mozCamera API (which is not able to use for 3rd party developer).

Related

Web Bluetooth contribute new service/characteristic to own device

Web Bluetooth, from reading through the spec and the APIs, seems like it can only handle pairing with a BT device and then reading or writing to it.
But it doesn't seem to be able to expose a new service or a new characteristic on an existing service on the device in the machine the page utilizing Web Bluetooth runs on.
Is there a way I missed how Web Bluetooth can be used to create a new service for the duration of the page being open and allow other machines/devices to pair with the one running the script on the page and use this new service?
My main interest is mesh networking with BTLE using the Web Bluetooth API, but for that all devices running the page need to be able to not only connect to other peers, but also to be connectable-to by other peers. That part I have no idea how to achieve with the current API.
Can I get a definitive answer on whether it is possible to contribute new services to the BT device of the computer the script runs on? Links to this being discussed in the WGs and whatnot would also be great, I am interested in why it is not possible if that's the case.
I have learnt a crucial piece of nomenclature which now allows me to answer this question: peripheral mode.
Not all Bluetooth adapters support it and the Web Bluetooth standard is not looking like it's going to support web pages acting as beacons/peripherals any time soon:
https://github.com/WebBluetoothCG/web-bluetooth/issues/231
So, as of now, what I asked for is not possible.

Monitoring the displacement of a mobile device using GPS

I am wanting to develop an application for mobile devices, which shows in real time where a user (with this software installed on your mobile device) is. The idea would be that one (or more) users could follow the map the displacement of another user via GPS. I want to use PhoneGap with HTML5 and CSS and Javascript.
My question is: Is it possible to do that with these technologies? If yes, where can I get information of how to handle the GPS that way? If you can not, which language would give me this possibility and where can I get information? At first, I intend to develop this Application for Android and IOS.
Yes it’s very much possible with PhoneGap technology. You have to write a web service to keep the GPS coordinates as user updates (or auto updates) in server. You can let other users to connect to Web service and get the info they wanted (i.e. the data they wanted to see the current location of the user). You developed using PhoneGap means, it’ll work for iPhone too.
You can easily develop a web service either using PHP, Java or C# though C# web services are easy to write and maintain but PHP web servers are cheap compare to windows hosting (which you will need to host C# web service).
The question you asked is very broad so can write a 1000 words article and beyond. If you ask specific question I can answer that.

phonegap for iOS (iPad 2, iPad3) - Background worker and continuous refresh

I am developping an app for Ipad (2 and 3).
The app needs a continuous synchronization with a remote web app. Point is, my app needs to keep "listening" whenever there is connectivity in order to receive updates (lots of data), alerts,... etc.
PS: Before going further I would like to highlight that my app is not targeted to the appstore and moreover it can't rely on push notifications.
What I am confused about is the multitasking on the ipad. I would like my app's local db to stay synchronized by communicating with the remote web app. And hence my questions are:
Does any of the ipads have a real multitasking? (like android's where you can have "services") Meaning that my app or at least a small part of it would still operate even if it is not active on the screen.
How can I achieve that using phonegap standard framework?
If the above points show that at some extent it's not possible. Is there still a possibility to extend phonegap with a plugin and make this happen?
If the above three points are unfortunately fully negative; how would you address the problem by keeping in mind that the syncrhonization involves a lot of data and is mandatory to cover the app's usability?
Does any of the ipads have a real multitasking? (like android's where
you can have "services") Meaning that my app or at least a small part
of it would still operate even if it is not active on the screen.
IOS only has limited background services - in that your app goes into a background state when not active. Really only limited to receiving push notifications. As Phonegap uses a webview and javascript that is only active when the app is active in the foreground.
How can I achieve that using phonegap standard framework?
If you want to keep data connection open you might have to look at development of an application for a computer tablet, rather then an IOS device.
If the above points show that at some extent it's not possible. Is
there still a possibility to extend phonegap with a plugin and make
this happen?
No.
If the above three points are unfortunately fully negative; how would
you address the problem by keeping in mind that the syncrhonization
involves a lot of data and is mandatory to cover the app's usability?
You only option (if you can only use phonegap) is to have the app active all the time, and set a constant sync using Jquery & XML/JSON data. Of course this depends on what type of data you are going to show. For showing a page of data - similar to a webpage you won't have any problems - as long as you understand once you change apps that data won't be synced.
I would like my app's local db to stay synchronized by communicating with the remote web app.
If I were you, I'd be questioning why would I need to do that? Why not just make the app works online? You can have all the assets locally, and just setup some sort of API to retrieve whatever data you need to display on demand.
Otherwise, you'll need to hack your way through to do all the things you wanted, plus you need offline / online syncing. Since you have most data available offline, I assume the app also works offline? And you'll have a really bad time working on offline / online syncing...

Get a tablets(iPad or Droid) mac address?

Synopsis: I am developing a HTML5 web app that will allow tablets(iPad or Droid) to login to a server and perform various functions. The client would like a way to check the devices mac address when logging in. From what I have read, most solutions use activex objects that will not work for webkit browsers.
Question: Does anyone know a solution that would hook into a HTML5 web app seamlessly(Idealy update a hidden form element with the value upon logging in)?
Thanks!
I don't think there's going to be a straightforward way to do this. The web server won't be exposed to a client's MAC address unless they're on the same physical segment...you'll only see the MAC from the most recent router hop in general.
If anything exists, it's going to be a browser plugin (show-stopper on iOS). And it would probably need more than the default permissions available (I don't suspect you can enumerate network interfaces in Java, for example, without asking for elevated permissions).
If you're looking for HTML/JS only then I don't think that this is possible. It won't be exposed.
The problem is that the packets you recieve back will only contain the MAC address of the node on the last hop.
This may be possible via a plugin, but then this limits you on iOS, and possibly also Android as you'd need to provide them a way of getting the plugin first (unless you used a plugin that was installed by default).
Edit: Not that I support an app for every little thing, but it shows that easy to press app buttons sometimes tend to do better than web apps (regardless of being able to make browser shortcuts to home screens). If it is suitable, you could consider loading this within a web view on the target device from within an app, from which you can then of course access MAC addresses and whatever else you may need.
MobiThinking: Mobile applications: native v Web apps – what are the pros and cons?
Forbes: Mobile Web App vs. Native App? It's Complicated

What is the best way for a website to check if a user has installed a client app?

Let's say I've got a website that works better if a client has installed and logged into a desktop application. I'd like to be able to do 2 things:
Alter the website if they haven't installed the app (to make it easy for them to find a link to the installer)
If they've installed the app on a couple of machines, determine which machine they are browsing from
I'd like something that works on Windows and OSX, on any of the major browsers. Linux is a bonus.
A few thoughts:
Websites can detect if you've got Flash installed. How does that work and could it be used for both of my goals?
Could I just let the client serve HTTP on localhost and do some javascript requests to fetch a local ID? I know google desktop search did something like this at one point. Is this a standard practice?
Thanks!
You can register a protocol from your desktop application (see this). This can be used, for example, to open your desktop application with arbitrary data from the website. You could then have your desktop app send a HTTP request to your webserver, telling it what machine you are on.
You can have a browser plugin (activex for IE or Netscape plugin for the rest of the browsers) that can communicate with the application. When the webpage is loaded, it can try to instantiate the plugin and if it succeeded, it can use it as a proxy to the application. If it fails, then either the app is not installed or the plugin was explictly disabled by the user. Either way, your website should degrade its functionality accordingly.
Update: Forgot to answer your questions:
Flash does it exactly this way. Flash is a browser plugin that is created by the web pages.
You can have a machine ID generated at the application/plugin install time and your plugin can pass that machine ID to the webpage when it is created.
On the topic of using local webserver:
I would stay away from having a local webserver, mainly because of security considerations. It takes quite a lot of work to make sure your local webserver is locked down sufficiently and there are no XSS vulnerabilities that other malicious websites can exploit to make it do stuff on their behalf.
Plus, having a webserver means that either it has to run as a system-wide process, or if it runs as the user, you can have the website interact with only one user's instance of the application, even though multiple users can be logged on and running it at the same time.
Google Desktop Search suffered from both the XSS security vulnerability (though they fixed it) and the limitation of only one user being able to use it on a machine (I don't know if they fixed this one yet, though chances are they did).
Websites can detect if you've got Flash installed.
Actually, I believe a browser can detect if you have the Flash plugin for the browser installed, and webpages can offer "installed" and "uninstalled" option that the browser can choose.
Otherwise, you are asking for a means, by putting some code in a webpage, of being able to analyze a user's home computer, and report what it learned to you website.
Can you say Major Security Hole?
If you can pick a development environment for the desktop app, then check out AIR from Adobe. It lets you develop desktop applications using either html/javascript, Flash, or Flex.
It has API calls you can use from a browser based flash app to see if the desktop based AIR app is installed, what version, etc. You can even launch it and pass parameters from the web app to the desktop app.
http://www.rogue-development.com/blog2/2008/03/interacting-with-an-air-app-from-a-browser-based-app/
Websites can detect if you've got Flash installed. How does that work and could it be used for both of my goals?
it's quite a bit simple, your browser tries to render some additional files, with some specific formats such as flash .swf and I the browser doesn't find installation, then will be start downloading, or you will get the option to download that program.
Flash also uses AC_RunActiveContent.js please take a look at this js, people usually put this on their webpages
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave cabs/flash swflash.cab#version=8,0,0,0','width','981','height','635','id','build5','align','middle','src','build5','quality','high','bgcolor','#ffffff','name','build5','allowscriptaccess','sameDomain','allowfullscreen','false','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','build5' ); //end AC code
}

Categories