Native applications can access the camera of the phone and perform operations like taking the picture, uploading it, and so on.
To check whether the device has a camera we can use following command:
System::get_property('has_camera')
The Camera API provides the following functionality:
To take a picture, use the following command:
This method will take the picture and once the picture is taken it will call camera_callback
.
We can choose a picture using the following command:
Camera::choose_picture('/app/model/camera_callback')
Once the user has taken/chosen a picture, the callback URL you specified will be called. The callback is a POST
message; the body of the message contains the status
and image_uri
.
status
can have: ok, cancel, or error value.
image_uri
points to the taken/chosen image stored in the /public/db-files
folder; the image file will have an auto-generated name.