Материал из for iRidium developers
Перейти к: навигация, поиск
Эта страница является переводом страницы Push notifications. Перевод выполнен на 100%.

Other languages:
English • ‎русский

Push notifications

Instructions for sending Push notifications from iRidium server to iOS, Android devices with i3 pro

read the handbook on JS methods for Push notifications

download the example

How It Works

iRidium server can notify the user about any event in the automation system, which it perceives. One of the ways of notification is sending Push notifications to smartphones and tablets where the i3 pro application is installed. i3 pro can be closed, you only need Internet connection without which Push notifications will not be received by the addressee.

iRidium server sends the command "to notify control panels" to the iRidium mobile website. The iRidium mobile website redirects the command to Apple or Google services (depending on the control panel OS). And the services send notifications to smartphones and tablets of users.


To understand which smartphones and tablets should receive notifications, they have to be in the list of active control panels on the iRidium mobile website.

iRIdium Server отправляет уведомления не каждому устройству отдельно, а условным Группам устройств. Настроить Группы можно в объекте iRidium Cloud, вкладка "Пользователи и проекты". Подробно - читайте далее.

! It is not possible to send Push notifications without iRidium server

! If a control panel is not connected to the Internet, Push notifications cannot be received

! Sometimes Push notifications cannot be delivered to the addressee. Please, ensure backing up of important messages, for example, with the help of SMS. It is because Apple and Google services do not have control of Push notifications delivery

How to Set up Sending and Processing of Push Notifications

Any event of iRidium server can be used to send Push notifications:

  • Commands from control panels or the server web-interface, initiated by users
  • State change of automation system equipment
  • Change of the date, time and other parameters of the environment which are not directly related to the equipment and user activity

You can send Push notifications on your smartphone or tablet with i3 pro only from iRidium server. There is a special command for sending notifications. It is set in the JavaScript editor of the server project. Ways to activate this command with different events on iRidium server:

1 Create a new project for iRidium server in iRidium Studio (File > New > New Server Project...)

2 Add the variables at changing which notifications should be sent in the server project:

  1. To notify about button clicking a button on the control panel, add the virtual command: Virtual > Channels > (+) in the server project. It will change the variable state from the control panel and use the change as a signal to send notifications
  2. To notify about changes in the automation system, set up drivers for system equipment in the project. Change of driver feedbacks will be used as a signal to send notifications
  3. To notify about changes of date and time (or other system data), you can refer to the system parameters. There is no need to create additional channels.

3 Open the editor window [JS] in the top toolbar of iRidium studio. Create a new script file: (+) > New Script and set up sending of notifications at various events in it. Let Let's consider three options:

3.1. To send a notification from the control panel or the server web-interface

see the video-instruction

Sending of notifications in this case is implemented with the help of scripts:

//********** send push when User press a button in i3 pro  **********
function push_from_i3(type, name, value)
   IR.SendPush(value, "info", 1); // send notification (text of notification, hiden data, group of panels)
In order for the script to work, you need to assign the function created in the script push_from_i3 to the server virtual command as a modifier. In order to do this, select the server virtual command (in the example it is the "Push from Panel" command), open its property Script Modifier and select the function push_from_i3 in it:

Now any string stored in "Push from Panel" will be converted into a Push notification and will be sent by the server to control panels.

3.2. Send a notification if the driver state changes

Sending of notifications in this case is implemented with the help of scripts:

