Add way to mass send push notifications
matthijs2704 opened this issue · 4 comments
Add a way to send push notifications to an array of device tokens.
Hi! As I need this feature for my own server, I've been thinking about a way to do it and I came up with this idea :
Making ApplePushMessage
device-independent (i.g. removing the deviceToken
property) would enable the renaming of this method to send the notification to one device :
VaporAPNS.send(applePushMessage:deviceToken:) -> Result
This renamed method would make the implementation of the batch-send feature pretty easy :
VaporAPNS.send(applePushMessage:deviceTokens:perDeviceCompletionHandler:)
deviceTokens
is an array of device tokens.
perDeviceCompletionHandler
is a closure ((ApplePushMessage,String,Result)->Void
) that is called once for every device with the send result for that device.
The method calls send(applePushMessage:deviceToken:)
for every token in the array and then calls the closure with the message, token and result.
This design has been inspired by CloudKit's operations completion handlers (ex: CKFetchRecordsOperation)
Of course this would be a source-breaking change
I have a draft implementation in my fork's batch-send branch.
Tell me what you think about it!
@alexaubry Thanks! I was already working on something similar indeed :P
This was added in VaporAPNS 1.1.0
Cool! Can't wait to try it
It is still all sync, so If you want to do it async, just use libdispatch or something similar :)