Implement Notification using Py FCM Python client for

  • Slides: 6
Download presentation
Implement Notification using Py. FCM Python client for FCM - Firebase Cloud Messaging (Android,

Implement Notification using Py. FCM Python client for FCM - Firebase Cloud Messaging (Android, i. OS and Web)

Steps to install pyfcm • Install using pip: pip install pyfcm OR pip install

Steps to install pyfcm • Install using pip: pip install pyfcm OR pip install git+https: //github. com/olucurious/Py. FCM. git

Send notifications using the FCMNotification class • Import fcm class from pyfcm import FCMNotification

Send notifications using the FCMNotification class • Import fcm class from pyfcm import FCMNotification • Configured with firebase project push_service = FCMNotification(api_key="<apikey>")

Send Notification to single device • • registration_id = "<device registration_id>" message_title = "Uber

Send Notification to single device • • 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 =

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(registra tion_ids=registration_ids, message_title=message_title, message_body=message_body)

Send a data message • data_message = { "Nick" : "Mario", "body" : "great

Send a data message • data_message = { "Nick" : "Mario", "body" : "great match!", "Room" : "Portugal. VSDenmark" } • # To multiple devices • result = push_service. notify_multiple_devices(registration_ids=registr ation_ids, message_body=message_body, data_message=data_message) • # To a single device • result = push_service. notify_single_device(registration_id=registration_id, message_body=message_body, data_message=data_message)