chenjunkai преди 6 години
родител
ревизия
5513cb29e9
променени са 2 файла, в които са добавени 10 реда и са изтрити 17 реда
  1. 8 16
      Controller/Test.py
  2. 2 1
      requirements.txt

+ 8 - 16
Controller/Test.py

@@ -35,25 +35,17 @@ class Test(View):
         master_secret = '6ce8d1ce403ae102661ca3b8'
 
         _jpush = jpush.JPush(app_key, master_secret)
-        _jpush.set_logging("DEBUG")
-        ###########
         push = _jpush.create_push()
-
+        # if you set the logging level to "DEBUG",it will show the debug logging.
+        _jpush.set_logging("DEBUG")
         # push.audience = jpush.all_
-        push.audience = devToken
+        push.audience = jpush.registration_id(devToken)
+        push.notification = jpush.notification(alert="hello python jpush api")
         push.platform = jpush.all_
-
-        # ios = jpush.ios(alert="Hello, IOS JPush!", sound="a.caf", extras={'k1': 'v1'})
-        android = jpush.android(alert="Hello, Android msg", priority=1, style=1, alert_type=1, big_text='jjjjjjjjjj',
-                                extras={'k1': 'v1'})
-
-        push.notification = jpush.notification(alert="Hello, JPush!", android=android)
-
-        # pprint (push.payload)
-        push.send()
-
-
-
+        try:
+            response = push.send()
+        except:
+            print("Exception")
         return response.json(0)
 
     def post(self, request, *args, **kwargs):

+ 2 - 1
requirements.txt

@@ -19,4 +19,5 @@ xmltodict
 var_dump
 django-middleware-global-request
 oss2
-aliyun-python-sdk-sts
+aliyun-python-sdk-sts
+jpush