From dbfab3eae73ebb23d7c10ba9797f7091c04e6822 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 9 Oct 2023 21:53:01 +0300 Subject: sender: remove APNS tokens with 'Unregistered' error --- vnext/server/sender.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'vnext/server') diff --git a/vnext/server/sender.js b/vnext/server/sender.js index 3f2dbc3b8..7e9ec2f26 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`) -- cgit v1.2.3