1 | <?php |
||
9 | class APNSNotification extends AbstractNotification |
||
10 | { |
||
11 | /** |
||
12 | * @var string APNS live server. |
||
13 | */ |
||
14 | private $apnsHost = 'gateway.push.apple.com'; |
||
15 | |||
16 | /** |
||
17 | * @var string APNS sandbox server |
||
18 | */ |
||
19 | private $apnsSandboxHost = 'gateway.sandbox.push.apple.com'; |
||
20 | |||
21 | /** |
||
22 | * @var int APNS server port to connect. |
||
23 | */ |
||
24 | private $apnsPort = 2195; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $apnsCert = 'apns-production.pem'; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $apnsSandboxCert = 'apns-dev.pem'; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | private $scheme = 'https'; |
||
40 | |||
41 | /** |
||
42 | * @var bool Connect to APNS sandbox or live server. |
||
43 | */ |
||
44 | private $live = false; |
||
45 | |||
46 | /** |
||
47 | * APNSNotification constructor. |
||
48 | * |
||
49 | * @param bool $live |
||
50 | * @param string|null $apnsCert |
||
51 | * @param string|null $apnsSandboxCert |
||
52 | * |
||
53 | * @throws InvalidCert When cannot find one of certificate files. |
||
54 | */ |
||
55 | 4 | public function __construct($live = false, $apnsCert = null, $apnsSandboxCert = null) |
|
71 | |||
72 | /** |
||
73 | * @throws \Exception |
||
74 | */ |
||
75 | 2 | public function send() |
|
85 | |||
86 | 1 | private function close() |
|
90 | |||
91 | /** |
||
92 | * Writes all data to the stream |
||
93 | * |
||
94 | * @return self |
||
95 | */ |
||
96 | 1 | private function write() |
|
111 | |||
112 | /** |
||
113 | * @param MessageInterface $message |
||
114 | * |
||
115 | * @return string Тhe json encoded string |
||
116 | */ |
||
117 | 1 | final protected function createPayload(MessageInterface $message) |
|
136 | |||
137 | /** |
||
138 | * @param $message |
||
139 | * @param $payload |
||
140 | * |
||
141 | * @return string |
||
142 | */ |
||
143 | 1 | private function createBinMessage(MessageInterface $message, $payload) |
|
156 | |||
157 | /** |
||
158 | * @param $token |
||
159 | * @param $payload |
||
160 | * |
||
161 | * @return string |
||
162 | * |
||
163 | */ |
||
164 | 1 | private function buildBinMessage($token, $payload) |
|
176 | |||
177 | /** |
||
178 | * @param $deviceToken |
||
179 | * |
||
180 | * @return mixed |
||
181 | */ |
||
182 | 1 | private function prepareToken($deviceToken) |
|
186 | |||
187 | 1 | protected function getConnectionParams() |
|
199 | |||
200 | /** |
||
201 | * @return string Full qualified url address of APNS server. |
||
202 | */ |
||
203 | 1 | private function getRemoteSocketAddress() |
|
207 | } |