1 | <?php |
||
21 | class GCM extends MessageBase |
||
22 | { |
||
23 | /** |
||
24 | * The maximum size allowed for an Android notification payload is 4096 bytes |
||
25 | */ |
||
26 | const PAYLOAD_MAX_LENGTH = 4096; |
||
27 | |||
28 | /** |
||
29 | * It`s possible to send the same message to up to 1000 registration IDs in one request |
||
30 | */ |
||
31 | const MAX_RECIPIENTS_PER_MESSAGE_COUNT = 1000; |
||
32 | |||
33 | /** |
||
34 | * Allow test the request without actually sending the message |
||
35 | * |
||
36 | * @var boolean |
||
37 | */ |
||
38 | private $dryRun = false; |
||
39 | |||
40 | /** |
||
41 | * If there is already a message with the same collapse key (and registration ID) |
||
42 | * stored and waiting for delivery, the old message will be discarded |
||
43 | * and the new message will take its place |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | private $collapseKey; |
||
48 | |||
49 | /** |
||
50 | * Message payload data |
||
51 | * |
||
52 | * @var array |
||
53 | */ |
||
54 | private $payloadData; |
||
55 | |||
56 | /** |
||
57 | * If the device is connected but idle, the message will still be delivered right away |
||
58 | * unless the delay_while_idle flag is set to true |
||
59 | * |
||
60 | * @var boolean |
||
61 | */ |
||
62 | private $delayWhileIdle; |
||
63 | |||
64 | /** |
||
65 | * Package name of you application |
||
66 | * |
||
67 | * @var string |
||
68 | */ |
||
69 | private $packageName; |
||
70 | |||
71 | /** |
||
72 | * @return string |
||
73 | */ |
||
74 | public function getMessageType() |
||
78 | |||
79 | /** |
||
80 | * @return string |
||
81 | */ |
||
82 | public function getCollapseKey() |
||
86 | |||
87 | /** |
||
88 | * @param string $collapseKey |
||
89 | * @return $this |
||
90 | */ |
||
91 | public function setCollapseKey($collapseKey) |
||
96 | |||
97 | /** |
||
98 | * @return boolean |
||
99 | */ |
||
100 | public function isDelayWhileIdle() |
||
104 | |||
105 | /** |
||
106 | * @param boolean $delayWhileIdle |
||
107 | * @return $this |
||
108 | */ |
||
109 | public function setDelayWhileIdle($delayWhileIdle) |
||
114 | |||
115 | /** |
||
116 | * @return boolean |
||
117 | */ |
||
118 | public function isDryRun() |
||
122 | |||
123 | /** |
||
124 | * @param boolean $dryRun |
||
125 | * @return $this |
||
126 | */ |
||
127 | public function setDryRun($dryRun) |
||
132 | |||
133 | /** |
||
134 | * @return string |
||
135 | */ |
||
136 | public function getPackageName() |
||
140 | |||
141 | /** |
||
142 | * @param string $packageName |
||
143 | * @return $this |
||
144 | */ |
||
145 | public function setPackageName($packageName) |
||
150 | |||
151 | /** |
||
152 | * @return array |
||
153 | */ |
||
154 | public function getPayloadData() |
||
158 | |||
159 | /** |
||
160 | * @param array $payloadData |
||
161 | * @return $this |
||
162 | */ |
||
163 | public function setPayloadData($payloadData) |
||
168 | |||
169 | /** |
||
170 | * @return array |
||
171 | */ |
||
172 | public function createPayload() |
||
191 | |||
192 | /** |
||
193 | * Pack message body into a json representation |
||
194 | * |
||
195 | * @param array $payload |
||
196 | * @return string |
||
197 | */ |
||
198 | public function packPayload($payload) |
||
202 | |||
203 | /** |
||
204 | * {@inheritdoc} |
||
205 | */ |
||
206 | public function validateRecipient($token) |
||
217 | |||
218 | /** |
||
219 | * @param array $payload |
||
220 | * @return array |
||
221 | */ |
||
222 | protected function checkIfDryRun($payload) |
||
230 | } |
||
231 |