Header Ads

Python Django with Google Firebase (FCM): Firebase Cloud Messaging Setup and Configure #Part 8

In this post of Python django with Google Firebase series I will show you how to setup and configure Firebase cloud messaging on Python Django.

Insights:

If we want to send a push-notification to an android app then one the best way is to use Firebase cloud messaging, we can setup a manual push-notification to Android app using Firebase console but sending a automated push-notification sometimes becomes a vary cramp-breaking task. Here, we'll integrate automated push-notification on python django based "Employee Daily Progress Reporting Web App". 


Work Flow Intro :

From, last 7 posts, we are working on a Python Django based web-app in which we are using Firebase as a Back-end support, we have created post/video tutorials for each Firebase functionality, integrated in our Web-App. If we talk about current status, till now we have come a very long way as we integrated following functionalities in our web app :

  • Firebase Authentication : SignIn, SignUp, Logout, Session 
  • Firebase Database : Push Data/ Retrieve Data | Secure Database Rules
  • Firebase Storage : Store Image/Files | Retrieve Images/Files

Now, with these functionalities Employee can create a report and Retrieve created reports along with images, but there is a requirement of sending automated push-notification to admin android app once a report is created. So, i hope you guys are clear with requirement of Integrating FCM with my Python Django web app. Let's see a step by step guide :-   


If you like videos like this consider donating $1, or simply turn off AdBlocker. Either helps me to continue making tutorials.


Code below follows the video to help :

Transcript / Cheat Sheet

Setting Up Firebase Console for FCM : 

Setting Up Pusher Beams (Pusher Notifications) : 

Django Code :

Views.py
def push_notify(name,progress,work): from pusher_push_notifications import PushNotifications
pn_client = PushNotifications(
instance_id='be2dce08-9b23-4a81-a72b-fab39797530c',
secret_key='0D2A5BABBF132520C4CF8FB9C165D12',
)
response = pn_client.publish(
interests=['hello'],
publish_body={'apns': {'aps': {'alert': 'Report Created'}},
'fcm': {'notification': {'title': str(name), 'body': 'Progress: '+str(progress) +" work: " +str(work) }}}
)
print(response['publishId'])
Android Code :

App/Build.gradle


compile 'com.pusher:push-notifications-android:0.9.12' compile 'com.google.firebase:firebase-messaging:10.0.1'
Main Activity.java :
import com.pusher.pushnotifications.PushNotifications;
PushNotifications.start(getApplicationContext(), "61d2753d-9e78-4bc5-86d4-61e44fedab27");
PushNotifications.subscribe("hello");

Get whole project source code here.

4 comments:

  1. just information we only provide information for those who need it
    Happy Valentines Day Love 2019

    ReplyDelete
  2. Valentine's day, the day of love, which falls on 14th February every year is celebrated by the couple all across the globe. Here is the world famous valentine day website visit here: Happy Valentine’s Day Love

    ReplyDelete
  3. Swagg Sauce, manufacturer of the finest premium vape juice and salt nicotine ingredients crafted with our signature flavor blends and eliquid online. Premium grade vape juice, candy, cream, custard, dessert, fruit, tobacco, menthol and more info click here https://buycheapvapecoilsnow989310935.wordpress.com/

    ReplyDelete

Powered by Blogger.