Jump to content
John van de Waeter

TWebbrowser & camera permission

Recommended Posts

Hi all,

If I open a website that gives the user the opportunity to use the camera, nothing happens inside the TWebbrowser. No error thrown.

 

I manually granted the required permissions to the app, but no luck.

 

On iOS it works OK, on Android nothing happens.

 

Any ideas?

 

thanks,

John

 

Share this post


Link to post

The process on Android is to:

 

Check the checkbox for Camera permission in the Uses Permissions of the Project Options

 

Request the permission at runtime, e.g:

  PermissionsService.RequestPermissions(['android.permission.CAMERA'],
    procedure(const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray)
    begin
      if AGrantResults[0] = TPermissionStatus.Granted then
        // Permission was granted
    end
  );

 

  • Like 2

Share this post


Link to post

Thanks Dave.

It was my impression that the embedded webbrowser would need the permission.

 

nevertheless...

The website with the photo-button works in every browser. The camera is started.

When the website is opened in the TWebbrowser, the photo-button only offers the option to pick a photo from the gallery.

 

John

Edited by John van de Waeter
nevertheless

Share this post


Link to post
16 hours ago, John van de Waeter said:

When the website is opened in the TWebbrowser, the photo-button only offers the option to pick a photo from the gallery.

Can you give an example of a site where it does this?

Share this post


Link to post
On 9/19/2023 at 1:42 AM, Dave Nottage said:

Can you give an example of a site where it does this?

I'm trying to wrap "www.trustroots.org" into a TWebbrowser.

You would have to create an account to get to the profile/image page. It offers 2 buttons: Select a photo and Take a photo.
Works okay in a browser

Works okay in a TWebbrowser on iOS

Does NOT work in a TWebbrowser on Android.

Share this post


Link to post
1 hour ago, John van de Waeter said:

Does NOT work in a TWebbrowser on Android.

After a bit of experimenting and searching around, it appears it's currently not possible. Here is one link relating to the issue:

 

  https://bugs.chromium.org/p/chromium/issues/detail?id=669492

 

I expect you'll need to implement photo taking in the app itself, and then when the user taps "Select Photo" or "Take A Photo" link in the TWebBrowser, they'll be able to select the image that has been taken.

Share this post


Link to post

The bugreport on Chromium is from 2016 and does not seem to be solved yet.
So yes, the only option is to implement taking photos in the app itself.

 

Thanks for looking into it!

 

John

 

Share this post


Link to post

However, another volunteer started a similar project (Website in a Webview) in another developers environment (react native IIRC) a couple of years ago.

Unfortunately this developer is no longer among us, but the app still exists in the Playstore.
Instead of doing nothing, both buttons show a choice: Camera or Files.

I would think (but am not sure) that this Webview also uses the Chromium browser. Strange that the reponse to the buttons is different...

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×