From baf922af6162183d90112df5293f41089c942ded Mon Sep 17 00:00:00 2001 From: JJTech0130 Date: Tue, 25 Jul 2023 19:07:29 -0400 Subject: [PATCH] send ACKs so it shows as Delivered --- apns.py | 8 ++++---- demo.py | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apns.py b/apns.py index b399997..f4acf60 100644 --- a/apns.py +++ b/apns.py @@ -238,10 +238,10 @@ class APNSConnection: logger.debug("Sending keep alive message") self.sock.write(_serialize_payload(0x0C, [])) - # def _send_ack(self, id: bytes): - # print(f"Sending ACK for message {id}") - # payload = _serialize_payload(0x0B, [(1, self.token), (4, id), (8, b"\x00")]) - # self.sock.write(payload) + def _send_ack(self, id: bytes): + logger.debug(f"Sending ACK for message {id}") + payload = _serialize_payload(0x0B, [(1, self.token), (4, id), (8, b"\x00")]) + self.sock.write(payload) # #self.sock.write(_serialize_payload(0x0B, [(4, id)]) # #pass diff --git a/demo.py b/demo.py index ecbf64b..7f47ad4 100644 --- a/demo.py +++ b/demo.py @@ -233,6 +233,8 @@ while True: return True payload = conn.incoming_queue.wait_pop_find(check_response) resp_body = apns._get_field(payload[1], 3) + id = apns._get_field(payload[1], 4) + conn._send_ack(id) resp_body = plistlib.loads(resp_body) #logging.info(f"Got response: {resp_body}") payload = resp_body["P"]