Reputation: 215
So I am trying to store some data within a QR Code. I have set my app up so it will scan the QR Code and perform actions based on the content. A user must have my app to do this. If someone didn't have my app, I would like for them to be able to scan the QR code with a normal/third-party QR scanner and be directed my website or my app's AppStore page. I have found a post from an Android user who describes encoding data into a URL. A normal QR scanner would only see the URL and direct the user to a website. A custom app would decode the URL and extract the data within. I'm just wondering whether anything like this is possible for Swift?
Thanks in advance.
Upvotes: 0
Views: 336
Reputation: 131481
Yes, that's trivial, and there's nothing special about Swift or iOS involved in doing it.
Set up your URL to be a URL that points to your website, with a query parameter that passes the desired data:
http://mywebsite/loaddata?code=aabbccddeeffgghhiijjkkllmmnn
You could encode the data as Base64 encoded output from the encryption algorithm of your choice, so only your apps would be able to decode it.
Encode that as the string in your QR code. Most QR code readers recognize HTTP URLs and will offer to open the link.
You would then code your website to respond to the URL as desired.
Your app could be coded to parse the string from the QR code and ignore everything but the part after the code=
.
Upvotes: 2