• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Benjamin

            靜以修身,儉以養德,非澹薄無以明志,非寧靜無以致遠。
            隨筆 - 397, 文章 - 0, 評論 - 196, 引用 - 0
            數據加載中……

            Python使用PyAPNs搭建APNS推送通知

            APNS 是蘋果為IOS設備提供的推送服務,全稱是(Apple Push Notification service)
            從github上下載源碼: PyAPNs https://github.com/djacobs/PyAPNs
            然后將解壓文件夾中的apns.py放入你的項目中.
            #測試接口(同步阻塞)
            def ios_push_test(token,in_alert,cert_path,key_path):
                # Send a notification
                apns = APNs(cert_file=cert_path,key_file=key_path)
                token_hex = token
                payload = Payload(alert=in_alert, sound="default", badge=1)
                apns.gateway_server.send_notification(token_hex, payload)
            #測試接口(帶相應回調:異步非阻塞)
            def ios_test(token,cert_path,key_path,in_alert):
                def response_listener(error_response):
                    print("client get error-response: " + str(error_response))
                #use_sandbox默認值為False,表示生產環境;Ture則表示開發(測試)環境
                apns_enhanced = APNs(use_sandbox=True,cert_file=cert_path, key_file=key_path,enhanced=True)
                token_hex = token
                payload = Payload(alert=in_alert, sound="default", badge=1)
                identifier = random.getrandbits(32)
                print(identifier)
                apns_enhanced.gateway_server.register_response_listener(response_listener)
                apns_enhanced.gateway_server.send_notification(token_hex, payload, identifier=identifier)
            錯誤代碼
            狀態碼 描述
            0 正確
            1 處理過程錯誤
            2 缺少設備令牌
            3 缺少主題
            4 缺少有效消息體
            5 令牌長度錯誤
            6 大小錯誤
            7 消息體長度錯誤
            8 令牌錯誤
            255 未知錯誤

            posted on 2020-04-22 11:11 Benjamin 閱讀(581) 評論(0)  編輯 收藏 引用 所屬分類: python

            久久免费的精品国产V∧| 欧美日韩精品久久免费| 色综合久久最新中文字幕| 国产国产成人久久精品| 热久久最新网站获取| 久久久久亚洲AV无码网站| 女同久久| 久久se精品一区精品二区| 久久久国产99久久国产一| 久久精品国产只有精品2020| 中文字幕无码久久精品青草| 久久综合久久久| 亚洲国产精品无码久久SM| 久久精品国产精品亚洲下载| 欧美黑人又粗又大久久久| 伊人久久成人成综合网222| 久久久综合九色合综国产| 亚洲中文字幕久久精品无码喷水| 国产精品激情综合久久| 精品久久久久久亚洲精品 | 久久精品中文騷妇女内射| 欧美久久一级内射wwwwww.| 狠狠色丁香婷婷综合久久来| 色88久久久久高潮综合影院| 四虎影视久久久免费观看| 久久久久久久久久免免费精品 | 久久精品人人做人人爽电影蜜月 | 国内精品久久久久影院一蜜桃| 久久综合伊人77777| 欧美久久综合九色综合| 久久午夜综合久久| 久久免费国产精品| 久久99国产一区二区三区| 久久最近最新中文字幕大全| 久久精品国产99久久久| 成人妇女免费播放久久久| 91久久精一区二区三区大全| 久久精品国产亚洲一区二区| 99久久99久久精品国产片果冻| 国产福利电影一区二区三区久久老子无码午夜伦不 | 亚洲精品国产自在久久|