//********** send push when Feedback of driver changes  **********
var driver = IR.GetDevice("KNX"); // driver name
IR.AddListener(IR.EVENT_TAG_CHANGE, driver, function(name,value)
   if (name == "Address 1" && value == 1) // if the KNX feedback "Address 1" changed to 1
      IR.SendPush("Back door opened!", "show backdoor camera", 1); // text of notification, hiden data, group of panels

In order for the script to work, the feedback channel "Address 1" of the "KNX" driver has to receive value 1. No additional actions are required from the user is not - sending of notifications is automatic.

3.3. To send a notification on the selected date

Sending of notifications in this case is implemented with the help of scripts:

//********** send push when it is some Date & Time  **********
IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, function (name, value)
   // conditions:
   if (IR.GetVariable("System.Date.MM_DD") == "03/14" && IR.GetVariable("System.Time.Hour") == 10 && IR.GetVariable("System.Time.Minutes") == 0) 
      IR.SendPush("Happy Birthday Mike!", "notification", 1); // text of notification, hiden data, group of panels
IR.SubscribeTagChange("System.Time.Minutes"); // subscribe on minutes to check condition each minute

The script is activated every minute and checks for the condition - the indicated date and time. Reaction to change of parameters in the operating system is provided by the global listener and subscription. A notification will be sent when the conditions are satisfied - month/day and time selected as the moment to send the notification occur

4 Create a project for the control panel: right-click on the server project > Create Project Panel.
Find the iRidium server driver in the created project and indicate the IP-address (Host) of the device on which you plan to run iRidium server, otherwise the control panel will not be able to connect to it.
i3 pro does not need any special settings to get notifications when the app is closed or minimized but we will set up additional possibilities for handling notifications (it is optional):

4.1. Set up handling of Push notification in the opened i3 pro app (RECOMMENDED)

If you don't add the handler of Push notifications in the project for control panels, then you will not be able to know that you received a notification while the app is opened

If the i3 pro application is already launched and opened on the control panel, the window with Push notifications will not pop up and the notification sound will not be heard by default. But it may also be required to handle server events in the opened application. Therefore, for handling of Push notifications in the opened application, add the script in the project for the control panel (*.irpz):

//********** Play sound and display text when notification received by the opened app **********
IR.AddListener(IR.EVENT_RECIEVE_PUSH_NOTIFY, 0, function(text, data, group)
    IR.PlaySound('Alerting.wav',0,50); // play sound
    IR.GetPage("Page 1").GetItem("text").Text = text; // display text of notification
    IR.GetPage("Page 1").GetItem("data").Text = data; // display  hiden data that can be used in JS

In this example, when receiving a Push notification, the application plays the sound and writes the data received from the notification on the graphic items in the project.

4.2. Only for 3.1. Set up sending of notifications by clicking the button in i3 pro

It applies only if there is the script implemented in the 3.1 example in the server project "To send a notification from the control panel or server web-interface "

To initiate the sending of notifications by user actions implemented in the 1st example of the script for the server, you need to control server virtual variables from the control panel. The setup does not directly relate to work of Push notifications, here we just write the server virtual variable in a string. The server processes the string and converts it into a Push notification for all control panels.

Create a graphic item - Button or Editbox. It will send the text of your notification to the server. Find the "Push from Panel" command in the "iRidium server" driver and drag it on the graphic item. In the dialog window for command assigning select Action: Send Token and in the value field: the .Text property of the item. For Editbox it is also necessary to assign the Show Keyboard command to start entering data from the keyboard of the mobile device after clicking on Editbox.


5 Save the projects for the server and the control panel and upload them in iRidium cloud. It is required for both projects to belong to the same automation object in the cloud.

Push notifications come only to devices, for which projects were downloaded from iRidium cloud (and not from iRidium transfer)

6 Create a Trial or commercial license for the object

7 Invite (activation step 4) the end-user in the object or use your alternative e-mail.

The control panel authorized as integrator will not get notifications because integrator's device are not included in the list of those who gets notifications! To check whether notifications work or not, you need to log in to the i3 pro app using the end user account

8 Set up Push Groups - grouping of users. In the example we set up sending of notifications to group 1, so we will create group 1 in the cloud:


1. Invite the end user to the project. Click "Push Groups" in "Users & Panels" to set up the groups that will contain the invited user

2. Create group 1 (for our example), select any name for it

3. The group is now linked to the end user. He will get notifications sent to the group

9 Sign in in i3 pro on your iOS, Android device as the end user (activation step 5.1), download the project with handling of notifications. Remember, that the integrator's account in i3 pro cannot be used to test Push notifications!

10 Sign in (activation step 5.2) on the server as an integrator, download the project with handling of notifications.

If you set up the script from 3.1, you can send a notification with free text using the server web-interface: go to the "Channels&Feedback" tab, select the "Push from Panel" command and enter the text you want to send. The server will generate a notification and it will appear on your iOS, Android device

11 Everything is ready. Your mobile device will get the notification from the server when any of the preset events is activated. Send notifications from control panels, the server web-interface or monitor changes of equipment status, time and date events with the help of notifications.

While the i3 pro app is opened and maximized on the control panel, you will not see the pop-up window with notifications or hear the sound of notifications. In order to make them active in the opened app, they should be set up separately, see 4.2