# Ask camera and library permissions in webview

**URL:** <https://community.thunkable.com/t/ask-camera-and-library-permissions-in-webview/2048179>\
**Category:** Questions about Thunkable X\
**Tags:** beginner\
**Created:** [September 19, 2022, 10:19am UTC](https://community.thunkable.com/t/ask-camera-and-library-permissions-in-webview/2048179 "2022-09-19T10:19:40Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![dani19130a](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/dani19130a/32/120952_2.png) [@dani19130a](https://community.thunkable.com/u/dani19130a)\
**Post date:** [September 19, 2022, 10:19am UTC](https://community.thunkable.com/t/ask-camera-and-library-permissions-in-webview/2048179/1 "2022-09-19T10:19:40Z")

</div>

Dear Community,  
I would like to ask you if someone can help with the issue described in the subject.

I developed a way for taking and cropping photos with a **simple html5 script** ([you can see it here](https://x.thunkable.com/copy/7e9af6a9c5803fa77538678ea0e0e37b)) but I noticed that **camera and photo library permissions are never asked** and I would like to find a way to solve it.

I’m pretty sure that App Store and Google Play will never approve an app like that and also it would be very unfair concerning users’ privacy and trust.

I already took a look at old posts in the forum ([for example this one](https://community.thunkable.com/t/how-to-allow-camera-permission-in-web-viewer-component-in-thunkable/1765899)), I implemented the suggested workaround in my project but no permission popup was showing.

**Cloudinary is not an option for me anymore** because of privacy matters (their servers are not located in the EU) and also because image upload is extremely slow.

**Using HTML is not the best option for me but still acceptable** , so finding a solution to my question is crucial for my app to be still developed in Thunkable.

Many thanks to everyone that could help me.

Daniele

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [September 20, 2022, 9:39am UTC](https://community.thunkable.com/t/ask-camera-and-library-permissions-in-webview/2048179/2 "2022-09-20T09:39:58Z")

</div>

Create a hidden button somewhere in your app and add the camera and photo gallery to the `click` event of the button. This will force Thunkable to ask for permissions.

---

<div class="post-metadata">

**Author:** ![dani19130a](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/dani19130a/32/120952_2.png) [@dani19130a](https://community.thunkable.com/u/dani19130a)\
**Post date:** [September 20, 2022, 3:44pm UTC](https://community.thunkable.com/t/ask-camera-and-library-permissions-in-webview/2048179/3 "2022-09-20T15:44:31Z")

</div>

Thanks @muneer,  
Is it something that you already tried in your projects?

I’ve followed your suggestion but no popup is showing.

You can see what I’ve done [here](https://x.thunkable.com/copy/b4f73b643c56445952c8193a9084423d)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [September 20, 2022, 4:00pm UTC](https://community.thunkable.com/t/ask-camera-and-library-permissions-in-webview/2048179/4 "2022-09-20T16:00:42Z")

</div>

Add a button to the app like this  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/4/e44299dd0b303ad3a0240cff5120a98090ccb282.png)

Keep it hidden

Add both `Camera and Gallery` components to the button.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/b/9b415f7d0dc258846dbae9c8caf14c2e9f4ef817.png)

Now Thunkable should ask for permission when installed in the device.

---

<div class="post-metadata">

**Author:** ![dani19130a](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/dani19130a/32/120952_2.png) [@dani19130a](https://community.thunkable.com/u/dani19130a)\
**Post date:** [September 21, 2022, 8:26am UTC](https://community.thunkable.com/t/ask-camera-and-library-permissions-in-webview/2048179/5 "2022-09-21T08:26:29Z")

</div>

Hi @muneer , Do you think there are alternative solutions?

I did exactly like you suggested, but still no permission popup is showing. You can look inside my demo project [here](https://x.thunkable.com/copy/b4f73b643c56445952c8193a9084423d)

I also tested the javascript code suggested [here](https://community.thunkable.com/t/how-to-check-permissions/1940176) but it is not working in iOS.

Maybe I’m making some mistake somewhere.

I also asked to the Thunkable chatbot but I’m still waiting for an answer since Monday.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [September 21, 2022, 12:49pm UTC](https://community.thunkable.com/t/ask-camera-and-library-permissions-in-webview/2048179/6 "2022-09-21T12:49:36Z")

</div>

After you add the blocks, did you include permission strings in your project settings?

---

<div class="post-metadata">

**Author:** ![dani19130a](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/dani19130a/32/120952_2.png) [@dani19130a](https://community.thunkable.com/u/dani19130a)\
**Post date:** [September 21, 2022, 1:21pm UTC](https://community.thunkable.com/t/ask-camera-and-library-permissions-in-webview/2048179/7 "2022-09-21T13:21:56Z")

</div>

Hi @jared , yes I did, I included the strings for iOS permissions if it’s that what you mean.

For me it’s very difficult to understand how a hidden button can raise the camera permission popup. Normally it raises only if a call to the camera block really happens

---

<div class="post-metadata">

**Author:** ![dani19130a](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/dani19130a/32/120952_2.png) [@dani19130a](https://community.thunkable.com/u/dani19130a)\
**Post date:** [September 22, 2022, 2:01pm UTC](https://community.thunkable.com/t/ask-camera-and-library-permissions-in-webview/2048179/8 "2022-09-22T14:01:19Z")

</div>

I have an update, if you have feedback, please, feel free to comment and reply.

The only way I found is to ask the user to explicitly use the camera and the photo library at least once with native blocks. This forces him/her to provide the permissions to the systems, after that I guess it is ok to offer the same features via HTML / javascript.

The bad part of the workaround is that the first time the user takes a “fake” picture with the only purpose to get the necessary permissions.

So, to limit the UX impact I’m developing a tutorial that starts immediately after the download to tell the user which permissions are necessary and ask to make a simple test opening the camera and the photo library.

I can’t say right now if this will hurt the user and if app stores will approve but this is the best solution I found at the moment and worth the risk.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [September 23, 2022, 2:34am UTC](https://community.thunkable.com/t/ask-camera-and-library-permissions-in-webview/2048179/9 "2022-09-23T02:34:36Z")

</div>

I would first try to invoke the **Camera Permission** from the HTML script itself.

 ![Screenshot_2022-09-23-05-32-03-19_40deb401b9ffe8e1df2f1cc5ba480b12](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/6/4610e1b9a80a9d5dec885904de050882475b0846.jpeg)

Check this link

> **[MediaDevices.getUserMedia() - Web APIs | MDN](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia)**
>
> The MediaDevices.getUserMedia() method prompts the user for permission to use a media input which produces a MediaStream with tracks containing the requested types of media.

---

<div class="post-metadata">

**Author:** ![dani19130a](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/dani19130a/32/120952_2.png) [@dani19130a](https://community.thunkable.com/u/dani19130a)\
**Post date:** [September 23, 2022, 7:02am UTC](https://community.thunkable.com/t/ask-camera-and-library-permissions-in-webview/2048179/10 "2022-09-23T07:02:13Z")

</div>

Unfortunately, it does not work on any iPhone, at least on my iOS 14.6

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [September 23, 2022, 8:28am UTC](https://community.thunkable.com/t/ask-camera-and-library-permissions-in-webview/2048179/11 "2022-09-23T08:28:12Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/c/fc57f3d5f31be093d196a3716f97898a8958aa1b.png)

The table here shows that Safari is compatible with it as long as your phone has the version indicated or above.

Also remember that the URL should be **https**. It might not work with **http** as noted in the table.

---

<div class="post-metadata">

**Author:** ![dani19130a](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/dani19130a/32/120952_2.png) [@dani19130a](https://community.thunkable.com/u/dani19130a)\
**Post date:** [September 23, 2022, 8:46am UTC](https://community.thunkable.com/t/ask-camera-and-library-permissions-in-webview/2048179/12 "2022-09-23T08:46:49Z")

</div>

I guess it is ok if you open it in a Safari browser Tab but it does not work if you open it in a WKWebView instance, which is the webview component for iOS

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [September 23, 2022, 10:00am UTC](https://community.thunkable.com/t/ask-camera-and-library-permissions-in-webview/2048179/13 "2022-09-23T10:00:31Z")

</div>

In this case you will need a way to implement `try - catch` in JavaScript and see if the error reported is related to permission then you can report it back to your app through the `Web Viewer` and from the app you invoke the Camera block to get the permission dialogue.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [December 22, 2022, 10:01am UTC](https://community.thunkable.com/t/ask-camera-and-library-permissions-in-webview/2048179/14 "2022-12-22T10:01:27Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
