Эх сурвалжийг харах

谷歌推送一键通话配置铃声

peng 1 жил өмнө
parent
commit
c6e60f0cfc
1 өөрчлөгдсөн 10 нэмэгдсэн , 17 устгасан
  1. 10 17
      Service/PushService.py

+ 10 - 17
Service/PushService.py

@@ -167,24 +167,17 @@ class PushObject:
                 push_data['priority'] = 'high'
                 push_data['content_available'] = True
                 push_data['direct_boot_ok'] = True
-                result = push_service.notify_single_device(registration_id=token_val, message_title=msg_title,
-                                                           message_body=msg_text, data_message=push_data,
-                                                           sound='android.resource://com.ansjer.zccloud_a/raw/phone_call',
-                                                           click_action='android.intent.action.VIEW',
-                                                           extra_kwargs={'default_sound': True,
-                                                                         'default_vibrate_timings': True,
-                                                                         'default_light_settings': True,
-                                                                         },
-                                                           )
+                sound = 'android.resource://com.ansjer.zccloud_a/raw/phone_call'
             else:
-                result = push_service.notify_single_device(registration_id=token_val, message_title=msg_title,
-                                                           message_body=msg_text, data_message=push_data,
-                                                           click_action='android.intent.action.VIEW',
-                                                           extra_kwargs={'default_sound': True,
-                                                                         'default_vibrate_timings': True,
-                                                                         'default_light_settings': True,
-                                                                         },
-                                                           )
+                sound = None  # 其他事件类型默认铃声
+            result = push_service.notify_single_device(registration_id=token_val, message_title=msg_title,
+                                                       message_body=msg_text, data_message=push_data, sound=sound,
+                                                       click_action='android.intent.action.VIEW',
+                                                       extra_kwargs={'default_sound': True,
+                                                                     'default_vibrate_timings': True,
+                                                                     'default_light_settings': True,
+                                                                     },
+                                                       )
             LOGGER.info('fcm推送结果:{}'.format(result))
             return True
         except Exception as e: