1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
basemessage.php
См. документацию.
1<?php
2
3namespace Bitrix\Pull\Push\Message;
4
5use Bitrix\Main\ArgumentException;
6use Bitrix\Pull\Push\Service\BaseService;
7
8abstract class BaseMessage
9{
10 protected array $deviceTokens = [];
11 protected ?string $text = null;
12 protected $category;
13 protected $badge;
14 protected string $sound = "default";
15 protected int $expiryValue = 7200;
16
18 protected $title;
19 public $customProperties = [];
20
21 public function addRecipient($sDeviceToken)
22 {
23 $this->deviceTokens[] = $sDeviceToken;
24 }
25
26 public function getRecipient($nRecipient = 0)
27 {
28 if (!isset($this->deviceTokens[$nRecipient]))
29 {
30 throw new ArgumentException(
31 "No recipient at index '{$nRecipient}'"
32 );
33 }
34
35 return $this->deviceTokens[$nRecipient];
36 }
37
38 public function getRecipients()
39 {
41 }
42
43 public function setText($sText)
44 {
45 $this->text = str_replace("\n", " ", $sText);
46 }
47
48 public function getText()
49 {
50 return $this->text;
51 }
52
53 public function setTitle(string $sTitle): void
54 {
55 $this->title = $sTitle;
56 }
57
58 public function getTitle()
59 {
60 return $this->title;
61 }
62
63 public function setBadge(int $nBadge): void
64 {
65 $this->badge = $nBadge;
66 }
67
68 public function getBadge()
69 {
70 return $this->badge;
71 }
72
73 public function setSound($sSound = 'default')
74 {
75 $this->sound = $sSound;
76 }
77
78 public function getSound()
79 {
80 return $this->sound;
81 }
82
83 public function setCustomProperty($sName, $mValue)
84 {
85 $this->customProperties[trim($sName)] = $mValue;
86 }
87
88 public function getCustomProperty($sName)
89 {
90 if (!array_key_exists($sName, $this->customProperties))
91 {
92 throw new ArgumentException(
93 "No property exists with the specified name '{$sName}'."
94 );
95 }
96
97 return $this->customProperties[$sName];
98 }
99
100 public function setExpiry(int $nExpiryValue)
101 {
102 $this->expiryValue = $nExpiryValue;
103 }
104
105 public function getExpiry()
106 {
107 return $this->expiryValue;
108 }
109
110 public function setCustomIdentifier($mCustomIdentifier)
111 {
112 $this->customIdentifier = $mCustomIdentifier;
113 }
114
115 public function getCustomIdentifier()
116 {
118 }
119
120 abstract function getBatch();
121
125 public function getCategory()
126 {
127 return $this->category;
128 }
129
133 public function setCategory($category)
134 {
135 $this->category = $category;
136 }
137
138 public function setFromArray(array $messageArray): BaseMessage
139 {
140 if (is_string($messageArray["TITLE"]) && $messageArray["TITLE"] != "")
141 {
142 $title = $messageArray["TITLE"];
143 $this->setTitle($title);
144 }
145
146 $this->setSound('');
147 if (is_string($messageArray["MESSAGE"]) && $messageArray["MESSAGE"] != "")
148 {
149 $text = $messageArray["MESSAGE"];
150 $this->setText($text);
151
152 if (!empty($messageArray["SOUND"]) && is_string($messageArray["SOUND"]))
153 {
154 $this->setSound($messageArray["SOUND"]);
155 }
156 }
157
158 if (isset($messageArray["CATEGORY"]))
159 {
160 $this->setCategory($messageArray["CATEGORY"]);
161 }
162
163 if (array_key_exists("EXPIRY", $messageArray))
164 {
165 $expiry = (int)$messageArray["EXPIRY"];
166 $this->setExpiry($expiry >= 0 ? $expiry : BaseService::DEFAULT_EXPIRY);
167 }
168
169 if (isset($messageArray["PARAMS"]))
170 {
171 $this->setCustomProperty(
172 'params',
173 (is_array($messageArray["PARAMS"]) ? json_encode($messageArray["PARAMS"]) : $messageArray["PARAMS"])
174 );
175 }
176
177 if (isset($messageArray["ADVANCED_PARAMS"]) && is_array($messageArray["ADVANCED_PARAMS"]))
178 {
179 if (array_key_exists("senderMessage", $messageArray["ADVANCED_PARAMS"]))
180 {
181 $this->setText("");
182 }
183
184 foreach ($messageArray["ADVANCED_PARAMS"] as $param => $value)
185 {
186 $this->setCustomProperty($param, $value);
187 }
188 }
189
190 $badge = (int)($messageArray["BADGE"] ?? 0);
191 if ($badge >= 0)
192 {
193 $this->setBadge($badge);
194 }
195 return $this;
196 }
197}
setSound($sSound='default')
Определения basemessage.php:73
setCategory($category)
Определения basemessage.php:133
getCustomProperty($sName)
Определения basemessage.php:88
addRecipient($sDeviceToken)
Определения basemessage.php:21
setFromArray(array $messageArray)
Определения basemessage.php:138
setCustomIdentifier($mCustomIdentifier)
Определения basemessage.php:110
setTitle(string $sTitle)
Определения basemessage.php:53
setExpiry(int $nExpiryValue)
Определения basemessage.php:100
getRecipient($nRecipient=0)
Определения basemessage.php:26
setCustomProperty($sName, $mValue)
Определения basemessage.php:83
setBadge(int $nBadge)
Определения basemessage.php:63
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
<? endif;?> window document title
Определения prolog_main_admin.php:76