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

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

iRidium API. Push notifications

methods for sending Push notifications to iOS and Android devices

read the instruction

see the video-instruction

download the example



Only for iRidium Server! Send Push notifications to the group of control panels


IR.SendPush(title, js_data, group_id, [status_callback], [this_ptr], [sound_type]);

input value description
title "text of notify" type: string
the notification text
js_data "data" type: string, JSON
data for sending to scripts of the application client that received the notification
group_id 1 type: number
identifier of the group of devices that will receive the notification. The groups have to be set up in your account on the website, the "Users & Panels" tab
status_callback status type: function
the processing function of the Push status. On input the function receives the object that stores the code and text description of the result of sending the Push notification
this_ptr this type: this
a pointer to the environment, it will be available in status_callback like this
sound_type 0 type: number
the type of sound that will be called on receive of Push notification. 0 - short sound (by default), 1 - long sound



// simple Push (send a text)
IR.SendPush("Hello World!", "Data", 1);
// advanced Push (with data to JS and status processing)
function status (object) {
	IR.Log('Status of Push: ' + object.Error + ' - ' + object.ErrorDescription);
IR.SendPush("Hello World!", "data for JS", 1, status, this, 0);

the amount of text and data that can be sent in a Push notification is limited and depends on the device to which you send the notification (2 KB for iOS, 4 KB for Android). If the available data amount is exceeded, the method returns an error
& и # symbols is not supported in Push messages and JS data

Groups of Devices

In order for control panels to get notifications they had to be placed in a group. The group is created on the website, in the "Users&Panels" tab of the cloud object settings. The group is assigned to the "user+project" combination. I.e. each project of one user can be a part of different groups and get different notifications.


1 To assign a group to a user and project. The group will be automatically assigned to any control panel where the user authorizes and downloads the project
2 To assign a group to a control panel by its HWID. You can remove or add Groups for separate panels


1 To create a new group (you will use Group ID to send a Push notification)
2 Groups that include the control panel (user and project)
3 The groups that do not include the control panel

Function for Processing of the Push Status

Only for iRidium Server! It is activated each time you send a Push notification and receives the result about the sending: success or error.

function status (object)
	IR.Log("Status of Push (Code): " + object.Error);
	IR.Log("Status of Push (Text): " + object.ErrorDescription);
IR.SendPush("Hello World!", "Data", 1, status, this, 0);
  • object.Error - the code of an event, the result of sending a Push notification. The event code:
    • 0 (Success) - successful sending
    • 1-10 (Error) - the error code
  • object.ErrorDescription - the text description of the event



Only for i3 pro! the handler of data received with Push notifications. It will get the notification text, data for JS and ID of the group for which the notification is intended.


IR.AddListener(IR.EVENT_RECEIVE_PUSH_NOTIFY, 0, function (text, data, group) {}, [pointer]);

input value description
function function() {} type: function
the unnamed function or reference to the function
pointer - type: object
the pointer to the object which serves the function (optional)



IR.AddListener(IR.EVENT_RECEIVE_PUSH_NOTIFY, 0, function(text, data, group)
      IR.Log("EVENT_RECEIVE_PUSH_NOTIFY:" + text + " data:" + data + " group:" + group);
      if(data == "do the action")
            IR.Log("Ok I do"); 
      if(data.indexOf("{") == 0)
         var obj = JSON.Parse(data);
         if(typeof(obj) != "undefined")