Giter Club home page Giter Club logo

apns-python-wrapper's People

Contributors

mklymyshyn avatar

Watchers

 avatar  avatar

apns-python-wrapper's Issues

No support for keeping connection to apns open

The connection to the apns should be kept open between .notify()s. Instead it 
is closed and reopened each time you want to send a new message.

Apple says in its documentation that repeated opening and closing of 
connections may lead to banning. Instead you should keep the connection open 
until apple closes it when an error occurs.

Without this feature, it does not make it plausible to use the wrapper in 
production. I really would love to though, it is a great tool so far.

Original issue reported on code.google.com by [email protected] on 8 Jul 2010 at 1:42

crash when enabling both force_ssl_command and debug_ssl

What steps will reproduce the problem?
1.construct an APNSNotificationWrapper and enable both force_ssl_command and 
debug_ssl options
2.set up something else for notification
3.run the code, and then crash at connection.py:95

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.

the 'command' variable is not exist, should use 'self.command' instead

Original issue reported on code.google.com by [email protected] on 11 Apr 2013 at 3:57

[pull request] Add support for expiry (and enhanced notification format)

The enhanced notification format is described here: 
http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Concept
ual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html#//apple
_ref/doc/uid/TP40008194-CH101-SW1

Implemented in "plabedan-apns-python-wrapper" clone repo (rev 39d5e5a1f04d).

Original issue reported on code.google.com by [email protected] on 14 Dec 2011 at 7:52

socket.error: [Errno 54] Connection reset by peer

when input  
$python apnstest.py

Traceback (most recent call last):
  File "apnstest.py", line 18, in <module>
    wrapper.notify()
  File "build/bdist.macosx-10.6-universal/egg/APNSWrapper/notifications.py", line 195, in notify
  File "build/bdist.macosx-10.6-universal/egg/APNSWrapper/connection.py", line 215, in connect
  File "build/bdist.macosx-10.6-universal/egg/APNSWrapper/connection.py", line 161, in connect
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ssl.py", line 309, in connect
    self.do_handshake()
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ssl.py", line 293, in do_handshake
    self._sslobj.do_handshake()
socket.error: [Errno 54] Connection reset by peer



My python file apnstest.py info:
deviceToken = '.........................................'
from APNSWrapper import APNSNotificationWrapper,APNSNotification

# create wrapper
wrapper = APNSNotificationWrapper('/Users/hanmj/Desktop/cert.pem', True)

# create message
message = APNSNotification()
message.token(deviceToken)
message.badge(5)
#message.alert("dddd")

# add message to tuple and send it to APNS server
wrapper.append(message)
print("send")
wrapper.notify()


thank you!

[email protected]

Original issue reported on code.google.com by [email protected] on 23 Mar 2011 at 8:32

ImportError: No module named 'utils'

What steps will reproduce the problem?
1.ImportError: No module named 'utils'
2.I had install APNSWrapper use easyinstall3.4
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.

Original issue reported on code.google.com by mikejinhua on 15 Sep 2014 at 2:48

Changes to get APNS working on Fedora

I had to make some changes to get APNSWrapper working:

Change apnsPackFormat (force network byte order and use unsigned values) to get 
the notifications 
working on Fedora.  

Some alert messages were not properly quoted.

Added a tokenHex option for when tokens are passed as hex strings.

Original issue reported on code.google.com by [email protected] on 24 Aug 2009 at 7:33

Attachments:

can not add passphrase in the code if i use this library

I am unable to add my passphrase while establishing apns connection 
1. I can pass it on command line
2. I can remove the need of passphrase from the key.pm using openssl -rsa
3. But i want to add the passphrase in my code inline .. not remove it , not 
pass it on command line but i want a place in the library where i can specify 
the passphrase. 

has anybody been able to do it ?
if so please ping me .. 

http://stackoverflow.com/questions/25044924/python-library-to-connect-to-apns-do
-not-have-a-place-to-add-passphrase-apnswrap

