From 48384c4b7e723e201ee491a0d09e8855d8484f13 Mon Sep 17 00:00:00 2001 From: Rajan Kumar Singh Date: Sat, 5 Feb 2022 23:50:20 +0530 Subject: [PATCH] 410 Unregistered contains extra timestamp value https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/handling_notification_responses_from_apns#:~:text=timestamp,field%20is%20410 --- push_notifications/apns.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/push_notifications/apns.py b/push_notifications/apns.py index 04064872..bc40f2d0 100644 --- a/push_notifications/apns.py +++ b/push_notifications/apns.py @@ -139,6 +139,11 @@ def apns_send_bulk_message( registration_ids, alert, batch=True, application_id=application_id, creds=creds, **kwargs ) - inactive_tokens = [token for token, result in results.items() if result == "Unregistered"] + + inactive_tokens = [] + for token, result in results.items(): + if isinstance(result, list) and result[0] == "Unregistered": + inactive_tokens.append(token) + # inactive_tokens = [token for token, result in results.items() if result == "Unregistered"] models.APNSDevice.objects.filter(registration_id__in=inactive_tokens).update(active=False) return results