Ask camera and library permissions in webview

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) 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), 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

1 Like

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.

2 Likes

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

1 Like

Add a button to the app like this
image

Keep it hidden

Add both Camera and Gallery components to the button.
image

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

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

I also tested the javascript code suggested here 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.

1 Like

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

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

1 Like

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.

2 Likes

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

Check this link

1 Like

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

1 Like

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.

1 Like

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

1 Like

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.

2 Likes