Tokens

From iRidium Mobile Wiki
Jump to: navigation, search

DOWNLOAD: Example of a project


Description

Tokens save information when closing the application so we could use it when opening the application again. For example, if you use a password, you can save it in the token and next time you don't need to enter the password.


Command Types for Working with Tokens

For working with tokens there are the following commands:

  • Reading from a token
  • Writing to a token


Writing Values to Tokens

To write values to tokens use the command:

IR.SetVariable("Tokens,Token_name",'value sent to the token')

  • Token_name - indicate the name of the token where the value is to be written to
  • value sent to the token - indicate the value to be written to the token
IR.AddListener(IR.EVENT_START,0,function()   //Event is activated at the application launch
{
IR.SetVariable("Tokens.example",'300')   //Writing the value in the token
});

Reading Data from Tokens

To read data from tokens use the command:

IR.GetVariable("Tokens,Token_Name")

  • Token_Name - indicate the name of the token where the value will be written to
IR.AddListener(IR.EVENT_START,0,function()   //Event is activated at the application launch
{
IR.GetVariable("Tokens.example")   //Reading from the indicated token
});


DOWNLOAD: Example of a project