Access Users Android and iOS Camera with Ionic Framework

In the series of Ionic blog posts earlier we have seen how to setup ionic development environment Setup dev environment for ionic framework, now we are going to build the app which is using Camera API

Now these days smart phones have at least one camera if not two. So many apps use the functionality of the user’s camera to click photos and access users phone gallery support to their apps. for adding cool features into thier app

Plugin

First, We need to install the Camera API plugin. From the ionic CLI, cd into your app/work directory

I am assuming you have already added the platform of your choice (android, ios or may be both)

Install Apache Cordova Camera Plugin

We have install the Camera API and now we can use the Camera functionality by writing some Javascript code like below:

In code we are just creating a Controller (takePhoto) and injecting $scope and $cordovaCamera. Then create a function with $scope ($scope.takePhoto) and call into you UI view

And you can find full working code on Github

The output images below showing the working of cordova camera plugin:

Screenshot from 2016-01-16 03_02_03     Screenshot from 2016-01-16 03_02_29      Screenshot from 2016-01-16 03_02_42

 

 

Thanks!!.

Written by 

Principal Architect at Knoldus Inc

2 thoughts on “Access Users Android and iOS Camera with Ionic Framework

Leave a Reply

%d bloggers like this: