| 123456789101112131415161718192021222324252627 |
- #-*-coding:utf-8 -*-
- import jpush
- app_key = "6aba55e8e8dacb49a5290b6e"
- master_secret = "257f2f6f8aa62add95accd86"
- _jpush = jpush.JPush(app_key, master_secret)
- _jpush.set_logging("DEBUG")
- push = _jpush.create_push()
- def send_notification_by_registration_ids(regids=["171976fa8a0d3dd7c0b"],msg="测试",title=None):
- """给指定regid发送消息
- """
- push.platform = jpush.all_
- android_msg = jpush.android(alert=msg,title=title)
- ios_msg = jpush.ios(alert={"title":title,"body":msg}, badge="+1", sound=None, extras={'k1':'v1'})
- push.notification = jpush.notification(alert=msg,android=android_msg,ios=ios_msg)
- push.options = {"time_to_live":86400, "sendno":12345,"apns_production":False}
- push.audience = jpush.audience(
- jpush.registration_id(*regids)
- )
- response = push.send()
- print response
- return response
- if __name__ == "__main__":
- send_notification_by_registration_ids()
|