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 | 5 | public function __construct($live = false, $apnsCert = null, $apnsSandboxCert = null) |
|
71 | |||
72 | /** |
||
73 | * Writes all data to the stream |
||
74 | * |
||
75 | * @param MessageInterface $message |
||
76 | */ |
||
77 | 2 | protected function sendImpl(MessageInterface $message) |
|
90 | |||
91 | /** |
||
92 | * @param MessageInterface $message |
||
93 | * |
||
94 | * @return string Тhe json encoded string |
||
95 | */ |
||
96 | 1 | final protected function createPayload(MessageInterface $message) |
|
115 | |||
116 | /** |
||
117 | * @param $message |
||
118 | * @param $payload |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | 1 | private function createBinMessage(MessageInterface $message, $payload) |
|
135 | |||
136 | /** |
||
137 | * @param $token |
||
138 | * @param $payload |
||
139 | * |
||
140 | * @return string |
||
141 | * |
||
142 | */ |
||
143 | 1 | private function buildBinMessage($token, $payload) |
|
155 | |||
156 | /** |
||
157 | * @param $deviceToken |
||
158 | * |
||
159 | * @return mixed |
||
160 | */ |
||
161 | 1 | private function prepareToken($deviceToken) |
|
165 | |||
166 | 2 | protected function getConnectionParams() |
|
178 | |||
179 | /** |
||
180 | * @return string Full qualified url address of APNS server. |
||
181 | */ |
||
182 | 2 | private function getRemoteSocketAddress() |
|
186 | } |