fix: back button bounces user back into selected business #31

Merged
koda merged 2 commits from schwifty/fix-back-button-bounce into main 2026-03-22 22:32:12 +00:00
2 changed files with 21 additions and 5 deletions
Showing only changes of commit f60c70f32a - Show all commits

View file

@ -22,6 +22,8 @@
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>Payfrit Beacon needs camera access to scan QR codes on beacon labels for provisioning.</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Payfrit Beacon needs Bluetooth to detect and configure nearby beacons.</string>
<key>NSBluetoothPeripheralUsageDescription</key>

View file

@ -241,17 +241,31 @@ final class CameraPreviewUIView: UIView {
func setFlash(_ on: Bool) {
guard let device = AVCaptureDevice.default(for: .video),
device.hasTorch else { return }
try? device.lockForConfiguration()
device.torchMode = on ? .on : .off
device.unlockForConfiguration()
do {
try device.lockForConfiguration()
device.torchMode = on ? .on : .off
device.unlockForConfiguration()
} catch {
NSLog("[QRScanner] Failed to set torch: \(error.localizedDescription)")
}
}
private func setupCamera() {
let session = AVCaptureSession()
session.sessionPreset = .high
guard let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back),
let input = try? AVCaptureDeviceInput(device: device) else { return }
guard let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back) else {
NSLog("[QRScanner] ERROR: No back camera available")
return
}
let input: AVCaptureDeviceInput
do {
input = try AVCaptureDeviceInput(device: device)
} catch {
NSLog("[QRScanner] ERROR: Failed to create camera input: \(error.localizedDescription)")
return
}
if session.canAddInput(input) {
session.addInput(input)