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

AttributeError: 'GatewayConnection' object has no attribute '_sent_notifications' #108

Closed
CTassisF opened this issue Jan 15, 2015 · 11 comments · May be fixed by #109
Closed

AttributeError: 'GatewayConnection' object has no attribute '_sent_notifications' #108

CTassisF opened this issue Jan 15, 2015 · 11 comments · May be fixed by #109

Comments

@CTassisF
Copy link

PyAPNs v2.0.1:

AttributeError: 'GatewayConnection' object has no attribute '_sent_notifications'

@jimhorng
Copy link
Collaborator

@CTassisF May I know what's the reproducing step of this issue?

@CTassisF
Copy link
Author

This is how I am sending Push Notifications:

import pyapns # I renamed apns.py to pyapns.py

connection = pyapns.APNs(use_sandbox = True, cert_file = StringIO.StringIO(sandbox_cert), key_file = StringIO.StringIO(key))
alert = (self.request.get('alert') if self.request.get('alert') else None)
sound = (self.request.get('sound') if self.request.get('sound') else None)
badge = (long(self.request.get('badge')) if self.request.get('badge') else None)
custom = {'foobar': (long(self.request.get('foobar')) if self.request.get('foobar') else None)}
content_available = (True if sound else False)

payload = pyapns.Payload(alert = alert, sound = sound, badge = badge, custom = custom, content_available = content_available)
frame = pyapns.Frame()
identifier = (long(self.request.get('line')) if self.request.get('line') else 0)
expiry = time.time() + 3600
priority = 10
apnslist = json.loads(self.request.get('json')) # apnslist is an array of APNs tokens
for apns in apnslist:
    frame.add_item(apns, payload, identifier, expiry, priority)
connection.gateway_server.send_notification_multiple(frame)

@jimhorng
Copy link
Collaborator

If you want to use enhance mode, please refer to document and specify enhanced=True,

apns_enhanced = APNs(use_sandbox=True, cert_file='apns.pem', enhanced=True)

however, for non-enhance mode, it should not use re-send mechanism that cause this error, please @xilvar to check it.

@xilvar
Copy link
Contributor

xilvar commented Jan 15, 2015

Hm. Strange. I'll take a look at it later tonight. @CTassisF

Sent from my iPhone

On Jan 14, 2015, at 6:56 PM, Jim Horng notifications@github.com wrote:

If you want to use enhance mode, please refer to document and specify enhanced=True,

apns_enhanced = APNs(use_sandbox=True, cert_file='apns.pem', enhanced=True)
however, for non-enhance mode, it should not use re-send mechanism that cause this error, please @xilvar to check it.


Reply to this email directly or view it on GitHub.

@geeknam
Copy link

geeknam commented Apr 10, 2015

Please update README if enhaced=True is needed for send_notification_multiple. It wasn't required prior 2.0.1.

@jimhorng
Copy link
Collaborator

It shouldn't be required, should be a bug
2015/4/10 上午9:28於 "Nam Ngo" notifications@github.com寫道:

Please updater README if enhaced=True is needed for
send_notification_multiple. It wasn't required prior 2.0.1.


Reply to this email directly or view it on GitHub
#108 (comment).

@stannie
Copy link

stannie commented May 1, 2015

Ran into this one too.

@borisbsv
Copy link

Ran into this one too, running the sample usage script. Adding enchanced=True to the APNs() fixed it, like so:
apns = APNs(use_sandbox=True, cert_file='my_cert.pem', key_file='my_key.pem', enhanced=True)

Is this expected behaviour?

@xilvar
Copy link
Contributor

xilvar commented Jun 30, 2016

Hm. Is it still doing that? I thought someone else's PR had fixed that bug
quite a while back. That being said you probably want to use enhanced apns
anyway since old(er) apns is simply worse... I'll take a look at the
codebase and see if it ended up with the bug again when I have a chance.

On Tue, Jun 28, 2016 at 2:03 AM, Boris Stoyanov notifications@github.com
wrote:

Ran into this one too, running the sample usage script. Adding
enchanced=True to the APNs() fixed it, like so:
apns = APNs(use_sandbox=True, cert_file='my_cert.pem',
key_file='my_key.pem', enhanced=True)

Is this expected behaviour?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#108 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AARJIW9nz1ucb-2y1DKytb2nltk7mBMDks5qQONTgaJpZM4DSnxh
.

@legel
Copy link

legel commented Jul 5, 2016

Still doing that.

Adding enhanced=True to the APNs() still fixes it.

@djacobs djacobs closed this as completed Aug 12, 2016
@sashabaranov
Copy link

Adding enhanced=True results in duplicate notifications, still have this bug withou enhanced

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 a pull request may close this issue.

9 participants