File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ class Larafirebase
27
27
28
28
private $ fromRaw ;
29
29
30
+ private $ iosBadgeCount ;
31
+
30
32
const API_URI = 'https://fcm.googleapis.com/fcm/send ' ;
31
33
32
34
public function withTitle ($ title )
@@ -92,6 +94,13 @@ public function fromRaw($fromRaw)
92
94
return $ this ;
93
95
}
94
96
97
+ public function withIosBadgeCount ($ iosBadgeCount )
98
+ {
99
+ $ this ->iosBadgeCount = $ iosBadgeCount ;
100
+
101
+ return $ this ;
102
+ }
103
+
95
104
public function sendNotification ($ tokens )
96
105
{
97
106
$ fields = array (
@@ -106,6 +115,15 @@ public function sendNotification($tokens)
106
115
'data ' => $ this ->additionalData ,
107
116
'priority ' => $ this ->priority
108
117
);
118
+ if (isset ($ iosBadgeCount )) {
119
+ $ fields ['apns ' ] = [
120
+ 'payload ' => [
121
+ 'aps ' => [
122
+ 'badge ' => $ iosBadgeCount
123
+ ]
124
+ ]
125
+ ];
126
+ }
109
127
return $ this ->callApi ($ fields );
110
128
}
111
129
You can’t perform that action at this time.
0 commit comments