Sending a notification crashes app - firebase

I have a react-native app, and I thoroughly followed all the steps mentioned here to add Firebase to your app, and Add the SDK.
However, when I try to send my first notification using the Notification composer, my application simply crashes with the message "pushNotif has stopped working". This happenes regardless of background or foreground state.
Has anyone ever experienced this? does anyone have any idea what could be wrong?

You should try react-native-fcm to implement FCM in react-native, then you'll be able to handle notifications in your react-native javascript code.

Related

Can FCM push notifications in Electron App

I'm trying to send notifications from Firebase Cloud Messaging (FCM) to a window app (window form for example) but it doesn't seem to be possible (since fcm only supports android/ios/webapp, for here and here).
So trying building Electron app to be able to receive and display notifications from fcm (slack is built from electron js and also displays notifications, here), and found the electron-push-receiver allowing it to receive notifications from FCM
But it seems that there is no update for a long time, so there is a issue#80
Now is it possible to build electron application that can receive notifications from FCM?
Thank you very much!
I just implemented FCM in my Electron app earlier today by following the guide here:
https://github.com/CydeSwype/electron-fcm-demo
Screenshot of FCM working in an Electron app
I was skeptical at first as well, given that the repo hasn't been updated in a while, but was pleasantly surprised that it still works.
If you have any further questions, go ahead and I'll try to help :)
I also got this working with electron-push-receiver, though I had to do a workaround for more recent versions of Electron.
I looked at the firebase-admin.messaging Node package but that is only for privileged environments.
The HTTP 503 issue you linked it seems was just another outage that has been resolved; I can still register for push notifications with this setup.

Firebase Cross Platform Push Notification Plugin Duplicating MainActivity

I'm using the following plugin for implementing and handling FCM push notifications in my xamarin application and there's one little unaddressed problem I'm facing.
I was hoping someone else has already figured it out and could help me.
THE PROBLEM:
It seems to be duplicating my MainActivity although I have the LaunchMode set to SingleTop.
There's an event called OnNotificationReceived that's provided by the library.
This event fires as expected, only once, when the application is in the foreground.
When I minimize the application (let it run in the background), send a notification to the device and tap on the notification, it opens the application, as expected, but if I send another notification after that, while the application is in the foreground, The OnNotificationReceived Event is fired twice.
I've tried changing the NotificationActivityFlags property to SingleTop.
I've tried changing my MainActivity's Launch Mode to SingleTop
I tried running the sample application they've provided to check if its something that I'm doing wrong, and still the same thing happens.
Logging the issue in their Github repository
None of the above have worked.
The issue can be reproduced by:
downloading the sample from the repository, link provided above
replacing their google-services.json file with your own from the Firebase
console.
change the package name of the sample of the application to the one you
have registered on Firebase
following the steps above that I've mentioned
ADDITIONAL INFO
Version Number of Plugin: 1.3.0
Device Tested On: Huawei P8 Lite Android Version 6.0
Version of VS: Visual Studio 2019
Version of Xamarin: 3.4.0.1009999
Update:
Unfortunately, the method below has not proven successful after attempting to implement it, I should have thought of the fact that I'm still going to need the notification object for iOS, earlier.
Myself and the team are going to implement a way to keep track of the users platform on the server and send them a notification either with or without the notification based on their platform, since iOS handles FCM notifications differently from Android. For now we're going to use Google's Instance ID service to determine what platform existing users are on.
Workaround:
I hope this helps someone in the future, if not I hope someone can provide me with a better solution.
In order to have my cake and eat it, basically be able to keep the notification object in the payload instead of removing it and having to further customise the payload to display notifications just for iOS, I changed the MainActivity's (the activity thats launched when a user taps on the notification) Launch mode to SingleInstance. That way I can keep my notification object in the payload and not have to worry about the OnNotificationReceived event being triggered twice.

Send Push Notifications Programmatically Javascript

I have an Angular 2+ app where I have an interface to send Push Notifications to users of an Ionic App.
What I want to do is to use the Web interface to send programmatically notifications with Javascript. Has anyone done this before?
Can anybody tell me how to do this? I would be really happy to see some code examples but a recommendation where to start and which API/SDK to use would be enough.
I really do not want anyone to do this for me but some direction would really help me as I am new to Push Notifications from the Web.
Thank you.
You can use Firebase to work with push notifications. There is a tutorial to implement it to you Ionic App. But to send push notification you will need to have a server backend.

How do you access OneSignal's database on Android & iOS in Flutter?

I am using OneSignal in my Flutter application to receive notifications. I have created my own table within Flutter to save notifications but I cannot save messages that have been sent whilst the app has been terminated. However, I have found that the OneSignal package has it's own database installed on the device which captures everything no matter what state the application is in! So, to avoid duplicating data I want to use this database instead. It is located outside of the flutter app folder which is my issue (see image below).
How do I access this database? Does anybody know if it is the same on iOS (I haven't been able to check at this time).
Many thanks.
It's important to understand that if an app has been terminated, any onReceived handler will not be fired. We don't recommend using the local db at all. Your best bet is to use the respective notification extender services for each platform. Though you will have to write native code for this! Cheers
Edit:
ANDROID - NotificationExtenderService - This can be setup to receive silent notifications when your app is not running or to override how notifications are shown in the notification shade. See the Background Data and Notification Overriding section to set this up.

Firebase Cloud Messages Push Notifications

I have developed a simple android app using Firebase database to store stuff.
Now, I want to set up notifications for each time a button is clicked.
Each time the button is clicked, it will take some info from firebase (text mostly) and will send a notification to anyone who downloaded the app.
I understood that simply creating a notificationManager won't work as needed.
I also heard about Firebase Cloud Messaging but im pretty new to this so I must know what I should start learning to make that work out.
So, if you have any good tutorials or anything helpful, that would be great!
Thanks!
You need to receive for the FCM in android app. Refer this doc. And you need to can use database triggers in firebase cloud functions to send FCM notification, or you need to deploy a cloud http function to do so.

Resources