xtrinch/fcm-django

I need help with integration with React-Redux application.

piyushjoshi1016 opened this issue · 7 comments

I could find the steps to integrate this library with any JS Framework like react or similar can you help me with step by step guide to do the same. or any video which is available for people to know the integration steps?

Things I want to know are:

  1. How to subscribe a user (How the request from frontend react application will be made. like may be using any subscription API call)
  2. How to setup serviceWorker (background service) on frontend react application to listen to the incoming notifications or data messages.
  3. How to filter and connect to the subscriber from Django code.

Have you checked out https://github.com/xtrinch/fcm-django-web-demo? It's pure javascript but it should be easy enough to port it to react?

Have you checked out https://github.com/xtrinch/fcm-django-web-demo? It's pure javascript but it should be easy enough to port it to react?

While trying to run the demo. I stuck with an error "The script has an unsupported MIME type ('text/plain')." and one uncaught following promise:

firebase-storage.js:4528 Uncaught (in promise) e {code: 'messaging/failed-serviceworker-registration', message: 'Messaging: We are unable to register the default s…). (messaging/failed-serviceworker-registration).', browserErrorMessage: "Failed to register a ServiceWorker for scope ('htt…ript has an unsupported MIME type ('text/plain').", stack: 'FirebaseError: Messaging: We are unable to registe…static.com/firebasejs/4.1.2/firebase.js:532:17774'}
Promise.then (async)
resetUI @ (index):152
(anonymous) @ (index):316

Here is the screenshot. attached.
image

There is not enough resources or help on fcm-django. There should be something like a YouTube tutorial that explains it perfectly for ease of use at least those who already know how to integrate it. @xtrinch

I was unable to reproduce any issues with the fcm-django-web-demo app. Try to pull the latest version and see if the issue persists.

I provided an example repo which I think should be sufficient as an implementation guide, if somebody wants to do a react example or something more elaborate, I will gladly link it in this repo

Hello, thanks. I have finally gotten it right. However I have an issue, it doesn't have the option to set the priority of the notification. It is on normal by default and unchangeable.

@IslamKolade
This basically boils down to how you construct the message that you pass to fcm-django, which is best followed by the official firebase-admin docs. An example would be:

message = messaging.Message(
    android=messaging.AndroidConfig(
        priority='normal',
        notification=messaging.AndroidNotification(
            title='test',
            body='test123',
        ),
    ),
)