Overview

The Turck RFID app is available on both Android and iOS, and has identical functionality on each platform. Developers can use Javascript to customize Turck RFID and to write custom cross-platform RFID scripts.

The steps for using Javascript are:

  1. Create your Javascript script, either starting from Turck RFID or from one of the sample scripts.
    The Turck RFID app (defaultApp.js) and several sample scripts are available here. You can download any of these as a starting point.
  2. Make your script file(s) availble via URL, normally by hosting it on your server
  3. Load the script in Turck RFID
    • manually in settings
      In the Turck RFID app, press and hold the settings button.
    • by invoking Turck RFID via URL and specifying the script to run
      On an Android or iOS device, invoke the URL
      turckrfid://app?source=URL_TO_LOAD_APP_FROM
When running a sample script, you can return to the default Turck RFID script:

Anatomy of a Turck RFID script

This is a very simple script that just displays a button:

//
// test app
//
'use strict';

class HelloWorldApp extends turck.App {

  ///////////////////////////////////////////////////////////////////////////////////////
  // Constructor
  ///////////////////////////////////////////////////////////////////////////////////////

  constructor() {
    super();
  }

  ///////////////////////////////////////////////////////////////////////////////////////
  // App has just launched, show the home screen
  ///////////////////////////////////////////////////////////////////////////////////////

  onLaunch(launchAction, launchPath, launchParameters) {
    app.showPage(new turck.ui.GadgetPage({
      titleText: "hello world",
      gadgets:[
        new turck.ui.Button({
          position: [{type: "parent", ratio: 0.5, at: "center"},
                     {type: "parent", ratio: 0.5, at: "center"}],
          text: "button",
          click: function() { app.showToast("hi!"); }
        })
      ]}));
    app.handleLaunchParameters(launchAction, launchPath, launchParameters);
  }

}

///////////////////////////////////
///////////////////////////////////

//
// Create the app object
//
var app = new HelloWorldApp();
The app object

The script is a Javascript object named app that subclasses turck.App. Javascript's flexibility means that app can be declared may ways, here we use ECMA classes. The onLaunch() function is called when the script starts running. it normally uses app.showPage() to show the home page for the script. The object passed to the script is normally a