Ernesto Ruiz
Ernesto Ruiz

Reputation: 820

How to send push notifications from django to a react native app?

I am building a django aplication and I want to know what is the best approach for sending push notifications to users in a react native app if a certain condition is mee. The idea is to send notifications to groups of users. It could be even 100 users at the same time

Upvotes: 2

Views: 3103

Answers (2)

user15195370
user15195370

Reputation:

Well I have done this just an hour ago. Try this:

pip install pyfcm

OR

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

Example:

# 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

You just need to use firebase. Get api key from their and your device_registration_id or device_token and your are all done.

For more you can follow the following link

Upvotes: 2

Rafael Mocelin
Rafael Mocelin

Reputation: 1

Did you try OneSignal?

http://onesignal.com

They have a simple setup, an easy to use API, and its free

Upvotes: 0

Related Questions