How to check permissions?

How can I check if the application has camera or location permissions? I am trying to do something like this (just an example):

If permission for camera is granted change text input to value “Granted”. If not change text input value to “Not granted”. I need to check it without taking a picture by camera (call Camera1’s take photo).

I found similar topic here ( https://community.thunkable.com/t/how-do-you-use-screen1-permissions-granted-permissions-denied/65247 ) but I don’t have these option on my Screen1 object and got no idea where to find these parameters/variables to use it with if-else statement.
I also tried do check it from WebView component with javascript (navigator.permissions.query) but it seems it is not supported solutions.

As for now… I don’t know how to check if permissions was granted or not and got no idea how to do this with Thunkable.

This is not possible,
Thunkable Doesn’t support such a block.

Ok, I found workaround for that, which I decided to share here, because maybe it will be helpful for others having the same problem. The solution is combination of javascript and post/receive message method. .

FOR CAMERA:
This will ask for permission if it was not given before, but will not open the Camera as with “Camera1’s take photo” so it looks better.

  1. I am executing javascript inside WebViewer component, which looks like this:
navigator.getUserMedia (
   {
   video: true
   },
   function(localMediaStream) {
      ThunkableWebviewerExtension.postMessage("camera-Granted");
   },
   function(err) {
      if(err.includes("denied")) {
         ThunkableWebviewerExtension.postMessage("camera-Denied");
      }
      else {
         ThunkableWebviewerExtension.postMessage("camera-Error");
      }
   }
);
  1. I am receiving postMessage with WebViewer ReceiveMessage (if message = “camera-Granted” etc.) and inside if rule I can add any action, not only inside WebViewer component but like every event I can do normally with blocks in Thunkable.

FOR LOCATION:
If it will throw error or latitude and logitude are null, I can assume that the permission is denied (so here no rocket scince really).

FOR MICROPHONE:
The same way as for camera but “video” will be “audio”.

After all of that:
Obviously it will be much more simple if Thunkable will add a feature or anything to allow to check permissions with blocks…or if Android Browser will start to support “Navigator API: permissions” for javascript.
Anyway… I recommend in future to add to Thunkable a feature allowing to check/ permission status from the blocks area. It will be much more comfortable to use it.

Have you tried it on iOS?

I’ve made some tests and it works fine on Android but on iOS no permission popup comes out.

Thanks
D