Original issue reported on code.google.com by [email protected] on 31 Jul 2014 at 3:02

I can't send dict format payload

APNSProperty data not support dict, I want send message using this format:

    $body = array(
        "aps" => array("alert" => $title, "badge" => 1),
        "newspush" => array("site" => 'cnbeta', "siteid" => $siteid),
        );
help me How Can I do this?

Original issue reported on code.google.com by [email protected] on 15 Mar 2013 at 4:58

wrapper.notify() Exception: argument for 's' must be a string

What steps will reproduce the problem?
1. run the code below in eclipse with pydev
2. code:
this code is being called from within a djangorestframework-0.2.3
snippet of view:

class SendTestNotificationRESTView( View ):
    """
    Send Test Notification
    """
    allowed_methods = ( 'GET', )

    renderers = ( JSONRenderer, DocumentingHTMLRenderer, )

    parsers = ( JSONParser, PlainTextParser )

    def get( self, request ):
        """
        GET request.
        """
        try:
            SendPushNotification( u'%s' % self.PARAMS['token'], alert=u'test', badge=99, sound=True )
        except Exception, args:

            logger.error( "Exception: %s" % args )

function:
def SendPushNotification( token, alert=None, badge=None, sound=None ):

    logger.debug( "Sending PUSH Notification to [%s]..." % token )
    print settings.APNS_CERT
    # create wrapper
    wrapper = APNSNotificationWrapper( settings.APNS_CERT, sandbox=True)

    # create message
    message = APNSNotification()
    message.token( token )

    if badge:
        logger.debug( "\tBadge: [%s]" % badge )
        message.badge( badge )

    if alert:
        logger.debug( "\tAlert: [%s]" % alert )
        message.alert( "%s" % alert )

    if sound:
        logger.debug( "\tSound" )
        message.sound()

    logger.debug( "\tAdding message..." )
    # add message to tuple and send it to APNS server
    wrapper.append( message )
    logger.debug( "\tSending..." )
    wrapper.notify()
    logger.debug( "\tSent!" )

3. ERROR output:
DEBUG send_push_notification Sending PUSH Notification to 
[2ed202ac08ea9033665d853a3dc8bc4c5e78f7c6cf8d55910df290567037dcc4]...
/home/idbill/workspace/Client/settings_overrides/Client_DEV.pem
DEBUG send_push_notification    Badge: [99]
DEBUG send_push_notification    Alert: [test]
DEBUG send_push_notification    Sound
DEBUG send_push_notification    Adding message...
DEBUG send_push_notification    Sending...
ERROR send_test_notification_rest_view Exception: argument for 's' must be a 
string

What is the expected output? 

$ python manage.py send_push_notifications
DEBUG send_push_notification Sending PUSH Notification to 
[97418bddebb2720d88f448cf0887a57267108ff84baa5d9eb9855afee6134a7a]...
/home/idbill/workspace/Client/settings_overrides/Client_DEV.pem
DEBUG send_push_notification    Badge: [99]
DEBUG send_push_notification    Alert: [test]
DEBUG send_push_notification    Sound
DEBUG send_push_notification    Adding message...
DEBUG send_push_notification    Sending...
DEBUG send_push_notification    Sent!
$

What do you see instead?

If I run from the interpreter, it works... 
if run as a management command, it works...
running from a restful view via web browser... fails


What version of the product are you using? On what operating system?
python 2.6
centos 6.2
django 1.3
Eclipse Indigo sr1 (w/ subversive 2.2.2/JavaHL 1.6 and pyDev 2.2.4 and 
Javascript for Developers)

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 25 Jan 2012 at 10:12

unicode problem

why are you always checking for str e.g. in an alert?
the alert of an APNSNotification does not accept unicode as you check for str 
or APNSAlert

(like everywhere else in the code)

did I miss something in the specs?


