reactjs - 如何将推送通知从 django 发送到 React Native 应用程序?

标签 reactjs django native

我正在构建一个 django 应用程序,我想知道如果满足某种条件,在 React Native 应用程序中向用户发送推送通知的最佳方法是什么。这个想法是向用户组发送通知。甚至可以同时有 100 个用户

最佳答案

嗯,我一小时前就完成了这个。试试这个:

pip install pyfcm

OR

pip install git+git://github.com/olucurious/PyFCM.git

示例:

# Send to single device.
from pyfcm import FCMNotification

push_service = FCMNotification(api_key="<api-key>")

registration_id = "<device registration_id>"
message_title = "Uber update"
message_body = "Hi john, your customized news for today is ready"
result = push_service.notify_single_device(registration_id=registration_id, message_title=message_title, message_body=message_body)

# Send to multiple devices by passing a list of ids.
registration_ids = ["<device registration_id 1>", "<device registration_id 2>", ...]
message_title = "Uber update"
message_body = "Hope you're having fun this weekend, don't forget to check today's news"
result = push_service.notify_multiple_devices(registration_ids=registration_ids, message_title=message_title, message_body=message_body)

print result

您只需要使用 firebase 即可。从他们和您的 device_registration_id 或 device_token 获取 api key ,您就完成了。

更多内容可以关注以下link

关于reactjs - 如何将推送通知从 django 发送到 React Native 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67222354/

相关文章:

node.js - 您应该将流程类型文件夹发布到 NPM 吗?

python - Django异步-关于模型保存功能

python - Django model.objects.all() 在正常调用时给出列表索引超出范围

android - Android 6 上的 Retrofit + Robospice native 崩溃 - 致命信号 11 (SIGSEGV),代码 1

node.js - 服务器渲染 react-router v4 passthrough if 404

javascript - 正确卸载 react 组件

javascript - useEffect 有时会给出 null 错误,因为 "error"变量来自 redux 的更改

django - 如何在 Azure 应用服务上(连续)运行工作线程

jquery - 相当于 native javascript 中的 $(this)

javascript - 是否可以在 Macgap 中调试 UIWebView?