Stay organized with collections
Save and categorize content based on your preferences.
Enabling the device's flash unit during an AR session can help improve
visibility.
Check that the current camera configuration supports flash
Not all camera configurations support enabling a flash unit.
Before enabling the flash or offering users the option to enable the flash,
ensure that the flash unit is available for the active camera
configuration:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-14 UTC."],[[["\u003cp\u003eUsing the device's flash during an AR session can enhance visibility in low-light conditions.\u003c/p\u003e\n"],["\u003cp\u003eBefore enabling the flash, verify if the active camera configuration supports it by checking the \u003ccode\u003ehasTorch\u003c/code\u003e property of the \u003ccode\u003eAVCaptureDevice\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eEnable the flash by setting the \u003ccode\u003etorchMode\u003c/code\u003e property of the \u003ccode\u003eAVCaptureDevice\u003c/code\u003e to \u003ccode\u003eAVCaptureTorchModeOn\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eDisable the flash by setting the \u003ccode\u003etorchMode\u003c/code\u003e property of the \u003ccode\u003eAVCaptureDevice\u003c/code\u003e to \u003ccode\u003eAVCaptureTorchModeOff\u003c/code\u003e.\u003c/p\u003e\n"]]],["To utilize the device's flash in an AR session, first verify if the active camera configuration supports it using `device.hasTorch`. If supported, enable the flash by setting `device.torchMode` to `AVCaptureTorchModeOn` after locking the device for configuration. If the camera doesn't support flash, setting `AVCaptureTorchModeOn` will have no effect. To disable it set the `device.torchMode` to `AVCaptureTorchModeOff` and unlock the configuration.\n"],null,["\u003cbr /\u003e\n\nEnabling the device's flash unit during an AR session can help improve\nvisibility.\n\nCheck that the current camera configuration supports flash\n\nNot all camera configurations support enabling a flash unit.\nBefore enabling the flash or offering users the option to enable the flash,\nensure that the flash unit is available for the active camera\nconfiguration: \n\n AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];\n if (device) {\n return device.hasTorch;\n }\n return false;\n\nEnable the flash unit\n\nEnable the flash unit by configuring the AR session with\n[`AVCaptureTorchModeOn`](https://developer.apple.com/documentation/avfoundation/avcapturetorchmode/avcapturetorchmodeon): \n\n AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];\n if (device) {\n if (device.hasTorch) {\n NSError *error = nil;\n if ([device lockForConfiguration:&error]) {\n device.torchMode = AVCaptureTorchModeOn;\n [device unlockForConfiguration];\n } else {\n return;\n }\n }\n }\n\n| **Note:** Configuring [`AVCaptureTorchModeOn`](https://developer.apple.com/documentation/avfoundation/avcapturetorchmode/avcapturetorchmodeon) with a camera configuration that does not support a flash unit will have no effect.\n\nDisable the flash unit\n\nDisable the flash unit by configuring the AR session with\n[`AVCaptureTorchModeOff`](https://developer.apple.com/documentation/avfoundation/avcapturetorchmode/avcapturetorchmodeoff): \n\n AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];\n if (device) {\n if (device.hasTorch) {\n NSError *error = nil;\n if ([device lockForConfiguration:&error]) {\n device.torchMode = AVCaptureTorchModeOff;\n [device unlockForConfiguration];\n } else {\n return;\n }\n }\n }"]]