forked from avto-dev/firebase-notifications-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppleFcmPlatformSettings.php
338 lines (304 loc) · 11 KB
/
AppleFcmPlatformSettings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<?php
declare(strict_types = 1);
namespace AvtoDev\FirebaseNotificationsChannel\PlatformSettings;
use Illuminate\Contracts\Support\Arrayable;
class AppleFcmPlatformSettings implements Arrayable
{
/**
* HTTP request headers defined in Apple Push Notification Service.
* Refer to APNs request headers for supported headers, e.g. "apns-priority": "10".
*
* @var array
*/
protected $headers;
/**
* Include this key when you want the system to modify the badge of your app icon.
* If this key is not included in the dictionary, the badge is not changed. To remove the badge, set the value of
* this key to 0.
*
* @var int
*/
protected $badge;
/**
* Include this key when you want the system to play a sound. The value of this key is the name of a sound file in
* your app’s main bundle or in the Library/Sounds folder of your app’s data container. If the sound file cannot
* be found, or if you specify default for the value, the system plays the default alert sound.
*
* @var string
*/
protected $sound;
/**
* Include this key with a value of 1 to configure a background update notification. When this key is present, the
* system wakes up your app in the background and delivers the notification to its app delegate.
*
* @var int
*/
protected $content_available;
/**
* Provide this key with a string value that represents the notification’s type. This value corresponds to the
* value in the identifier property of one of your app’s registered categories.
*
* @var string
*/
protected $category;
/**
* Provide this key with a string value that represents the app-specific identifier for grouping notifications. If
* you provide a Notification Content app extension, you can use this value to group your notifications together.
*
* @var string
*/
protected $thread_id;
/**
* A short string describing the purpose of the notification. Apple Watch displays this string as part of the
* notification interface. This string is displayed only briefly and should be crafted so that it can be understood
* quickly. This key was added in iOS 8.2.
*
* @var string
*/
protected $title;
/**
* The text of the alert message.
*
* @var string
*/
protected $body;
/**
* The key to a title string in the Localizable.strings file for the current localization. The key string can be
* formatted with %@ and %n$@ specifiers to take the variables specified in the title-loc-args array.
*
* This key was added in iOS 8.2.
*
* @var string
*/
protected $title_loc_key;
/**
* Variable string values to appear in place of the format specifiers in title-loc-key.
*
* This key was added in iOS 8.2.
*
* @var string[]
*/
protected $title_loc_args;
/**
* If a string is specified, the system displays an alert that includes the Close and View buttons. The string is
* used as a key to get a localized string in the current localization to use for the right button’s title instead
* of “View”.
*
* @var string
*/
protected $action_loc_key;
/**
* A key to an alert-message string in a Localizable.strings file for the current localization (which is set by the
* user’s language preference). The key string can be formatted with %@ and %n$@ specifiers to take the variables
* specified in the loc-args array.
*
* @var string
*/
protected $loc_key;
/**
* Variable string values to appear in place of the format specifiers in loc-key.
*
* @var string[]
*/
protected $loc_args;
/**
* The filename of an image file in the app bundle, with or without the filename extension. The image is used as
* the launch image when users tap the action button or move the action slider. If this property is not specified,
* the system either uses the previous snapshot, uses the image identified by the UILaunchImageFile key in the
* app’s Info.plist file, or falls back to Default.png.
*
* @var string
*/
protected $launch_image;
/**
* Allow to modify payload on iOS 10+ devices.
*
* @see https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension
*
* @var bool
*/
protected $mutable_content;
/**
* HTTP request headers defined in Apple Push Notification Service.
* Refer to APNs request headers for supported headers, e.g. "apns-priority": "10".
*
* @param array $headers
*/
public function setHeaders(array $headers)
{
$this->headers = $headers;
}
/**
* Include this key when you want the system to modify the badge of your app icon.
* If this key is not included in the dictionary, the badge is not changed. To remove the badge, set the value of
* this key to 0.
*
* @param int $badge
*/
public function setBadge(int $badge)
{
$this->badge = $badge;
}
/**
* Include this key when you want the system to play a sound. The value of this key is the name of a sound file in
* your app’s main bundle or in the Library/Sounds folder of your app’s data container. If the sound file cannot
* be found, or if you specify default for the value, the system plays the default alert sound.
*
* @param string $sound
*/
public function setSound(string $sound)
{
$this->sound = $sound;
}
/**
* Include this key with a value of 1 to configure a background update notification. When this key is present, the
* system wakes up your app in the background and delivers the notification to its app delegate.
*
* @param int $content_available
*/
public function setContentAvailable(int $content_available)
{
$this->content_available = $content_available;
}
/**
* Provide this key with a string value that represents the notification’s type. This value corresponds to the
* value in the identifier property of one of your app’s registered categories.
*
* @param string $category
*/
public function setCategory(string $category)
{
$this->category = $category;
}
/**
* Provide this key with a string value that represents the app-specific identifier for grouping notifications. If
* you provide a Notification Content app extension, you can use this value to group your notifications together.
*
* @param string $thread_id
*/
public function setThreadId(string $thread_id)
{
$this->thread_id = $thread_id;
}
/**
* A short string describing the purpose of the notification. Apple Watch displays this string as part of the
* notification interface. This string is displayed only briefly and should be crafted so that it can be understood
* quickly. This key was added in iOS 8.2.
*
* @param string $title
*/
public function setTitle(string $title)
{
$this->title = $title;
}
/**
* The text of the alert message.
*
* @param string $body
*/
public function setBody(string $body)
{
$this->body = $body;
}
/**
* The key to a title string in the Localizable.strings file for the current localization. The key string can be
* formatted with %@ and %n$@ specifiers to take the variables specified in the title-loc-args array.
*
* This key was added in iOS 8.2.
*
* @param string $title_loc_key
*/
public function setTitleLocKey(string $title_loc_key)
{
$this->title_loc_key = $title_loc_key;
}
/**
* Variable string values to appear in place of the format specifiers in title-loc-key.
*
* This key was added in iOS 8.2.
*
* @param string[] $title_loc_args
*/
public function setTitleLocArgs(array $title_loc_args)
{
$this->title_loc_args = $title_loc_args;
}
/**
* If a string is specified, the system displays an alert that includes the Close and View buttons. The string is
* used as a key to get a localized string in the current localization to use for the right button’s title instead
* of “View”.
*
* @param string $action_loc_key
*/
public function setActionLocKey(string $action_loc_key)
{
$this->action_loc_key = $action_loc_key;
}
/**
* A key to an alert-message string in a Localizable.strings file for the current localization (which is set by the
* user’s language preference). The key string can be formatted with %@ and %n$@ specifiers to take the variables
* specified in the loc-args array.
*
* @param string $loc_key
*/
public function setLocKey(string $loc_key)
{
$this->loc_key = $loc_key;
}
/**
* Variable string values to appear in place of the format specifiers in loc-key.
*
* @param string[] $loc_args
*/
public function setLocArgs(array $loc_args)
{
$this->loc_args = $loc_args;
}
/**
* The filename of an image file in the app bundle, with or without the filename extension. The image is used as
* the launch image when users tap the action button or move the action slider. If this property is not specified,
* the system either uses the previous snapshot, uses the image identified by the UILaunchImageFile key in the
* app’s Info.plist file, or falls back to Default.png.
*
* @param string $launch_image
*/
public function setLaunchImage(string $launch_image)
{
$this->launch_image = $launch_image;
}
public function setMutableContent(bool $mutable_content)
{
$this->mutable_content = $mutable_content;
}
/**
* Build an array.
*
* @return array
*/
public function toArray(): array
{
return [
'headers' => $this->headers,
'payload' => [
'aps' => [
'alert' => [
'title' => $this->title,
'body' => $this->body,
'title-loc-key' => $this->title_loc_key,
'title-loc-args' => $this->title_loc_args,
'action-loc-key' => $this->action_loc_key,
'loc-key' => $this->loc_key,
'loc-args' => $this->loc_args,
'launch-image' => $this->launch_image,
],
'badge' => $this->badge,
'sound' => $this->sound,
'content-available' => $this->content_available,
'category' => $this->category,
'thread-id' => $this->thread_id,
'mutable-content' => (int) $this->mutable_content,
],
],
];
}
}