Quick permission handling in a few lines of code

Giving an app fine-grained access to certain device features is a reoccurring theme in a mobile application. Luckily Tabris.js offers a rich set of APIs to handle these types of runtime permissions. While the Tabris.js API is feature-rich, sometimes all that is required is to perform an action only when certain permission is available.

For these common use cases Tabris.js offers the convenience API permissions.withAuthorization(). To use it, you merely need to give your desired permission and to provide a callback which will be executed when the the permission has been granted:

In the above example, we require the 'camera' permission and activate the camera when the permission is given. In order for the native platform to correctly support the camera permission some entries have to be made in the config.xml.

As you can see, the entire process of handling permissions has been greatly simplified.