Created
April 7, 2014 15:34
-
-
Save Kingson/10022578 to your computer and use it in GitHub Desktop.
这是一段使用APNSWrapper实现的发送Apple Push的代码。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# coding=utf-8 | |
""" | |
1. 这是一段使用APNSWrapper[https://code.google.com/p/apns-python-wrapper/]实现的发送Apple Push的代码, | |
其中的deviceToken需要替换为自己设备的deviceToken,pem_cert也需要替换为自己应用的P12证书; | |
2. 具体的获取设备的deviceToken的方法和导出P12证书的方法, | |
请参考这篇文章[http://www.cnblogs.com/sunnyxx/archive/2012/12/01/2796461.html] | |
""" | |
__author__ = 'jszhou' | |
from APNSWrapper import * | |
import binascii | |
# 请替换为自己的设备的deviceToken | |
deviceToken = binascii.unhexlify("********") | |
#创建通知对象 | |
notification = APNSNotification() | |
notification.token(deviceToken) | |
notification.alert("土豪,我们做朋友吧") | |
notification.badge(5) | |
notification.sound() | |
#创建发送通知的这个wrapper | |
pem_cert_name = "production.p12" # 需要使用自己应用的P12证书 | |
wrapper = APNSNotificationWrapper(pem_cert_name, False) | |
wrapper.append(notification) | |
wrapper.notify() |
Author
Kingson
commented
Apr 7, 2014
- APNSWrapper[https://code.google.com/p/apns-python-wrapper/]
- iOS远程推送和python版push server相关笔记[http://www.cnblogs.com/sunnyxx/archive/2012/12/01/2796461.html]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment