如何将推送通知从 django 发送到反应本机应用程序?
How to send push notifications from django to a react native app?
我正在构建一个 Django 应用程序,我想知道如果满足特定条件,在 React Native 应用程序中向用户发送推送通知的最佳方法是什么。这个想法是向用户组发送通知。甚至可以同时100个用户
你试过 OneSignal 了吗?
它们设置简单,易于使用 API,而且免费
好吧,我刚刚在一个小时前完成了这个。试试这个:
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 密钥,你就完成了。
更多可以关注以下link
我正在构建一个 Django 应用程序,我想知道如果满足特定条件,在 React Native 应用程序中向用户发送推送通知的最佳方法是什么。这个想法是向用户组发送通知。甚至可以同时100个用户
你试过 OneSignal 了吗?
它们设置简单,易于使用 API,而且免费
好吧,我刚刚在一个小时前完成了这个。试试这个:
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 密钥,你就完成了。
更多可以关注以下link