Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'develop'

  • Loading branch information...
commit 4f3812b04f92789871c11eddfcccc9bae5f55fc4 2 parents 0f2f5d2 + c9d0878
authored October 22, 2012

Showing 2 changed files with 38 additions and 0 deletions. Show diff stats Hide diff stats

  1. 37  apns-send
  2. 1  setup.py
37  apns-send
... ...
@@ -0,0 +1,37 @@
  1
+#!/usr/bin/env python
  2
+
  3
+from apns import APNs, Payload
  4
+
  5
+import optparse
  6
+
  7
+parser = optparse.OptionParser()
  8
+
  9
+parser.add_option("-c", "--certificate-file",
  10
+                  dest="certificate_file",
  11
+                  help="Path to .pem certificate file")
  12
+
  13
+parser.add_option("-p", "--push-token",
  14
+                  dest="push_token",
  15
+                  help="Push token")
  16
+
  17
+parser.add_option("-m", "--message",
  18
+                  dest="message",
  19
+                  help="Message")
  20
+
  21
+options, args = parser.parse_args()
  22
+
  23
+if options.certificate_file is None:
  24
+    parser.error('Must provide --certificate-file')
  25
+
  26
+if options.push_token is None:
  27
+    parser.error('Must provide --push-token')
  28
+
  29
+if options.message is None:
  30
+    parser.error('Must provide --message')
  31
+
  32
+apns = APNs(cert_file=options.certificate_file)
  33
+
  34
+# Send a notification
  35
+payload = Payload(alert=options.message, sound="default", badge=1)
  36
+apns.gateway_server.send_notification(options.push_token, payload)
  37
+print("Sent push message to APNS gateway.")
1  setup.py
@@ -8,6 +8,7 @@
8 8
     license = 'unlicense.org',
9 9
     name = 'apns',
10 10
     py_modules = ['apns'],
  11
+    scripts = ['apns-send'],
11 12
     url = 'http://www.goosoftware.co.uk/',
12 13
     version = '1.1.2',
13 14
 )

0 notes on commit 4f3812b

Please sign in to comment.
Something went wrong with that request. Please try again.