Skip to content

Commit 723305e

Browse files
committed
Added ios badge count support
1 parent f18aaca commit 723305e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Services/Larafirebase.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class Larafirebase
2727

2828
private $fromRaw;
2929

30+
private $iosBadgeCount;
31+
3032
const API_URI = 'https://fcm.googleapis.com/fcm/send';
3133

3234
public function withTitle($title)
@@ -92,6 +94,13 @@ public function fromRaw($fromRaw)
9294
return $this;
9395
}
9496

97+
public function withIosBadgeCount($iosBadgeCount)
98+
{
99+
$this->iosBadgeCount = $iosBadgeCount;
100+
101+
return $this;
102+
}
103+
95104
public function sendNotification($tokens)
96105
{
97106
$fields = array(
@@ -106,6 +115,15 @@ public function sendNotification($tokens)
106115
'data' => $this->additionalData,
107116
'priority' => $this->priority
108117
);
118+
if (isset($iosBadgeCount)) {
119+
$fields['apns'] = [
120+
'payload' => [
121+
'aps' => [
122+
'badge' => $iosBadgeCount
123+
]
124+
]
125+
];
126+
}
109127
return $this->callApi($fields);
110128
}
111129

0 commit comments

Comments
 (0)