Original issue reported on code.google.com by [email protected] on 18 Apr 2010 at 12:00

easy_install fails on Python 2.6.2

What steps will reproduce the problem?
1. Run easy_install APNSWrapper with Python 2.6.2

What is the expected output? What do you see instead?

The easy_install package should detect whether the native Python ssl module is 
present.

[root@domU-12-31-39-00-66-32 ~]# easy_install APNSWrapper
Searching for APNSWrapper
Reading http://pypi.python.org/simple/APNSWrapper/
Reading http://code.google.com/p/apns-python-wrapper/
Best match: APNSWrapper 0.3
Downloading http://apns-python-wrapper.googlecode.com/files/APNSWrapper-0.3.zip
Processing APNSWrapper-0.3.zip
Running setup.py -q bdist_egg --dist-dir 
/tmp/easy_install-uo1Vbr/egg-dist-tmp-bJCqJu
zip_safe flag not set; analyzing archive contents...
Adding APNSWrapper 0.3 to easy-install.pth file

Installed /usr/local/lib/python2.6/site-packages/APNSWrapper-0.3-py2.6.egg
Processing dependencies for APNSWrapper
Searching for ssl
Reading http://pypi.python.org/simple/ssl/
Reading http://docs.python.org/dev/library/ssl.html
Best match: ssl 1.15
Downloading 
http://pypi.python.org/packages/source/s/ssl/ssl-1.15.tar.gz#md5=81ea8a1175e437b
4c769ae65b3290e0c
Processing ssl-1.15.tar.gz
Running ssl-1.15/setup.py -q bdist_egg --dist-dir 
/tmp/easy_install-oRdN75/ssl-1.15/egg-dist-tmp-ReIHb7
Traceback (most recent call last):
  File "/usr/local/bin/easy_install", line 8, in <module>
    load_entry_point('setuptools==0.6c9', 'console_scripts', 'easy_install')()
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 1671, in main
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 1659, in with_ei_usage
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 1675, in <lambda>
  File "/usr/local/lib/python2.6/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/local/lib/python2.6/distutils/dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "/usr/local/lib/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 211, in run
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 446, in easy_install
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 478, in install_item
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 519, in process_distribution
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/pkg_resources.py", line 522, in resolve
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/pkg_resources.py", line 758, in best_match
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/pkg_resources.py", line 770, in obtain
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 446, in easy_install
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 476, in install_item
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 655, in install_eggs
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 930, in build_and_install
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 919, in run_setup
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/sandbox.py", line 27, in run_setup
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/sandbox.py", line 63, in run
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/sandbox.py", line 29, in <lambda>
  File "setup.py", line 11, in <module>
ValueError: This extension should not be used with Python 2.6 or later (already 
built in), and has not been tested with Python 2.3.4 or earlier.


What version of the product are you using? On what operating system?
Python 2.6.2 on Fedora Core 8

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 19 Aug 2009 at 9:15

APNSNotification always contains "aps" keys - it should be added only if is not empty


When building an APNSNotification, an "aps" key is always appended

--> keys.append('"aps":{%s}' % ",".join(apsKeys))

Even if the apsKeys dict is empty.


This is an error, the dict should be checked and only if is not empty it should 
be added.

The reason is that some services in the Iphone expect an empty notification 
with properties only and the 'aps' key causes an error.


APNSWrapper version - 0.6.1

Original issue reported on code.google.com by [email protected] on 2 Jun 2011 at 6:19

Cannot install if ssl module is not installed

APNSWrapper 0.4:
If you don't have the ssl module, then you can't install APNSWrapper, despite 
it should work 
without ssl module by forcing invocation of openssl executable.

Correction: in file connection.py, remove initial "import ssl" at line 9, 
because import is done 
conditionally later in APNSConnection's __init__.

Original issue reported on code.google.com by [email protected] on 23 Apr 2010 at 1:19

Badges won't clear

What steps will reproduce the problem?
1. Send a apns-python-wrapper push with badges
2. Try to send another push with either badge(0) or unbadge()

What is the expected output? What do you see instead?

Neither badge(0) nor unbadge() clear the badge. Looking at the code, line 342 
shows if self.badgeValue: but that won't work when badgeValue is 0, because it 
won't attach to payload. 342 should say if self.badgeValue is not None:


What version of the product are you using? On what operating system?


Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 1 Aug 2012 at 9:19

patch for long connection

from APNSWrapper import APNSNotificationWrapper, APNSNotification
import struct

class APNSNotificationWrapperLongConn(APNSNotificationWrapper):

    def select_host(self):
        if self.sandbox != True:
            apnsHost = self.apnsHost
        else:
            apnsHost = self.apnsSandboxHost
        return apnsHost

    def connect(self):
        self.connection.connect(self.select_host(), self.apnsPort)

    def close(self):
        self.connection.close()

    def setpayload(self, payload = None):
        """Append payload to wrapper"""
        if not isinstance(payload, APNSNotification):
            raise APNSTypeError, "Unexpected argument type. Argument should be an instance of APNSNotification object"
        self.payloads = [payload]

    def notify(self):
        """ 
        Send nofification to APNS:
        1) prepare all internal variables to APNS Payout JSON
        2) make connection to APNS server and send notification
        """
        payloads = [o.payload() for o in self.payloads]
        payloadsLen = sum([len(p) for p in payloads])
        messages = []
        offset = 0 
        if len(payloads) == 0:
            return False
        for p in payloads:
            plen = len(p)
            messages.append(struct.pack('%ds' % plen, p)) 
            offset += plen
        message = "".join(messages)
        self.connection.write(message)
        return True

Original issue reported on code.google.com by [email protected] on 5 Nov 2011 at 5:37

Still doesn't handle unicode strings

Steps to reproduce:
>>> import APNSWrapper
>>> a = APNSWrapper.APNSNotification()
>>> a.alert(u"BLAHBLAHBLAH")
<APNSWrapper.notifications.APNSNotification object at 0x426c70>
>>> a.badge(4)
>>> a.tokenHex(<YOUR_KEY_HERE>)
<APNSWrapper.notifications.APNSNotification object at 0x426c70>
>>> b = APNSWrapper.APNSNotificationWrapper(certificate=<PATH_TO_YOUR_FILE>, 
sandbox=True)
>>> b.append(a)
>>> b.notify()
True

The device will set the badge correctly (to 4) but it won't show any alert 
message. This is because there is no alert message sent, since it's unicode.

I've included a patch below.

--- a/APNSWrapper/notifications.py  Wed May 19 21:41:49 2010 +0300
+++ b/APNSWrapper/notifications.py  Wed Jul 07 11:50:51 2010 -0400
@@ -324,6 +324,9 @@
             if isinstance(self.alertObject, str):
                 alertArgument = _doublequote(self.alertObject)
                 apsKeys.append('"alert":"%s"' % alertArgument)
+            elif isinstance(self.alertObject, unicode):
+                alertArgument = _doublequote(self.alertObject.encode("utf-8"))
+                apsKeys.append('"alert":"%s"' % alertArgument)
             elif isinstance(self.alertObject, APNSAlert):
                 alertArgument = self.alertObject._build()
                 apsKeys.append('"alert":{%s}' % alertArgument)

Original issue reported on code.google.com by [email protected] on 7 Jul 2010 at 3:59

to openssl or not

since version 0.5, apns seems to try always openssl, even if the ssl module is 
available

I do not want to use openssl, as there seem to be problems with apple 
negotiation some times and I 
get hanging openssl porcesses

if I deinstall openssl on my debian, I get a 
APNSWrapper.apnsexceptions.APNSNoCommandFound 
exception

any hints?

Original issue reported on code.google.com by [email protected] on 19 May 2010 at 1:50

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.