|
@@ -11,19 +11,39 @@
|
|
|
@file: spnsss.py
|
|
|
@Contact: chanjunkai@163.com
|
|
|
"""
|
|
|
+from gcm import GCM
|
|
|
+
|
|
|
+gcm = GCM(API_KEY)
|
|
|
+data = {'param1': 'value1', 'param2': 'value2'}
|
|
|
+
|
|
|
+# Downstream message using JSON request
|
|
|
+reg_ids = ['token1', 'token2', 'token3']
|
|
|
+response = gcm.json_request(registration_ids=reg_ids, data=data)
|
|
|
+
|
|
|
+# Downstream message using JSON request with extra arguments
|
|
|
+res = gcm.json_request(
|
|
|
+ registration_ids=reg_ids, data=data,
|
|
|
+ collapse_key='uptoyou', delay_while_idle=True, time_to_live=3600
|
|
|
+)
|
|
|
+
|
|
|
+# Topic Messaging
|
|
|
+topic = 'topic name'
|
|
|
+gcm.send_topic_message(topic=topic, data=data)
|
|
|
+
|
|
|
+exit()
|
|
|
import time
|
|
|
import apns2
|
|
|
from var_dump import var_dump
|
|
|
|
|
|
-
|
|
|
-daytime = time.strftime("%Y%m%d%H%M", time.localtime(1547256103))
|
|
|
+daytime = time.strftime("%Y%m%d%H%M", time.localtime(time.time()))
|
|
|
print(daytime)
|
|
|
|
|
|
cli = apns2.APNSClient(mode="dev", client_cert="apns-dev.pem", password='111111')
|
|
|
-alert = apns2.PayloadAlert(body="body!", title="title!")
|
|
|
+alert = apns2.PayloadAlert(body="test!", title="title!")
|
|
|
payload = apns2.Payload(alert=alert)
|
|
|
n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
|
|
|
-response = cli.push(n=n, device_token="ce85e307e4938ea71d9b2fb8f21de2224d4bb67c")
|
|
|
+response = cli.push(n=n, device_token="34f057ea415333732aa2347af7f3600fab771b3cd924ad1d1e27aa66b9c280e8",
|
|
|
+ topic='com.ansjer.zsavcloud')
|
|
|
|
|
|
var_dump(response)
|
|
|
assert response.status_code == 200, response.reason
|