0

I am trying to implement a notification system in Django. I find the firebase quite easy which is as follow:

from fcm_django.models import FCMDevice

device = FCMDevice.objects.all()

Now in view:

device.send_message(title="Title", body="Message", icon=..., data={"test": "test"})

In settings:

FCM_DJANGO_SETTINGS = {
     # default: _('FCM Django')
    "APP_VERBOSE_NAME": "[string for AppConfig's verbose_name]",
     # true if you want to have only one active device per registered user at a time
     # default: False
    "ONE_DEVICE_PER_USER": True/False,
     # devices to which notifications cannot be sent,
     # are deleted upon receiving error response from FCM
     # default: False
    "DELETE_INACTIVE_DEVICES": True/False,
    # Transform create of an existing Device (based on registration id) into
                # an update. See the section
    # "Update of device with duplicate registration ID" for more details.
    "UPDATE_ON_DUPLICATE_REG_ID": True/False,
}

Now my question is, we are using AWS for the backend and also for the database. In this case can we use the firebase for notification? How do these two services aws and firebase work together? WIll there be any problem??

Reactoo
  • 916
  • 2
  • 12
  • 40

1 Answers1

2

Sending messages through Firebase Cloud Messaging is done through a REST API, which can be called from any platforms. Any libraries you'll find out there (including Firebase's own Admin SDKs) are just wrappers around that REST API.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Hello Puff, is there any way to check the notification locally?? I did put the send_meesage function in my view, the api works but can't tell if the notification pops up or not – Reactoo Dec 16 '21 at 22:44
  • Not sure what you mean by "locally" there. The best way to see if you've wired up the client-side code correctly is to send a notification to the devie token from the Firebase console. Once that has confirmed that the client is configured correctly, move on to your own server that sends the messages. – Frank van Puffelen Dec 16 '21 at 23:46
  • Hello Frank, I am quite new to this. I am using Django rest for backend so local meaning where my localhost runs in console or browser, kind of like terminal (localhost:8000) where I test my apis in development before deploying it to prod. So, isnt there any way to test the firebase notification system in development mode only without integrating the client side ie frontend?? – Reactoo Dec 17 '21 at 03:13
  • As said: The best way to see if you've wired up the client-side code correctly is to send a notification to the devie token from the Firebase console. Once that has confirmed that the client is configured correctly, move on to your own server that sends the messages. – Frank van Puffelen Dec 17 '21 at 16:02
  • ok frank, I am not sure i am understanding correctly. I just finished writing the code (view) in Django ie server-side not the front end code. There is no any frontend side code right now which will be done by android studio developer. I just want to test my backend code now in the local terminal. For eg we can test sending mass emails in our local console, similar to that? Is that posssible?? – Reactoo Dec 18 '21 at 08:33
  • 1
    If you have no client yet, there's not a lot of testing you can do for testing [sending to a specific device](https://firebase.google.com/docs/cloud-messaging/send-message#send-messages-to-specific-devices). You could try [sending to a topic](https://firebase.google.com/docs/cloud-messaging/send-message#send-messages-to-topics) to see if the code gives any errors. But until a device is wired up to receive, there's nothing to show the test messages. – Frank van Puffelen Dec 18 '21 at 15:38
  • Hi Frank, I did find this one way using Gitpod. https://blog.hipolabs.com/testing-push-notifications-locally-with-firebase-ef052531af03 but stuck on one thing that I didnt get request permission dialog box of google clouding message. – Reactoo Dec 18 '21 at 15:50
  • More details here Frank, if you are kind enough to help https://stackoverflow.com/questions/70409319/request-permission-not-appearing-in-fcm-for-django – Reactoo Dec 19 '21 at 06:16
  • Hi Puff, one question ..is firebase totally free, ie if our project runs for like 10 years , a million notifications might be sent..can we do that we firebase?? or we have to buy a premium at one point?? – Reactoo Dec 20 '21 at 17:30
  • Cloud Messaging is free and unlimited as shown on the Firebase [pricing page](https://firebase.google.com/pricing). – Frank van Puffelen Dec 20 '21 at 23:55