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

send_notification_multiple stopped working suddenly #181

Open
contacitltd opened this issue Nov 26, 2016 · 9 comments
Open

send_notification_multiple stopped working suddenly #181

contacitltd opened this issue Nov 26, 2016 · 9 comments

Comments

@contacitltd
Copy link

I have been using the send_notification_multiple function for quite some time, but it has stopped working yesterday.. When I add more than one notification to the frame, the messagses are not delivered to the devices (when there is only one notification in the frame, it does work).
As I used this for a long time before it recently stopped working, i can only suspect Apple has changed something in the API?

For reference, here is my code:

identifier = 3
expiry = time.time()+(3600*24*7)
priority = 10
payload = Payload(alert="test message", sound="default", badge=1, custom={"update":"news"})
frame = Frame()
for reg_id in reg_ids:
   frame.add_item(reg_id, payload, identifier, expiry, priority)
self.apns.gateway_server.send_notification_multiple(frame)

Has anyone experienced a similar issue?

@sanderfoobar
Copy link

sanderfoobar commented Dec 6, 2016

Does not work for me too. I can give more info if required, for now @contacitltd example should be enough.

In the mean time, I take it Apple will not like it if you send 30k push notifications with the send_notification() method?

@djeer
Copy link

djeer commented Feb 3, 2017

I seem to have the same problem.
Here's my code:

...
frame_cl = Frame()
...
for *something*
    frame_cl.add_item(token, payload, identifier, expiry, priority)
...
apns_cl = APNs(use_sandbox=False, cert_file='*dir*/****.pem')
apns_cl.gateway_server.send_notification_multiple(frame_cl)		
...

I have this error:

  File "/*myproject*/send.py", line 218, in send_notice
    apns_cl.gateway_server.send_notification_multiple(frame_cl)
  File "build/bdist.linux-x86_64/egg/apns.py", line 559, in send_notification_multiple
    self._sent_notifications += frame.get_notifications(self)
AttributeError: 'GatewayConnection' object has no attribute '_sent_notifications'

@djeer
Copy link

djeer commented Feb 5, 2017

It's fixed in this fork https://github.com/mnemonicflow/PyAPNs here https://github.com/mnemonicflow/PyAPNs/commit/f07515ec610475a715f6fd3e35595f875b13586d
This projest seems to be abadoned

@connectarena
Copy link

same issue here.. and above fork by @diman94 is not reachable (broken link). any one knows the actual link?

@djeer
Copy link

djeer commented May 18, 2017

I almost shure I have it on my computer. I will upload it tomorrow if I don't forget. You may look through recent forks of this project (as I did), maybe you'll find something useful.

@djeer
Copy link

djeer commented May 19, 2017

Try this one https://github.com/diman94/PyAPNs/
As I remember
self._sent_notifications += frame.get_notifications(self)
replaced with
if self.enhanced: self._sent_notifications += frame.get_notifications(self)

@markleetw
Copy link

markleetw commented May 24, 2017

@contacitltd @skftn @connectarena
Excuse me. Would you mind to tell me if you're using enhanced mode or not?

I'm using very old version of PyAPNs and legacy notification (not enhanced notification), but recently I often got stuck when sending multiple notifications. It really bothers me, so I'm trying to upgrade the lib and replace with the enhanced mode. Till now, I haven't met the same issue in sandbox testing yet, but according to my experience, it's not easy to reproduce, so I need more details about your questions to infer if the stuck problem still remains, if so, maybe I should think a plan B.

@MrCsabaToth
Copy link

I thought it worked at some point in the past, but my problem is only involving banner type notifications when the application is not in the foreground.

@monstermac77
Copy link

Given what @djeer said about what fix was made in that fork, and that self._sent_notifications = collections.deque(maxlen=SENT_BUFFER_QTY) has now been moved out of the if enhanced block of the init for APNs in the source repo, I think this was a bug that probably doesn't exist anymore and this issue should be closed.

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

No branches or pull requests

6 participants