Objective-C : is it possible to detect QR code dat

2019-05-10 10:54发布

问题:

I did qr code with Zxing, Right now I can read data but what I want is :

  • Example: Be able read type of QR Code is wifi, VCard, Calendar, url, etc... if detect QR Code is wifi so I be able code to change wifi setting key,

So, how do i know that data read from QR code is wifi?

回答1:

QR Code itself does not specify any types. Its plain text. It can be an HTTP URL or a custom URL. (e.g. it should have "type://wifi" inside it. You can then use it to see what the type is). But off-the-shelf, there is no such thing. You have to know who is creating the QR Codes and what is he storing in them.



回答2:

There is no standard format for encoding wi-fi information in a QR code. There is a de facto standard suggested by zxing and supported by Barcode Scanner, which is like:

WIFI:T:WPA;S:mynetwork;P:mypass;;

(This imitates many of DoCoMo's standards for QR code contents.) I'd just reuse this if you can.

This page lists common encodings for other data. Whether you can do anything with them on the iPhone, I don't know. On Android you can scan these to configure Wi-fi and add contacts.



回答3:

Here is a nice document of different QR code types. None of them are standard, but you get the idea: https://github.com/zxing/zxing/wiki/Barcode-Contents

There is platform specific format for Android.

    WIFI:T:WPA;S:mynetwork;P:mypass;;

Though, if there is no API for setting the WIFI settings on iOS, any format doesn't help much :/