【问题标题】:Push Notification Django 1.9推送通知 Django 1.9
【发布时间】:2017-07-26 17:07:45
【问题描述】:

我正在开发已经在 Django 1.9 中开发的项目。 我进行了很多搜索,但没有找到任何兼容版本的库来通过 Django DRF 和 Firebase (FCM) 实现推送通知。

谁能帮我推荐一个我可以为我的项目实现的推送通知库。

以下是我搜索过的库,但不适用于 python3 或 django 1.9

  1. https://github.com/jleclanche/django-push-notifications
  2. https://github.com/bogdal/django-gcm

只需要建议选择稳定库以使用 Firebase 通过 Django Rest Frameworkd(DRF) 发送推送通知。

提前致谢

【问题讨论】:

  • RestFrameWork 是 '3.6.3'

标签: django api firebase firebase-cloud-messaging django-rest-framework


【解决方案1】:

看看pyfcm。这个库对我来说很有前途,最适合 FCM 推送通知。文档包含满足您需求的每个示例。

注意:此库与任何 Web 框架无关。它可以在任何地方实现,因为它可以在 python 本身中实现。

这是向多个设备发送推送通知的最小示例,

# Send to single device.
from pyfcm import FCMNotification

push_service = FCMNotification(api_key="<api-key>")
# Send to multiple devices by passing a list of ids.
registration_ids = ["<device registration_id 1>", "<device registration_id 2>", ...]
message_title = "title"
message_body = "Dev loves Stack overflow"
result = push_service.notify_multiple_devices(registration_ids=registration_ids, message_title=message_title, message_body=message_body)

【讨论】:

    猜你喜欢
    • 2015-05-26
    • 1970-01-01
    • 1970-01-01
    • 2020-09-17
    • 1970-01-01
    • 2015-11-30
    • 1970-01-01
    • 2018-02-17
    • 2021-06-11
    相关资源
    最近更新 更多