User action for send oush notifications in firebase on android - android

Is possible to send push notifications with firebase without using the console,I mean can I send a push notifications when some user makes some action in the app?

Is possible to send push notifications with firebase without using the
console
Yes you can use Firebase API
I mean can I send a push notifications when some user makes some
action in the app?
You can subscribe to a topic when user makes some action in the app
FirebaseMessaging.getInstance().subscribeToTopic("news");
and send a notification from Firebase web console or use Firebase API to all topic subscribers.

You can send a message to a topic from the Firebase Cloud Messaging API.
But this requires the use of your FCM server key, which means it should only be done from an app server. You should never embed your server key in the client-side app. This means that direct device-to-device notifications are not possible at the moment, you will always need an app server for that.
For a tutorial explaining one possible scenario, see: https://firebase.googleblog.com/2016/08/sending-notifications-between-android.html

Related

How to ensure firebase has received push notification sent from app server, without android app

I am new with Firebase. I want to send push notifications to an android app from a spring application. At preset I dont have an android app. I want to test whether the firebase integration is correct or not, which means I want to make sure that the push notifications sent from the backend server are recieved correctly in firebase .
How do I ensure that firebase has recieved the push notifications sent from backend server?
Is it possible to test push notifications without an android app registered on firebase? If yes, how do I do that?
I am using Firebase Admin SDK. Do I need a separate server key other than the service account key for sending notifications?
You'll get a success (or fail) response when sending messages. This means that FCM has received your message and it will try to deliver it to the users.
FCM needs to target your app in order to send notification. If you don't set up FCM SDK in your app, it wont be able to do so.
You just need to generate an auth token. This guide should help you set it up.

FCM: Access all sent push messages

The goal I want to achieve for the app owner is to send FCM push notifications via web interface to the customers (already achieved) and to give the customers a view in my app, on which they can read all or at least the last 10 sent push messages. Is there any (REST) api in FCM which can be used to receive the sent push notifications and its content so I can display them in my Android fragment?
Unfortunately, there is no available API as of the moment to retrieve your GCM/FCM logs. However, there's been a recent improvement in the Firebase Notifications console where stats for messages sent using the FCM API is included in the Firebase Notification console stats.
The more details can be found from this answer and the blogpost.

Is it possible to send automatically push notification to android app by using Google Analytics for Firebase Triggers on "app_remove" event

I am trying to send a push notification when user is going to uninstall my Android app. My idea is to use Firebase Cloud Messaging and Google Analytics for Firebase Triggers. In order to be able to use triggers I have been marked "app_remove" event as conversion in Firebase Console of my app. It is possible send notifications using Firebase Cloud Messaging triggered by a Firebase function as described in this question, but when my app is uninstalled It will not be able to show incoming message from FCM as a push notification. It is possible to setup the incoming message to be displayed as push notification even my app is uninstalled?
It is possible to setup the incoming message to be displayed as push notification even my app is uninstalled?
Not possible.
When your app is uninstalled, the corresponding registration token tied to that specific app instance is also invalidated.
The registration token is what FCM uses to send messages to the corresponding device, if invalidated, FCM will no longer have any way to send messages to that device.

How do I send user to user notifications with Firebase programmatically?

The Firebase Console allows us to send notifications to single users, groups, users subscribed to topics or to the entire user base. Is there any code that allows us to directly send notifications in the same way, but programmatically?
For example, if I had a list of users (containing their Firebase UIDs), if I click on one of the users, could I send a notification to that user through Firebase the same way the console allows us to send a notification through the console?
This Firebase Blog uses the Google App Engine Flexible Environment to actually send the notifications, but it requires a free trial and costs money.
This Quickstart doesn't really show how to send user to user notifications. It focuses on the subscription-based notifications, but this isn't really what I need.
Is there any good way of doing this with Java/Kotlin and the Firebase API?
FCM doesn't support you sending message directly from Android app to Android app. However, this is a workaround to solve your problem:
Create a firebase cloud function. Listen a special path in firebase database
Android app 1 push a data (maybe Android app 2 ID) to this path
Firebase cloud function process data, determine who to send notification (Android app 2).
Firebase cloud function push notification to Android app 2.
ref: https://firebase.google.com/docs/functions/use-cases#notify_users_when_something_interesting_happens
In a basic concept: we write our server to get action from firebase database and decision to send notification to other user by FCM. This our server can write with NodeJS or using Firebase Cloud Function (above)
Guide how to using Nodejs is here: https://firebase.googleblog.com/2016/08/sending-notifications-between-android.html

android FCM enable/disable from application settings

I've implemented Firebase Cloud Messaging in my android app.
Is it possible to turn notifications off from my application settings screen?
It was possible with old GCM as we have broadcast GcmReceiver and we could handle it ourselves.
Now we have only FirebaseInstanceIdService and could handle it only when app is in foreground.
How we can handle it when app is in background?
Is it possible only to disable Firebase Cloud Messaging only for some category of notification inside app or this should be done on the server side?
You can manage whether or not notifications are displayed by always sending data messages from your app server. The Firebase console always sends notification messages, which are the types of messages that generate notifications automatically when your app is in the background. So if you want full control of when notifications are displayed use data messages which are only available from your app server, not yet from the Firebase console. See more on message types here.
I came with the solution to send request to the server if I need to switch on/off some type of notifications. And if send request to switch off some notification server will no longer trigger FCM server to send notification to the device

Categories

Resources