Documentation

CPushManager

Class manages how push-notifications are sent to a phone number

You can send push-notification if this option is enabled in settings:

CPullOptions::GetPushStatus()

If a user is online, a message is included into mailing table first for a 15-seconds period (standby time can be longer, depending on the type of agent executed on site), and then it is sent out. If the user is offline, the message will be sent out immediately.

$CPushManager = new CPushManager();
$CPushManager->AddQueue(Array(
   'USER_ID' => 1,
   'MESSAGE' => 'Test message',
   'TAG' => 'IM_MESS_1',
   'SUB_TAG' => 'IM_MESS'
));

Parameters

Parameter Description Available from version
USER_ID User who receives a push-notification
MESSAGE Message text (maximum 255 symbols).
TAG Optional. It is necessary if they must be deleted prior sending out.
SUB_TAG Optional. It is necessary if they must be deleted prior sending out.

Also, SEND_IMMEDIATELY = Y key can be passed to send a message without delay, if your logic requires it.

Note: user must be subscribed on push-notifications; it occurs automatically after entering an account via mobile app.


Deleting push-notification by the main tag

CPushManager:: DeleteFromQueueByTag($userId, $tag);

Deleting a Push notification by the additional tag

CPushManager:: DeleteFromQueueBySubTag($userId, $subTag);

Attention: deleting is possible only, if a push-notification hasn't been sent yet to a user.



© «Bitrix24», 2001-2024
Up