-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support of the enhanced notification format #21
Added support of the enhanced notification format #21
Conversation
Awesome, I was considering writing this myself so I'm glad I checked the open pull requests first! |
no problem ;-)
|
identifier = pack('>I', getrandbits(32)) | ||
self.write(self._get_notification(token_hex, payload, identifier, expiry)) | ||
|
||
error_response = self.read(6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can read, Apple will not send anything back when the push message is accepted. Thus, we will block here indefinitely. Seems consistent with what I'm seeing as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. We should set the socket to non-blocking mode, or with a very short timeout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the API should be asynchronous here. I'm not confortable with either waiting for a short timeout period or setting the socket to non-blocking mode. In either case you may end up getting an exception for the wrong notification. IMHO the appropriate solution would be to have a separate thread/process read from the socket (in blocking mode, if necessary forever) and execute a callback function when an error response is read.
I think this was obsoleted by #71 and can be closed? |
The Apple Push Notification Service has an "enhanced notification format".
When this format is used, the gateway server responses with a detailed error instead of just ignoring the request.
This commit adds support for this feature, which includes raising exceptions depended on the server response.