Development of QR Code Search in Mobile Application
QR code contains structured data: URL, vCard contact, Wi-Fi credentials, payment request. Task of QR code search is parsing content and routing to right action. Implementation simpler than with barcodes, but content handling logic requires thought.
Scanning: shortest path
iOS 16+: DataScannerViewController — system scanner, requires one line setup:
let scanner = DataScannerViewController(
recognizedDataTypes: [.barcode(symbologies: [.qr])],
qualityLevel: .balanced,
isHighlightingEnabled: true
)
isHighlightingEnabled: true adds visual highlight of found code — users appreciate it.
iOS 14-15: VNDetectBarcodesRequest from Vision framework for photo, AVCaptureMetadataOutput for live video. Bit more code, but same logic.
Android: ML Kit BarcodeScanning.getClient() with BarcodeScannerOptions — specify FORMAT_QR_CODE for speed optimization. If need all formats — remove filter, but slightly slower.
Parsing and routing
QR code is string. What to do depends on content:
- Starts with
http://orhttps://→ open inSFSafariViewController/CustomTabs -
WIFI:S:NetworkName;T:WPA;P:password;;→ offer Wi-Fi connection (on iOS viaNEHotspotConfiguration, on Android viaWifiNetworkSuggestion) -
BEGIN:VCARD→ parse viaCNContactVCardSerialization(iOS) orVCardReader(Android) - Internal app format → custom handling
Regexes for type detection work, but fragile. Better — ML Kit on Android auto-detects type via Barcode.valueType (URL, WIFI, CONTACT_INFO etc). On iOS VNBarcodeObservation.payloadStringValue returns raw string — type parsing yourself.
Working with gallery
Users expect to select QR code from photo in gallery, not just camera scan. Implementation:
iOS: PHPickerViewController → get UIImage → VNDetectBarcodesRequest on CIImage. Works sync or via perform in background thread.
Android: ActivityResultContracts.GetContent("image/*") → get Uri → InputImage.fromFilePath(context, uri) → BarcodeScanning.getClient().process(inputImage).
Common error: image processing on main thread. On gallery photo blocks UI for 200-500ms. Always — background thread.
Development timeline: 1-2 days. Cost calculated individually.







