Since iOS 11, the native camera app can decode QR codes. This got our attention as QR codes are the default serialization tag for the ADIs of Thngs and products in our platform.
We believe native QR code support allows for a paradigm shift in the way people interact with real world objects. Until now, a user could only interact with a QR code Thng through a web app which uses evrythng-scan.js or by downloading a native app which supports QR codes. With iOS 11, over a billion iPhone and iPad users will be able to directly interact with Thngs by scanning a QR code directly from the camera app without needing a third-party app.
A powerful feature of the EVRYTHNG platform is the Redirector. The Redirector allows you to write simple context-aware rules that are fired when the QR code of a product or Thng is scanned. The Redirector supports redirection to web pages as well as to native apps.
Let us now go through a concrete example to show how EVRYTHNG can help you to drive a native user experience on an iOS 11 device. In this use case, we will use a Thng, it’s QR code and the Redirector to build a small campaign that will open a song on iTunes based on where the a QR code on a Thng or product was scanned.
Create a new project. Make sure you set "Current Project" to your QR code project, otherwise resources (such as applications or Thngs) will be unscoped and will be accessible to every project in our account.
Within the newly created project, create an application. We'll call it "Songs of London".
Create a new Thng using the 'Thngs' section. The newly created Thng doesn't have a QR code yet. We'll do that once the redirector is set up.
Go to to the account Redirector using the left-hand navigation panel.
Add a rule to the account Redirector to defer the redirection result to the previously created application "Songs of London".
Go back to the "Songs of London" application. Scroll down and add a new application Redirector rule by selecting “Create Rule”.
We will create one rule, that will play "Streets of London" when someone scans a QR code in the vicinity of the EVRYTHNG office. Set the name to "Streets of London" and the Redirect URL to
https://itun.es/gb/et8st?i=323732789. Since in iOS apps can be bound to URLs this will open the native iTunes app with the selected song. With this mechanism you can drive native experiences via the web!
We can declare this rule to be triggered when in or near London by adding two conditions:
- Location latitude between 50.0 and 51.0.
- Location longitude between 0.0 and 1.0.
Then select “Create rule”.
Feel free to add more songs, change the coordinates to where you are or add other context based rules. The example above shows an additional song for when the QR code is scanned in New York.
Next, go back the Thng you created and select 'Setup redirection'.
For the application, select "Songs of London", add a default URL, and then create the rule.
A new QR code will be created to enable devices to follow the redirection.
Your Redirector should now be setup and working properly. Take your iPhone or iPad, open the camera app and target the QR code on your screen (you don't even need to take a picture!) and you'll see a notification when the QR code is decoded. If you don't have iOS 11 installed yet, try the QR code scanner that comes with another app, such as the Twitter app or Chrome. When you scan the code, the Redirector will return the URL of the song in iTunes based on your location.
At this point, you're probably wondering about when is best to use the Redirector. You might also have come across the Reactor and you're wondering why we have two rule-based systems. In short, the Redirector is synchronous and returns a valid URI based on simple rules. As you have seen the Redirector can redirect to the URL of a Web app or to a URI launching an app on iOS or Android.
The Reactor is an asynchronous rules engine that can be used to implement complex rules.
The Redirector is great when you want to drive tailored user experiences from the Web as a direct response to action. For example:
- Present personalised information to users after a product scan.
- Open native apps and Web apps based on the kind of product the user scanned.
- Launch the control application of a connected device.
Don't use the redirector to:
- Modify incoming events.
- Send incoming events them to third party systems.
- Trigger background services and execute complex instructions.