codebude / QRCoder

A pure C# Open Source QR Code implementation
MIT License
4.61k stars 1.1k forks source link

Can't use custom protocols in generator. #157

Closed Abrifq closed 5 years ago

Abrifq commented 5 years ago

Type of issue

[Doesn't support custom protocols ("protocol://api") ] Bug

Expected Behavior

"protocol://api" should redirect to corresponding app, if there is not any, should show an error page in Safari (or in other browser)

Current Behavior

"protocol://api" redirects to "{default search engine}.com/?q=protocol://api"

Possible Solution (optional)

Create a custom variable type to initilaize it as URL

Steps to Reproduce (for bugs)

qrCodeData = qrGenerator.CreateQrCode("protocol://api", QRCodeGenerator.ECCLevel.Q);

Your Environment

.NET 4.6.1 Win 7 x64

READER => iOS 12 (camera app)

codebude commented 5 years ago

This is not the fault of QRCoder. It encodes exactly the string, which is given to it. The logic to open an app can't be handled by a QR code at all. It everytime the task of the scanner app.

So your request...

"protocol://api" should redirect to corresponding app, if there is not any, should show an error page in Safari (or in other browser)

...can't be handled within the specs of QR code.

Nevertheless it's possible to launch apps via QR code. But it works only, if the given uri scheme (protocol://api...) is registered in the iPhones plist. https://stackoverflow.com/questions/47636662/how-to-open-an-app-with-the-ios11-integrated-qrcode-reader

If it's not registered (app not available) the iPhone won't launch the app, but start a search. This is the standard behaviour.