You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'body' => '$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.',
81
-
'icon' => 'stock_ticker_update',
82
-
'color' => '#f45342',
82
+
'icon' => 'ic_stock_ticker',
83
+
'color' => '#f45342'
83
84
],
84
85
]);
85
-
86
86
```
87
87
88
+
*Notification keys and value options*:
89
+
`tag`: Identifier used to replace existing notifications in the notification drawer. If not specified, each request creates a new notification. If specified and a notification with the same tag is already being shown, the new notification replaces the existing one in the notification drawer.
90
+
91
+
`color`: The notification's icon color, expressed in #rrggbb format.
92
+
93
+
`icon`: Unless specified, let the Android app deal with this. Kind of similar to sound, but with notification icons instead.
94
+
95
+
88
96
PHP: iOS Specifc message
89
97
```php
90
98
$config = ApnsConfig::fromArray([
@@ -128,28 +136,28 @@ We always register userId as a topic `user_[ID]`eg `user_1`
128
136
129
137
Topics can be used very smart, and should avoid every situation of having to store push settings in the DB.
130
138
131
-
Example 1)
139
+
## Example 1)
132
140
133
141
Feature: Push on breaking news which is optional for users (is a setting)
134
142
135
-
The app will register to a tag "breakingNews" if the push setting is on.
143
+
The app will register to a tag `breakingNews` if the push setting is on.
136
144
It's important to code this as a way where local storage is master
137
145
138
-
The backend will now just push to the tag "breakingNews"
146
+
The backend will now just push to the tag `breakingNews`
139
147
140
-
Example 2)
148
+
## Example 2)
141
149
142
150
Feature: Recieving push notifications about athlete with id: 12345, after favoriting him/her
143
151
144
-
The app will register to tag "athelete_12345"
152
+
The app will register to tag `athelete_12345`
145
153
146
-
The backend will now just push to the tag "athlete\_[ID]" instead of looping users which have favorited it (maybe the state is even local)
154
+
The backend will now just push to the tag `athlete\_[ID]` instead of looping users which have favorited it (maybe the state is even local)
147
155
148
-
Example 3)
156
+
## Example 3)
149
157
150
158
The app have options to only receive news push notification during race or always
151
159
152
-
The app will register to tag "newsAlways" or "newsDuringRace" or both
160
+
The app will register to tag `newsAlways` or `newsDuringRace` or both
153
161
154
162
Backend will push to those tags, but will figure out if the the current time is durring race and add that tag also.
'body' => '$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.',
212
+
'sound' => 'default'
213
+
],
214
+
]);
215
+
```
198
216
199
-
2) No sound
217
+
###No sound
200
218
201
-
Android: Yet to figure out how this works in FCM, Please do PR
219
+
Android: The documentation is pretty lackluster on this. For Android 8.0+ notification channel's will probably override this anyway.
202
220
iOS: empty string. ""
203
221
204
222
PHP iOS No sound
@@ -213,19 +231,19 @@ PHP iOS No sound
213
231
]));
214
232
```
215
233
216
-
3) Custom sound
234
+
###Custom sound
217
235
218
236
Here we have to set sound for ios & android specificly
219
237
220
-
The normal approach in Android is to link to the file name in /res/raw/
238
+
`sound`: The sound to play when the device receives the notification. Supports "default" or the filename of a sound resource bundled in the app i.e. `stocksound.mp3`. Android: Sound files must reside in /res/raw/.
This is starting to be a very important matter, notification without high prio. Can easily take minutes to be send
249
267
250
-
PHP: Android high priority
268
+
*PHP: Android high priority*
269
+
270
+
`priority`: Message priority. Can take "normal" and "high" values.
271
+
272
+
*Normal priority messages* are delivered immediately when the app is in the foreground. When the device is in Doze or the app is in app standby, delivery may be delayed to conserve battery. For less time-sensitive messages, such as notifications of new email, keeping your UI in sync, or syncing app data in the background, choose normal delivery priority.
273
+
274
+
FCM attempts to deliver *high priority messages* immediately, allowing the FCM service to wake a sleeping device when necessary and to run some limited processing (including very limited network access). High priority messages generally should result in user interaction with your app. If FCM detects a pattern in which they don't, your messages may be de-prioritized.
251
275
252
276
```php
253
277
->withAndroidConfig(AndroidConfig::fromArray([
@@ -258,7 +282,7 @@ PHP: Android high priority
258
282
]))
259
283
```
260
284
261
-
PHP: iOS high priority
285
+
*PHP: iOS high priority*
262
286
263
287
```php
264
288
->withApnsConfig(ApnsConfig::fromArray([
@@ -281,7 +305,7 @@ No priority 10 is highest, but does not work together with content-available
281
305
Sometimes we use push to notifity the phone about a update, but we do not want it to show in the notification center.
282
306
eg booking was updated, with updates in payload or please pull newest booking
283
307
284
-
PHP iOS example
308
+
### PHP iOS example
285
309
```php
286
310
$apns = [
287
311
'payload' => [
@@ -303,16 +327,18 @@ PHP iOS example
303
327
304
328
->withApnsConfig($apns);
305
329
```
330
+
The reason of this code, is that "alert" & "sound" is not allowed when sending silent pushes. It should not even be in object, else it will be ignored as silent
331
+
Same goes for priorty, 5 is highest for silent
306
332
307
-
PHP Android example, there is no real featuer for this. But android can read payload and decide not to build notification
333
+
334
+
### PHP Android example
335
+
To send silent push notifications send a payload with only `data` object set. The Android app will then receive data payload in `onMessageReceived`.
308
336
```php
309
337
$message = $message->withData([
310
-
'silent' => 'true',
338
+
'someKey' => 'someValue',
311
339
]);
312
340
```
313
341
314
-
The reason of this code, is that "alert" & "sound" is not allowed when sending silent pushes. It should not even be in object, else it will be ignored as silent
0 commit comments