djacobs / PyAPNs

Python library for interacting with the Apple Push Notification service (APNs)
http://pypi.python.org/pypi/apns/
MIT License
1.22k stars 374 forks source link

Error handling and frames #46

Closed Mina-H-Samy closed 10 years ago

Mina-H-Samy commented 10 years ago

1) I would like to be able to remove unregistered tokens from my database. How do I get the 6 bytes error-response packet that contains the status code when sending using a frame?

2) If sending a large number of notifications in a frame, and there's an unregistered notification somewhere in the middle (for example, someone uninstalled the app), will all the remaining notifications be delivered?

Mina-H-Samy commented 10 years ago

It seems I was getting confused because apns works very differently to gcm. Here is what I found for anyone else (please correct me if I'm wrong):

1) Simply listen to the feedback server. Any token in the feedback server needs to be removed from the database. The error-response packet should not be encountered under normal circumstances, it is only to let you know that the notification payload, text, etc... are malformed.

2) Yes they will be. Connection is only closed when a notification request is malformed. Make sure to listen to the feedback server after sending the frame and make sure you delete all unregistered tokens.