1 | <?php |
||
15 | class ApnChannel |
||
16 | { |
||
17 | use InteractsWithConnection; |
||
18 | |||
19 | /** |
||
20 | * The sandbox environment identifier. |
||
21 | * |
||
22 | * @var int |
||
23 | */ |
||
24 | const SANDBOX = 0; |
||
25 | |||
26 | /** |
||
27 | * The production environment identifier. |
||
28 | * |
||
29 | * @var int |
||
30 | */ |
||
31 | const PRODUCTION = 1; |
||
32 | |||
33 | /** @var \ZendService\Apple\Apns\Client\Message */ |
||
34 | protected $client; |
||
35 | |||
36 | /** @var \Illuminate\Events\Dispatcher */ |
||
37 | protected $events; |
||
38 | |||
39 | /** @var \NotificationChannels\Apn\ApnCredentials */ |
||
40 | protected $credentials; |
||
41 | |||
42 | /** |
||
43 | * Create a new instance of the APN channel. |
||
44 | * |
||
45 | * @param \ZendService\Apple\Apns\Client\Message $client |
||
46 | * @param \Illuminate\Events\Dispatcher $events |
||
47 | * @param \NotificationChannels\Apn\ApnCredentials $credentials |
||
48 | */ |
||
49 | 2 | public function __construct(Client $client, Dispatcher $events, ApnCredentials $credentials) |
|
55 | |||
56 | /** |
||
57 | * Send the notification to Apple Push Notification Service. |
||
58 | * |
||
59 | * @param mixed $notifiable |
||
60 | * @param \Illuminate\Notifications\Notification $notification |
||
61 | */ |
||
62 | 2 | public function send($notifiable, Notification $notification) |
|
63 | { |
||
64 | 2 | $tokens = (array) $notifiable->routeNotificationFor('apn'); |
|
65 | 2 | if (empty($tokens)) { |
|
66 | return; |
||
67 | } |
||
68 | |||
69 | 2 | $message = $notification->toApn($notifiable); |
|
|
|||
70 | 2 | if (! $message) { |
|
71 | return; |
||
72 | } |
||
73 | |||
74 | 2 | foreach ($tokens as $token) { |
|
75 | if (! $this->openConnection()) { |
||
76 | 2 | continue; |
|
77 | 2 | } |
|
78 | 2 | $packet = $this->getPacket($message, $token); |
|
79 | $this->sendPacket($notifiable, $notification, $packet, $token); |
||
80 | $this->closeConnection(); |
||
81 | 2 | } |
|
82 | 2 | } |
|
83 | |||
84 | /** |
||
85 | * Get the packet for the given message and token. |
||
86 | * |
||
87 | * @param \NotificationChannels\Apn\ApnMessage $message |
||
88 | * @param string |
||
89 | * @return \ZendService\Apple\Apns\Message |
||
90 | */ |
||
91 | 2 | protected function getPacket($message, $token) |
|
108 | |||
109 | /** |
||
110 | * Sent the notification to the given token. |
||
111 | * |
||
112 | * @param mixed $notifiable |
||
113 | * @param \Illuminate\Notifications\Notification $notification |
||
114 | * @param \ZendService\Apple\Apns\Message $packet |
||
115 | * @param string $token |
||
116 | * @return void |
||
117 | * @throws \NotificationChannels\Apn\Exceptions\SendingFailed |
||
118 | */ |
||
119 | 2 | protected function sendPacket($notifiable, $notification, $packet, $token) |
|
136 | } |
||
137 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.