yannickl / QRCodeReader.swift

Simple QRCode reader in Swift
MIT License
1.33k stars 330 forks source link

I want to stop camera after validation of QR code #170

Open anuj2219 opened 5 years ago

anuj2219 commented 5 years ago

Hi,

I am trying to stop camera after validation code.

Example - I am validation domain first after scan because end user may be scan other QR code. So if I am using didFindCode and after that I am validating code if code is not for my app so I start scanning again but in this case camera screen is fluctuating.

Here is my code I am using QRCodeReaderView for custom view

        reader.didFindCode = {[weak self] result in
            guard let `self` = self else { return }
            let url = result.value
            let url1 = URL.init(string: url)
            if let baseUrl = url1?.host{
                if baseUrl == "domain.co" || baseUrl == "domainName.co"{
                  // Some Code Validation 
                    }
                }else{
                    self.snackbar.text = "Invlid QR code"
                    MDCSnackbarManager.show(self.snackbar)
                    self.reader.startScanning()
                }
            }
        }
        reader.startScanning()

So please let me know if I am missing anything.

Thanks for great QR example

yannickl commented 5 years ago

Sorry I don't understand your use case. :/

You should call the reader.stopScanning() method to stop the camera.

anuj2219 commented 5 years ago

I am trying to say I want to stop camera after validation QRCode if QR is invalid want keep camera open like Linkedin QR scanner for user profile.