Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
huaweipushkitmessage.php
1<?php
2
4
6
8{
9 public function getBatch(): string
10 {
11 $data = $this->getPayload();
12 $batch = "Content-type: application/json\r\n";
13 $batch .= "Content-length: " . strlen($data) . "\r\n";
14 $batch .= "\r\n";
15 $batch .= $data;
16
17 return base64_encode($batch);
18 }
19
20 public function getPayload(): string
21 {
22 $customData = Json::encode([
23 "contentTitle" => $this->title,
24 "contentText" => $this->text,
25 "badge" => $this->badge,
26 "messageParams" => $this->customProperties,
27 "category" => $this->getCategory(),
28 "sound" => $this->getSound(),
29 ], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_UNESCAPED_UNICODE);
30
31 $payload = [
32 "message" => [
33 "data" => $customData,
34 "android" => [
35 "ttl" => (string)$this->expiryValue,
36 ],
37 "token" => $this->deviceTokens,
38 ],
39 ];
40
41 return $this->strippedPayload($payload);
42 }
43}