From d908e9cc37fdbcda1644f193027766a4bccaa70f Mon Sep 17 00:00:00 2001 From: JJTech0130 Date: Thu, 17 Aug 2023 22:40:02 -0400 Subject: [PATCH] give up on proper ACKing --- apns.py | 8 +++++++- demo.py | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apns.py b/apns.py index e3883fb..cdafc1a 100644 --- a/apns.py +++ b/apns.py @@ -126,6 +126,12 @@ class APNSConnection: self._incoming_queue.append(payload) + # TODO: Hack: Send an ACK if this is a notification + # We do this because as of now pypush does not handle all incoming notifications + # and if you do not ACK a notification, APNs will keep resending it and eventually kill the connection + if payload.id == 0xA: + await self._send_ack(payload.fields_with_id(4)[0].value) + # Signal to any waiting tasks that we have a new payload self._queue_park.set() self._queue_park = trio.Event() # Reset the event @@ -292,7 +298,7 @@ class APNSConnection: return True r = await self._receive(0xA, f) - await self._send_ack(r.fields_with_id(4)[0].value) + #await self._send_ack(r.fields_with_id(4)[0].value) return r async def set_state(self, state: int): diff --git a/demo.py b/demo.py index cf42096..571a724 100644 --- a/demo.py +++ b/demo.py @@ -139,6 +139,7 @@ async def main(): # Send a message to myself await im.send(imessage.iMessage.create(im, "Hello, world!", [user.current_handle])) + print(await im.receive()) if __name__ == "__main__": import trio