I have a problem with my QR code. The data of the QR code is the text like this "Name: John Cena" (the text includes the colon). Most of the QR code scanner apps and Android camera can scan it but the iPhone camera can not do that.
The example in the image:
Can anyone help me figure out this problem? Thanks a lot!
A QR can technically have any text string (not exceeding a certain length). So if you have some custom app reading custom QR codes, you can put in whatever payload you want. So, you technically can put “Name: John Cena” in as a payload.
But if you want it to be universally recognized, you want to follow certain conventions. For example, for sharing a contact, you might follow the VCARD
format:
BEGIN:VCARD
VERSION:3.0
N:Cena;John;;;
FN:John Cena
END:VCARD
The above VCARD payload is a simplified rendition of what CNContactVCardSerialization
generates (which offers a nice API to translate contact info into a QR), rendered as an image via CIImage
generator filter CIQRCodeGenerator
. This VCARD serialization tool is a good way to make well-formed contact cards that (largely) follow established standards.
But as you can see, the colon is not what presents the challenge (as the above includes colons, too). It is simply that “Name: John Cena” is not an accepted standard.
Or, another common practice is to put some well established URI. E.g., https://google.com/search?q=John+Cena
results in:
Or mailto:John.Cena@example.com
:
There are a variety of well-known payloads. The Wikipedia page on QR codes outlines a bunch of them. Or I am sure a web search for “QR codes” can provide other authoritative sources.
But if you put strings that do not follow one of these well-established standards in your QR codes, the iOS camera will not pick them up (as it does not know what to do with the resulting string). But many third party apps will show you the contents of the QR payload, whether one of the established standards, or not.