Skip to content
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

Conversation

adamrimon
Copy link

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.

@chrisballinger
Copy link

Awesome, I was considering writing this myself so I'm glad I checked the open pull requests first!

@adamrimon
Copy link
Author

no problem ;-)
On Oct 2, 2012 1:57 AM, "Chris Ballinger" notifications@github.com wrote:

Awesome, I was considering writing this myself so I'm glad I checked the
open pull requests first!


Reply to this email directly or view it on GitHubhttps://github.com/simonwhitaker/PyAPNs/pull/21#issuecomment-9054557.

identifier = pack('>I', getrandbits(32))
self.write(self._get_notification(token_hex, payload, identifier, expiry))

error_response = self.read(6)

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.

Copy link
Author

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.

Copy link

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.

@ExplodingCabbage
Copy link
Collaborator

I think this was obsoleted by #71 and can be closed?

@djacobs djacobs closed this Feb 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants