我正在构建一个 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/