I have followed the steps.
pip install fcm-djangoEdit your settings.py file
INSTALLED_APPS = ("fcm_django")
FCM_DJANGO_SETTINGS = {
"FCM_SERVER_KEY": "[your api key]"
}
and then
How do I send push messages on tokens ?? I didn't understand the following method
from fcm_django.models import FCMDevice
device = FCMDevice.objects.all().first()
device.send_message("Title", "Message")
device.send_message(data={"test": "test"})
device.send_message(title="Title", body="Message", icon=..., data={"test": "test"})
pip install pyfcm
OR
pip install git+https://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)
print result
OR
# 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
after google myself getting this result and its working for more info use this link https://pypi.org/project/pyfcm/0.0.4/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With