summaryrefslogtreecommitdiff
path: root/examples/lib/okpush/apn.js
diff options
context:
space:
mode:
Diffstat (limited to 'examples/lib/okpush/apn.js')
-rw-r--r--examples/lib/okpush/apn.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/examples/lib/okpush/apn.js b/examples/lib/okpush/apn.js
index 5e13e15..b6909f6 100644
--- a/examples/lib/okpush/apn.js
+++ b/examples/lib/okpush/apn.js
@@ -9,17 +9,21 @@ function init (config) {
apnProvider = new apn.Provider(config.apn.connection)
}
-function push (tokens, note) {
- tokens.forEach(function(token){
- connection.send(note, token).then( function (response) {
- response.sent.forEach( function (token) {
- // notificationSent(user, token)
- })
+function push (note) {
+ db.getAllDevices(function(err, tokens){
+ if (err) {
+ console.error("Error fetching devices:", err)
+ return
+ }
+ connection.send(note, tokens).then( function (response) {
+ // response.sent.forEach( function (token) {
+ // notificationSent(user, token)
+ // })
response.failed.forEach( function (failure) {
if (failure.error) {
// A transport-level error occurred (e.g. network problem)
// notificationError(user, token, failure.error);
- } else {
+ } else if (failure.status == 410) {
// `failure.status` is the HTTP status code
// `failure.response` is the JSON payload
// notificationFailed(token, failure.status, failure.response);