Skip to content

Firebase Cloud Messaging Quickstart with Python client for FCM

License

Notifications You must be signed in to change notification settings

Aramideh/FireBase-Cloud-Messaging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java based Firebase Cloud Messaging (FCM) Quickstart & Python client for FCM

The Firebase Cloud Messaging Android Quickstart app demonstrates registering an Android app for notifications and handling the receipt of a message. InstanceID allows easy registration while FirebaseMessagingService and FirebaseInstanceIDService enable token refreshes and message handling on the client. This projects contains python scripts necessary to send diffrent types of messages to registered clients.

FCM Demo

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Sending Notifications

You can send messages to the clients with these ways:

  • Use Firebase console to send FCM messages to device or emulator, go to the firebase console and start sending messages to the clients.

  • Using Pyfcm visit https://pypi.org/project/pyfcm/ to install pyfcm. then create a file and copy the code provided in below in the file.

from pyfcm import FCMNotification
  push_service = FCMNotification(api_key="SERVER_KEY")
  registration_id = "REGISTERATION_TOKEN"
  message_title = "your title"
  message_body = "Hi, your message body goes here!"
  result = push_service.notify_single_device(registration_id=registration_id, 
  message_title=message_title, message_body=message_body)

print result

run the saved file from command prompt and if everything is OK, you will see the notification on the client screen.

  • SERVER_KEY: You can get your SERVER_KEY from firebase console, go to the project setting in firebase console and from Cloud Messaging tab get your SERVER_KEY

  • SREGISTERATION_TOKEN: This token will be created the first time the app installs on an android device, you can get this token from the log in android studio or clicking on the token button in the app will show it to you.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

About

Firebase Cloud Messaging Quickstart with Python client for FCM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages