File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,12 @@ extension Firebaseable {
153
153
return try fcm.sendMessage (container.make (Client.self ), message : message).transform (to : ())
154
154
}
155
155
}
156
+
157
+ extension Array where Element == Firebaseable {
158
+ func sendPush (title : String , message : String , on container : Container) throws -> Future<Void > {
159
+ return try map { try $0 .sendPush (title : title, message : message, on : container) }.flatten (on : container)
160
+ }
161
+ }
156
162
```
157
163
Optionally you can handle ` sendMessage ` error through defining ` catchFlatMap ` after it, e.g. for removing broken tokens or anything else
158
164
``` swift
@@ -170,7 +176,7 @@ Optionally you can handle `sendMessage` error through defining `catchFlatMap` af
170
176
}
171
177
```
172
178
173
- e.g. I'm conforming my ` Token ` model to ` Firebaseable `
179
+ Then e.g. I'm conforming my ` Token ` model to ` Firebaseable `
174
180
175
181
``` swift
176
182
final class Token : Content {
@@ -188,6 +194,6 @@ Token.query(on: req)
188
194
.join (\User.id , to : \Token.userId )
189
195
.
filter (\User.
email == " [email protected] " )
190
196
.all ().map { tokens in
191
- try tokens.map { try $0 . sendPush (title : " Test push" , message : " Hello world!" , on : req) }. flatten ( on : req)
197
+ try tokens.sendPush (title : " Test push" , message : " Hello world!" , on : req)
192
198
}
193
199
```
You can’t perform that action at this time.
0 commit comments