Permanent Notification From Firebase Cloud Function? - firebase

Is it possible to send permanent notification from firebase cloud functions? User can't dismiss that notification?

For iOS you cannot, but Android you could setup a local notification using remote config.
iOS Remote Notifications
While you could send the same notification over and over again, control of the notifications is at the OS level of the client device. iOS would never let you create a local or remote notification that cannot be dismissed because it would be a poor user experience. In addition, I think you would find that your users would not be happy about it as well.
An alternative, would be to create a custom UI Header in your app that includes a label. You could then use Firebase Remote Config to set a value for that label, that way you can deliver the same message to all users of your app.
Android Push Notifications
In Android, it looks like you can have permanent notifications. However, it looks like this is controlled at the client level. So I still recommend the remote config option here as well. Set the value of the remote config, and then generate a local notification and set the notification to not clear.
notification.flags |= Notification.FLAG_NO_CLEAR;
Perhaps, a key/value pair could be sent from your Firebase Cloud Message call, but you will run into other issues as well. When should the function be called? Will you generate a new notification for every new user added to Firebase? This could become more expensive versus the remote config route.
Google Chrome Notifications
The remote config option should scale to this as well. A quick Google search didn't show anything that would suggest you can do a permanent notification like Android. And even if you could then your solution wouldn't work in Safari and other browsers.

Related

Firebase push notification device to device

I am coding a React Native app and I using Firebase push notification service.
In my app, users can send message for each other and I want to notify them when they get message.
I found one way for native android I can code for react native it is not problem just I want to know if there is better way. I can make post to directly to Firebase service with using Http post.
This is the link which way I found: https://blog.usejournal.com/send-device-to-device-push-notifications-without-server-side-code-238611c143
I want to push notification to specific device without server, is there another way to do this?
Sending a message to a device with Firebase Cloud Messaging requires that you specify the FCM server key. As its name implies, this key is supposed to only be used in trusted environments, as knowing it allows one to send any message they want to all users of the app. For this reason it is not possible to secure send messages directly from one device to another device with FCM.
Instead you will have to run code in a trusted environment, such as your development machine, a server you control, or Cloud Functions. Your client-side application code invokes the server-side code, that ensures the call is authorized, and then calls the FCM API.
For more on this see:
How to send one to one message using Firebase Messaging
How to send device to device messages using Firebase Cloud Messaging?

Show notification based on a Firebase values

I want to show notification in my app even if the app is closed.. I don't need Firebase's Push Notification Service. The idea is similar to WhatsApp's message notification service.
When a value is added to firebase by a user another user should receive notification that there is a value change
Can someone tell me how this is done and What should I use to achieve this?
Push notifications for all major apps run through APNS for iOS, and Firebase Cloud Messaging for Android. While the apps may use a higher-level service from their application code, those services depend on APNS and FCM for the actual message delivery.
To see an example of how to build a notification system on top of this, based on values being written to a database, see Send Firebase Cloud Messaging notifications for new followers.

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.

How to create a "real" iOS push notification from Firebase topic messages if the app is not running?

As far as I understand messages on subscribed topics are received through the socket connection.
So while the app is running in the background I could create local notifications and "fake" notification that pop up on the home screen and are visible in the notification center.
But is there a way to receive topic pushes if the app is closed/not running in the background?
I'm grateful for any kind of feedback as I couldn't find any documentation regarding that specific use case.
Just to clarify: I am talking about (subscribed) topic messages in firebase NOT the firebase messages. I am used to the generic iOS push notifications handling and the involved lifecycle methods. All I need to know is how firebase topic messages can be sent via apns notifications.
With Firebase Messaging you can send notifications so the app is closed (it must be installed), basically it is configured in the AppDelegate the methods and configuration according to your need, you can see more information here Firebase Messaging
No you can’t, setup your configration in apo delegate and firebase settings, when the app is offline firebase talked directly to the APN which called the nitification center in your iphone but you don’t have access on it during the application is closed.

Web Push. fetching web pushes sent while offline?

I am coding a vue.js app using web pushes with Firebase Cloud Messaging and I wondered if it was possible to send a web push to a user and in case the user was offline, to somehow store it for later display when the user opens the app again. Is there a principled approach to this problem, i.e. managing web pushes when the end user is offline?
The reason I am asking this is that, so far, all the web push notifications I've committed to FCM server with tokens of offline clients (i.e. desktop browsers) went into oblivion. To be sure, FCM didn't try pushing the notification again when the clients went back online.
For this reason I am considering coding a self-made dispatcher to manage web push for offline clients, but I need to make sure my efforts are worth it.
updated: I am now able to display notifications sent to an offline client after coming back online using appropriate time_to_live values. However, only the latest notification is displayed. How is there any specific reason why?
FCM's default behavior is exactly like that. From the docs:
If the device is not connected to FCM, the message is stored until a connection is established (again respecting the collapse key rules). When a connection is established, FCM delivers all pending messages to the device.

Resources