python - 如何使用 PyFCM 在 Django Python 中启用 Google Firebase 通知分析?
问题描述
我们正在使用 PyFCM 模块通过 google firebase 发送通知,并且不知何故 GCP firebase 控制台的报告部分中缺少通知分析报告的数据。
有人可以知道如何在 Firebase 上启用通知分析吗?因为我们想知道正在发送、接收和打开的通知的详细信息。
解决方案
我们需要在发送到 firebase 的每个通知中添加 analytics_label,对于使用 Django 的 PyFcm,您可以在下面给出的 fcm_options 中传递 analytics_label:-
from pyfcm import FCMNotification
push_service = FCMNotification(api_key=FCM_SERVER_KEY)
registration_ids = ['user_mobile_token_key']
data = {
"body": "test body,
"title": "title,
"priority": "high"
}
extra_kwargs = {'**fcm_options**': {
'analytics_label': 'notification-label'}}
result = push_service.multiple_devices_data_message(registration_ids=registration_ids,
data_message=data, extra_kwargs=extra_kwargs)
print(result)
推荐阅读
- html - 嵌入的 Google 表格会删除之后的元素
- c++ - 编译时计算 (C++ v. C)
- r - 最好/更快?在R中反转多对多关系列表的方法
- stored-procedures - 使用 Teradata 存储过程的倒三角形
- python - 基于单独列 pandas 中的标准的累积最大值/最小值
- python - Testcontainers Postgresql 模拟不起作用
- python - 上传到 azure blob 存储的文件为空或什至不存在
- javascript - Reactjs:如何在点击时将对话框移动到屏幕顶部
- android - 出现数据剂量,我只有白屏
- python - 在python中将套接字绑定到本地地址的权限被拒绝