Package: apns-proxy-client
Client program ofAPNs Proxy
ServerInstallationpip install apns-proxy-clientHow to Usefromapns_proxy_clientimportAPNSProxyClientclient=APNSProxyClient(host="localhost",port=5556,application_id="myapp")withclient:# send "Hello" alerts to many tokensfortokeninmany_tokens:client.send(token,'Hello',badge=1)# get disabled device tokens from feedback servicefeedback=client.get_feedback()OR useconnect()andclose()instead ofwithfromapns_proxy_clientimportAPNSProxyClientclient=APNSProxyClient(host="localhost",port=5556,application_id="myapp")client.connect()# send "Hello" alerts to many tokensfortokeninmany_tokens:client.send(token,'Hello')# get disabled device tokens from feedback servicefeedback=client.get_feedback()client.close()Set host and port for your server running on. application_id is
specified in settings.py on apns-proxy-server.send() method synopsistoken="YOUR_VALID_DEVICE_TOKEN"client=APNSProxyClient(host="localhost",port=5556,application_id="myapp")withclient:# Simpleclient.send(token,'Hello')# Custom sound (default = 'default')client.send(token,'Alert with custom sound',sound='custom')# Message without soundclient.send(token,'I am silent',sound=None)# Badgeclient.send(token,'Alert with badge',badge=2)# Change badge silentlyclient.send(token,None,sound=None,badge=9999)# Set expiry (default = 1hour)four_hours_later=int(time.time())+(60*60*4)client.send(token,'I am long life',expiry=four_hours_later)# Set priority (default = 10)client.send(token,'I am low priority',priority=5)# For background fetchclient.send(token,None,sound=None,content_available=True)# With custom field.client.send(token,'With custom field',custom={'foo':True,'bar':[200,300],'boo':"Hello"})# Finally following payload will send to APNs# {#     "aps": {#         "alert": "With custom field",#         "sound": "default",#      },#      "foo": True,#      "bar": [200, 300],#      "boo": "Hello"#}# Use JSON Payloadclient.send(token,{'body':'This is JSON alert','action_loc_key':None,'loc_key':'loc key','loc_args':['one','two'],'launch_image':'aa.png'})# Allclient.send(token,'Many opts',sound='foo',badge=2,content_available=True,custom={"bar":"boo"},expiry=four_hour_later,priority=5)# Test. APNsProxyServer don't send to APNsclient.send(token,'This message never send to device',test=True)Parameters of send methodNameTypeRequiredDefault Value (Set on server)tokenstringyesalertstring, unicode or dictyessoundstringno‘default’badgenumbernoNonecontent_availableboolnoFalsecustomdictnoNoneexpirydateno1 hourprioritynumberno10testboolnoFalseget_feedback() method synopsisThis client library provides a way to get disabled device tokens from
APNs feedback service; just callget_feedback()without any
parameters.get_feedback()returns the dict that is a pair of “device_token”
and “timestamp”.NameTypeDescriptiondevice_tokenstringThe device token string which cannot be received push notificationstimestampfloatThe seconds since 00:00 on January 1, 1970 UTC. This value means a timestamp which APNs judged the device token should be disabled.client=APNSProxyClient(host="localhost",port=5556,application_id="myapp")withclient:feedback=client.get_feedback()# a value of feedback likes the following dict:#   {#       "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef": 1399442843.0,  # device_token : unix timestamp#       "abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789": 1399442892.0,#   }For contributorMakefile provides some useful commands.CommandDescriptionmake setupSetup work directorymake lintCode check using flake8make testRun testsLicenseBSD