Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Is there a way to check if my project has camera access?

in Questions Posts: 33

I looked through the forums and the documentation, but I couldn’t find what I was looking for.

As an experiment, I turned off Codea’s access to the camera to see if my app would still work. Codea completely crashed when it hit the line spriteSize(CAMERA). After turning the camera permission back on in iOS settings for Codea the crash was resolved.

I am wondering if there is a way to check to see if my project has access to the camera. I have tried pcall(spriteSize, CAMERA) in the hopes that I could catch the error and prevent the crash, but Codea still crashes to the iPad home screen.

For my AR projects I am able to check using if scene.ar.trackingState == AR_NONE then. Is there something similar that I am missing?

Thanks for your help!

Comments

  • dave1707dave1707 Mod
    Posts: 7,605

    @exomut Codea shouldn't crash. @Simeon Can something be added to stop Codea from crashing when trying to use a camera command when the camera isn't on.

  • edited June 15 Posts: 815

    Have you tried if CAMERA then sprite(CAMERA, WIDTH*.5, HEIGHT*.5) end - I have a camera so I can’t try it out :tongue:

    Not sure, but if that shouldn’t work, try if type(CAMERA) == ‘userdata’ then ... end or if type(CAMERA) then ... end, since CAMERA is a picture?

  • SimeonSimeon Admin Mod
    Posts: 4,958

    @dave1707 I'll add this to my list of bugs to fix. You're right, Codea shouldn't crash on permission denied

  • Posts: 33

    @TokOut Thanks for the idea. I tested your idea and type(CAMERA) always returns a string, and that string is just CAMERA, even if I turn off permissions for the camera. Good idea though.

    @Simeon Could you please consider adding, re-requesting for camera permissions if the user chose to not allow access. Or at least a permission check so I can inform the user to turn on permission in the settings. Thanks.

  • SimeonSimeon Admin Mod
    Posts: 4,958

    @exomut iOS will not allow an app to re-request permission for any service if the user denied the initial request. But I will fix this bug and allow to check the authorisation status so you can lead them to settings.

    Are you on the beta? Would you consider joining so I can get these fixes to you sooner.

  • Posts: 33

    @Simeon It would be nice to join the beta. I am always worried that I am reporting bugs and issues that you have already fixed. However, I vaguely remember reading a post around a month ago, saying that the Apple Pencil API was not in the beta yet. I am using that API for one of my apps for my classroom. If the Apple Pencil API is there, then joining the beta sounds great. You are using Test Flight, correct?

  • Posts: 815

    Yes, you’ll need to DM your email to Simeon directly.

  • SimeonSimeon Admin Mod
    Posts: 4,958

    @exomut the pencil API has been released. DM me your Apple ID email and I'll add you.

    I've modified cameraSource() to allow for checking for camera availability. If you call cameraSource() it normally returns whether CAMERA_FRONT or BACK is selected. If the camera is unavailable or unauthorised it will return -1. Also fixed the crashing when attempting to use the camera after denying access.

  • dave1707dave1707 Mod
    Posts: 7,605

    @Simeon Tried out your cameraSource(). It works the way you specify but there's one thing that I don't agree with. If the camera isn't available, you print the message Camera functionality is not available or not authorized on this device. If someone unintentionally puts that test in draw and they're not displaying the print pane, it will continuously print that message without them knowing it and eventually crash Codea.

  • SimeonSimeon Admin Mod
    Posts: 4,958

    @dave1707 good point though my takeaway is I should make sure continuous printing doesn't crash Codea, that sounds like a bug I'll try to fix

Sign In or Register to comment.