android FCM enable/disable from application settings - android

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

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.

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.

Firebase cloud messaging: Possible to send Data messages when permission = blocked?

I'm trying to implement a messaging sub system in a multi platform app for web and mobile using Firebase Cloud Messaging (FCM). FCM allows you to send messages in two formats: Notifications and Data.
Notifications are shown by the platform, eg. in a little popup on the web platform or added to a list of notifications on your mobile phone.
Data messages are handled by your application.
Before the app can receive messages, you have to ask the user for permission to send/receive notifications.
Now, when the user blocks notifications, data messages seem to be blocked as well. Am i missing something, or is this by design?
In the context of iOS, permissions are only needed to show push notifications in the notification center.
UIApplication.shared.registerForRemoteNotifications() will allow you to retrieve the device token, but will not present a permission alert. At this point, you can receive push notifications, but you won't see them unless you print them out in didReceiveRemoteNotification, or in the case of Firebase data messages, didReceive remoteMessage.
In order to show notifications outside of the app, you would need to call UIApplication.shared.registerUserNotificationSettings(settings) which will present a permission alert.

User action for send oush notifications in firebase on 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

Firebase Cloud Messaging Android receive silent push notifications

I am trying to migrate to Firebase cloud messaging from GCM and I noticed that when the application is not running the notifications are coming in the notifications tray. With GCM this was not the case, it was up to the developer to show a notification or not. I want to have similar behavior with FCM where when the app is running I want to silently handle the push message instead of having user to click on the notification and start the app. How can I achieve that.
Thanks,
P
Firebase Cloud Messages has two types of messages:
Notification Message: this type of message has the same behavior as the GCM messages
FCM automatically displays the message to end-user devices on behalf of the client app. Notification messages have a predefined set of user-visible keys
Data Message: this type has the behavior you described above.
Client app is responsible for processing data messages.
Data messages have only custom key-value pairs.
To send data messages you need to use the HTTP API [for Data Message]. (quoted from Arthur)
Full documentation: https://firebase.google.com/docs/cloud-messaging/concept-options

Categories

Resources