diff options
author | Vitaly Takmazov | 2023-10-09 21:53:01 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-10-10 18:50:47 +0300 |
commit | dbfab3eae73ebb23d7c10ba9797f7091c04e6822 (patch) | |
tree | 86fe8bd7292272e817359d85c7603340cc739c00 /vnext/server | |
parent | 21be35dfd270798ca901bc33f5c85ccabb942052 (diff) |
sender: remove APNS tokens with 'Unregistered' error
Diffstat (limited to 'vnext/server')
-rw-r--r-- | vnext/server/sender.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/vnext/server/sender.js b/vnext/server/sender.js index 3f2dbc3b..7e9ec2f2 100644 --- a/vnext/server/sender.js +++ b/vnext/server/sender.js @@ -60,9 +60,10 @@ export function sendNotification(productionIds, sandboxIds, data) { results.filter(r => r.method === 'apn') .forEach(async r => { log(`Response message: ${JSON.stringify(r.message)}`) - let badTokens = r.message.filter(m => m.errorMsg === 'BadDeviceToken').map(m => { - return { 'type': 'apns', 'token': m.regId } - }) + let badTokens = r.message.filter(m => + m.errorMsg === 'BadDeviceToken' || m.errorMsg === 'Unregistered').map(m => { + return { 'type': 'apns', 'token': m.regId } + }) if (badTokens.length > 0) { await deleteSubscribers(badTokens) log(`${badTokens.length} APNS tokens deleted`) @@ -70,9 +71,11 @@ export function sendNotification(productionIds, sandboxIds, data) { }) results.filter(r => r.method === 'gcm') .forEach(async r => { - let badTokens = r.message.filter(m => m.errorMsg === 'NotRegistered' || m.errorMsg === 'MismatchSenderId' || m.errorMsg === 'InvalidRegistration').map(m => { - return { 'type': 'fcm', 'token': m.regId } - }) + let badTokens = r.message.filter(m => + m.errorMsg === 'NotRegistered' || m.errorMsg === 'MismatchSenderId' + || m.errorMsg === 'InvalidRegistration').map(m => { + return { 'type': 'fcm', 'token': m.regId } + }) if (badTokens.length > 0) { await deleteSubscribers(badTokens) log(`${badTokens.length} GCM tokens deleted`) |