Flashlight-PhoneGap-Plugin icon indicating copy to clipboard operation
Flashlight-PhoneGap-Plugin copied to clipboard

Is this plugin really working?

Open ghevge opened this issue 1 year ago • 10 comments

I'm trying this plugin on an iphone 6s running iOS 14.7.1, but I am not able to turn on the flashlight. There is no error thrown by the code, it acts like everything is ok, but still no flashlight comes on.

During the build I see some deprecated messages, complaining about: /Users/user/Software/project/platforms/ios/test/Plugins/cordova-plugin-flashlight/Flashlight.m:45:17: 'setFlashMode:' is deprecated: first deprecated in iOS 10.0 - Use AVCapturePhotoSettings.flashMode instead.

and

/Applications/Xcode-13.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.5.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:837:41: Property 'flashMode' is declared deprecated here

ghevge avatar Jun 02 '23 19:06 ghevge

I would suggest you change plugin to one that is more actively developed, i.e. community-cordova-plugin-flashlight (current version is 3.3.3), see community-cordova-plugin-flashlight.

Let me know what you think after you have tested it, thanks.

minduch avatar Jun 02 '23 20:06 minduch

@minduch I'm seeing the same behavior with community-cordova-plugin-flashlight. On Android it doesn't work either.

ghevge avatar Jun 02 '23 20:06 ghevge

Are there any permissions I have to provide ?

ghevge avatar Jun 02 '23 20:06 ghevge

I would report the problem in that plugin too.

Message ID: @.***>

minduch avatar Jun 02 '23 21:06 minduch

Yes, you need the Camera access on iOS.

minduch avatar Jun 02 '23 21:06 minduch

You probably need it for Android too. You can try our app iiziRun Developer with flashlight manipulations under Settings.

minduch avatar Jun 02 '23 21:06 minduch

I am granting already the camera permission in both ios and android. The camera works, is just the flashlight that doesn't work when using this plugin. As for reporting a problem under community-cordova-plugin-flashlight, i can't because there is no issues section available there.

ghevge avatar Jun 02 '23 21:06 ghevge

In android I am able to start the flashlight from javascript. But in ios this is not supported. That is way I was trying this plugin. But it seems it doesn't work properly

ghevge avatar Jun 02 '23 21:06 ghevge

Hmm it seems that the reason this plugin doesn't work properly (at least in android) is because I already have the camera running by another user (webview browser in my end).

android.hardware.camera2.CameraAccessException: CAMERA_IN_USE (4): setTorchMode:2031: Torch for camera "0" is not available due to an existing camera user

For some reasons the plugin doesn't pop up these errors in the callback. I can only see them if I debug the plugin.

ghevge avatar Jun 02 '23 22:06 ghevge

It seems that this plugin only works if the camera is not in use. Which is not my case. I need the camera running and the torch to be enabled/disabled per user preference. So to answer my initial question: This plugin, partially works.

ghevge avatar Jun 03 '23 10:06 ghevge