项目作者: yunsonbai

项目描述 :
基于http2的apns库
高级语言: Python
项目地址: git://github.com/yunsonbai/apns2.git
创建时间: 2016-10-17T07:20:29Z
项目社区:https://github.com/yunsonbai/apns2

开源协议:

下载


apns2 (based on http2)

Overview

  • 应用:iso消息推送
  • 版本:0.3
  • 主要功能和特点:
    • 基于http2
    • 支持批量发送
  • 安装

Requirements

  • 开发语言
    • python3.5
  • 依赖库
    • hyper==0.7.0
    • hyperframe==3.2.0
    • h2==2.4.1

example

  1. from apns2.client import APNsClient
  2. from apns2.payload import Payload
  3. import uuid
  4. def push():
  5. token_hexs = [
  6. 'f9dcb885edbfcddsdaf64960bed56b19c362b3c617565126b085af2c8829467a',
  7. '9dc9662fa9dsd390fc6b3d3ec637a764867241f516d847b54d24ce7e37963b6e',
  8. 'd52c31a293aa79c61222626b0d025866ssssa4d0c79a2b2bf729cd48c61f14a2',
  9. '8c51ed081211d19d90f4b34b403c39f5ceeeeec368cfd9277812a7af778fbf5f',
  10. '3df3c6bc4a98c38d5d13cbb932f4969f5f0efhhha8e4cd32270777f273dc0e41',
  11. 'a25fbf0b5f84632406f33a78398138c87d13iiiiiiiiiiic466c11be9de22011',
  12. '3df3c6bc4a98c38d5d13cbb932f4969f5f0efyyyy8e4cd32270777f273dc0e41',
  13. 'aef8a3d0b6d38807ad8ab485665d36edc305a9793jjj269214bcd3357f60e07a']
  14. print(len(token_hexs))
  15. payload = Payload(alert="Hello World!", sound="default")
  16. # custom = {
  17. # 'custom': {
  18. # 'type': 1
  19. # }
  20. # }
  21. # payload = Payload(custom=custom, content_available=True)
  22. client = APNsClient(
  23. 'Dev_Cer-key.pem',
  24. # 'Cer_Key.pem',
  25. use_sandbox=True,
  26. use_alternative_port=False)
  27. response = client.send_notification_multiple(token_hexs, payload)
  28. return response
  29. def response_handler(response):
  30. # do something: delete badtoken and so on
  31. pass
  32. if __name__ == '__main__':
  33. response = push()
  34. response_handler(response)