How to detect type of data in QR Code after scan it

Hello I’m using Expo SDK 44
How can I parse the scanned result data received from my barcode scanner to a new screen?

Data scanned ex =>;SUB:subject;BODY:description;;

How to show to user a normal data?

Hi @abdotatito

Are you expecting to only scan these “MATMSG” QR codes? Or is this just an example?

Either way, the QR code just represents a blob of data. That data might look like a URL or it might look like vCard data etc. If you know that the data should be one of these MATMSG things then you should be able to parse it manually or else maybe you can find an existing npm that parses them.
If you could get any random type of data then your code would probably need to check if it looks like a URL. If so, treat it as such. Otherwise see if it looks like vCard data, you can use a vCard parser to parse it. Otherwise if it looks like iCalendar data you could use an iCalendar parser. etc.

EDIT: See also:

The MATMSG” QR codes are just an example of the problem there are a lot of types of QR Codes (email, vCard, URL, WIFI, Event…) I just ask if there’s a simple way or a solution already built to use it instead of checking the content manually

OK. Not that I’m aware of. There’s nothing built in to the Expo SDK for that, but this problem is not specific to Expo or React Native or even mobile apps. All you need is a JavaScript library that can guess the content type and then parse it in some way.

Since this is not a problem that’s specific to Expo, I suggest you do some searching for a JavaScript package that will do this and if you don’t find it you might try asking on a more general forum like Stack Overflow.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.