mirror of
https://github.com/selfxyz/self.git
synced 2026-04-05 03:00:53 -04:00
31 lines
783 B
Swift
31 lines
783 B
Swift
//
|
|
// QRScannerBridge.swift
|
|
// OpenPassport
|
|
//
|
|
// Created by Rémi Colin on 23/07/2024.
|
|
//
|
|
|
|
import Foundation
|
|
import SwiftQRScanner
|
|
import React
|
|
|
|
@objc(QRScannerBridge)
|
|
class QRScannerBridge: NSObject {
|
|
@objc
|
|
static func requiresMainQueueSetup() -> Bool {
|
|
return false
|
|
}
|
|
|
|
@objc
|
|
func scanQRCode(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
DispatchQueue.main.async {
|
|
let rootViewController = UIApplication.shared.keyWindow?.rootViewController
|
|
let qrScannerViewController = QRScannerViewController()
|
|
qrScannerViewController.completionHandler = { result in
|
|
resolve(result)
|
|
}
|
|
rootViewController?.present(qrScannerViewController, animated: true, completion: nil)
|
|
}
|
|
}
|
|
}
|