spnsss.py 937 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. @Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
  5. @AUTHOR: ASJRD018
  6. @NAME: AnsjerFormal
  7. @software: PyCharm
  8. @DATE: 2019/1/3 16:46
  9. @Version: python3.6
  10. @MODIFY DECORD:ansjer dev
  11. @file: spnsss.py
  12. @Contact: chanjunkai@163.com
  13. """
  14. import time
  15. import apns2
  16. from var_dump import var_dump
  17. daytime = time.strftime("%Y%m%d%H%M", time.localtime(time.time()))
  18. print(daytime)
  19. cli = apns2.APNSClient(mode="dev", client_cert="apns-dev.pem", password='111111')
  20. alert = apns2.PayloadAlert(body="test!", title="title!")
  21. payload = apns2.Payload(alert=alert)
  22. n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
  23. response = cli.push(n=n, device_token="34f057ea415333732aa2347af7f3600fab771b3cd924ad1d1e27aa66b9c280e8",
  24. topic='com.ansjer.zsavcloud')
  25. var_dump(response)
  26. assert response.status_code == 200, response.reason
  27. assert response.apns_id