Zhen Liu
Zhen Liu

Reputation: 7932

Phonegap build: How to explicitly ask for permissions?

I am building a hybrid app for Android and iOS, and using phonegap build cli-5.2.0

I am using a camera plugin

<plugin name="cordova-plugin-camera" source="npm" spec="2.2.0" />

I have this line specified in my config.xml

<preference name="permissions" value="none"/>
<feature name="http://api.phonegap.com/1.0/camera"/>

And I notice that on my android device, it only asks for read/write access of USB storage. When using the camera to take a photo, android doesn't ask for any permission and the camera just some how works.

I want to know how to explicitly require Camera permission on android prior to app installation? I need to have it because I believe it is causing some other bug related to a video functionality my app has.

I have tried to build without the permission none line, but that did not make any difference.

Upvotes: 3

Views: 1606

Answers (1)

Zhen Liu
Zhen Liu

Reputation: 7932

The way to do it is to add a config-file element. I don't know why it is so hard to find.

<gap:config-file platform="android" parent="/manifest" mode="add">
    <uses-permission android:name="android.permission.CAMERA" />
</gap:config-file>  

Upvotes: 1

Related Questions