Просмотр исходного кода

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

peng 1 год назад
Родитель
Сommit
1f3bbad896
1 измененных файлов с 18 добавлено и 8 удалено
  1. 18 8
      Service/PushService.py

+ 18 - 8
Service/PushService.py

@@ -167,14 +167,24 @@ 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,
-                                                       click_action='android.intent.action.VIEW',
-                                                       extra_kwargs={'default_sound': True,
-                                                                     'default_vibrate_timings': True,
-                                                                     'default_light_settings': 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://your.package.name/raw/phone_call',
+                                                           click_action='android.intent.action.VIEW',
+                                                           extra_kwargs={'default_sound': True,
+                                                                         'default_vibrate_timings': True,
+                                                                         'default_light_settings': True,
+                                                                         },
+                                                           )
+            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,
+                                                                         },
+                                                           )
             LOGGER.info('fcm推送结果:{}'.format(result))
             return True
         except Exception as e: