1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NotificationChannels\Apn\Notifications; |
4
|
|
|
|
5
|
|
|
use Illuminate\Bus\Queueable; |
6
|
|
|
use NotificationChannels\Apn\ApnChannel; |
7
|
|
|
use NotificationChannels\Apn\ApnMessage; |
8
|
|
|
use Illuminate\Notifications\Notification; |
9
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue; |
10
|
|
|
|
11
|
|
|
class ApnTestNotification extends Notification |
12
|
|
|
{ |
13
|
|
|
use Queueable; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* The body of the test notification that will |
17
|
|
|
* be sent. |
18
|
|
|
* |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
private $notificationBody; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* The title of the test notification that will |
25
|
|
|
* be sent. |
26
|
|
|
* |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
private $notificationTitle; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* The badge number that will be sent with the |
33
|
|
|
* notification. |
34
|
|
|
* |
35
|
|
|
* @var integer |
36
|
|
|
*/ |
37
|
|
|
private $badgeNumber; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* The sound that will be played when the device |
41
|
|
|
* receives the notification. |
42
|
|
|
* |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
private $sound; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* NewChatMessage constructor. |
49
|
|
|
* |
50
|
|
|
* @param string $notificationTitle |
51
|
|
|
* @param string $notificationBody |
52
|
|
|
* @param int $badgeNumber |
53
|
|
|
* @param string $sound |
54
|
|
|
*/ |
55
|
|
|
public function __construct(string $notificationTitle, string $notificationBody, int $badgeNumber, string $sound = 'default') |
56
|
|
|
{ |
57
|
|
|
$this->notificationBody = $notificationBody; |
58
|
|
|
$this->notificationTitle = $notificationTitle; |
59
|
|
|
$this->badgeNumber = $badgeNumber; |
60
|
|
|
$this->sound = $sound; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Set the notification route as 'ApnChannel'. |
65
|
|
|
* |
66
|
|
|
* @param mixed $notifiable |
67
|
|
|
* @return array |
68
|
|
|
*/ |
69
|
|
|
public function via($notifiable): array |
|
|
|
|
70
|
|
|
{ |
71
|
|
|
return [ApnChannel::class]; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Use the APN service to send a push notification |
76
|
|
|
* to any iOS devices. |
77
|
|
|
* |
78
|
|
|
* @param $notifiable |
79
|
|
|
* @return ApnMessage |
80
|
|
|
*/ |
81
|
|
|
public function toApn($notifiable): ApnMessage |
|
|
|
|
82
|
|
|
{ |
83
|
|
|
return ApnMessage::create() |
84
|
|
|
->badge($this->badgeNumber) |
85
|
|
|
->title($this->notificationTitle) |
86
|
|
|
->body($this->notificationBody) |
87
|
|
|
->sound($this->sound); |
88
|
|
|
} |
89
|
|
|
} |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.