Androidx NotificationCompat vs Firebase Cloud Messaging - android

I am developing a mobile application which requires a push notification to notify the user when a certain condition is met. I am new to this and I discovered multiple ways to implement a push notification.
However, I am unsure of which one is best to be implemented. I am new to mobile app development so I am unsure of how to differ both of them.
From my understanding, androidx NotificationCompat is easier to be used but my SV suggests me to use Firebase Cloud Messaging instead.

Short answer:
NotificationCompat is the helper class for the developer to access in android.app.Notification.
Firebase Cloud Message(FCM) is a cross-platform messaging solution that lets you reliably send messages at no cost.
I can't help you make a final decision, I just list the positive and negative options of them, hope can help you.
For FCM
To notify the end-user of the new message which you want them to know(eg. bouns/upgrade, even though the cycling message at 18:30 every day, etc).
Help the developer to track the lifecycle of the notification(how many were opened? how many were canceled, etc..)
Help the developer to Customize the Notification Styles, and can also preview them in the console of the FCM.
Can also implement your own background and send your customized message to the background center of the FCM with XMPP
Can also send message to the part of the user
With some topic(eg: send message to the user who enters some page or use some function)
With some age(eg: send message to the user who ages between 29 and 25 years old)
For NotificationCompact
use for local, hard control from your backend.
others...

Related

Not sure how to design in app notifications from interactions (likes, share, etc...)

I am developing an Android application in Kotlin that can be thought of as similar to Instagram.
I am designing how to implement my in-app notifications. By "in-app notifications" I mean interactions such as likes, publication sharing, new chat message, etc.
For the moment, I do want foreground notifications. The notifications would not involve any view component.
The proposed flow would be:
Interaction action from Client_1 (like, share, message) triggers an Event_A in the server.
Event_A produces a state change and generates a notification to Client_2.
Client_2 receives the notification
a. Display a badge in the notification icon bar.
b. Generates a new item in the notifications list when Client_2 open it.
I make this clarification because, while searching this, I've seen "in-app notifications" are related to campaigns, publicity, new features, etc.
So far, I though two possible implementations but not sure if they are the right ones.
1 - Web Sockets
My app already uses Web Sockets for handling chat messages. However, so far, the connection is only open when the user enters to the chat view.
I consider easy to implement but this implies having an open connection the entire time the user is on the app and may be an unnecessary load for the server and an increment on Web Socket's time session.
2 - SNS + FCM
I've found that AWS SNS and FCM (Firebase Cloud Messaging) is a common approach for handling notifications.
However, reading the Firebase's documentation and examples, I understand it's mostly used for the other kind of in-apps notifications (campaigns, publicity, new features, etc).
In this FCM's documentation, it defines two types of messages: Notification Messages and Data Messages. I understand, Data Messages would be more appropiate for my use case.
Don't know it is worth the complexity of configuring FCM and handling the token's lifecycle.
So, my questions are:
Are the above scenarios good approaches? Is there any other way to achieve this?
Which is the correct term for this kind of notifications?
FCM is just normal push messaging. It can be used for any type of data. It's just a general method for a server to push data to an app, even if the app isn't running at the moment. So it's the right answer. The problem with web sockets is it won't work if your app is shut down either by the user or by the system.

Disable firebase cloud messaging from going to tray via Cloud Messaging

I've researched this topic for a little while, but I can't seem to get it. Apparently Google hasn't made an UI for this is what I understand. So here's the question.
I like to send cloud messages to my app users (100k+) occasionally. The users have an option to turn these notifications off which works fine if the app is in foreground.
But for background, Firebase does not give me any way of handling this. The message will always go to the tray even a user has disabled it inside the app. Understandably the notification never makes it to the app.
I've read responses from people that we should send such messages directly from our own servers. Yes, I've got my own servers and I do send a lot of messages to my users directly from the server. I maintain a database of all fcm codes.
But I'm wondering if there's a way of achieving this through the firebase console. It's nice to have all messages in once place e.g. ios and android. Google will also show us statistics which are also important in analysing which notifications are working better.
I've seen a possible answer here, How can I disable firebase notification on android client app, but it looks very unconventional.
Any help would be appreciated.
to disable notifications just must add
FirebaseMessaging.getInstance (). UnsubscribeFromTopic ("Topic_Name");
Note: these must be previously subscribed to the Topic
to enable notifications again use this
FirebaseMessaging.getInstance (). SubscribeToTopic ("Topic_Name");

Sending notification from one app client to another

I am developing an Android app, which deals with allocating orders to multiple suppliers. Each supplier will have the same Android app installed. Every day, the in charge of the suppliers will open the app, pick up the suppliers to assign from the recyclerview and enter a customised message on the days' supply in an editText.
The message should be delivered in form of push notification to other suppliers he has selected from the recyclerview. So, in this case I cannot use Firebase console to send notifications. I initially thought of using Twilio to do this. But my client wanted to keep this as last option. They want me to try Push notifications.
I am researching, but every one is illustrating on how the notification can be sent through Firebase console. I also heard that GCM is obsolete now.
Please can anyone give me some pointers on how this can be done? Please note that I am a beginner in Android.
I think you can use firebase cloud messaging to achieve this. See FCM documentation.
You can send a push notification through firebase by using firebase HTTP protocol instead of the firebase console. In this way, you can programmatically send a push notification by making a REST call.
There are 2 firebase HTTP protocols that you may use to achieve this:
Legacy protocol:
This is the older firebase HTTP protocol. This is easier to set up and you can find a lot of material online explaining how to use this like medium article.
New protocol(HTTP V1):
This is the newer HTTP protocol. This is a little more difficult as authentication is done by oAuth token. However, this is more secure and extensible. Also, it seems like firebase might eventually deprecate the legacy API.
Hence, in your app, once the in charge of suppliers assigns the duties, you can call the firebase APIs to send out push notifications to all the assigned suppliers.

Having Some issues with google cloud messaging api for android

I am new to gcm api for android and have for some time now i have being working on an android app to allow chatting between two users of the app. The app is such that a chat can only be initiated when one user opts to contact the other user. But my confusion comes in the manner i would be able to create a chatroom for these two users and for the other user to be able receive messages. since i found out that each user must subscribe to a topic inorder to receive messages in that topic. Would i have to subscribe all users to all possible topics or what? that is my big question but it seems it would have so much overhead considering i have 1000+ users.
Please i need all the help i can get here. Thanks
Would i have to subscribe all users to all possible topics or what?
GCM topic messaging allows your app server to send a message to multiple devices that have opted in to a particular topic.
It is not a requirement but it can ease the work for the server to send messages. In this tutorial, you will see that they have created a chat like environment using GCM without using the topic function.
BUT consider the effects on your server like how will it behave on the potential load when you use the topic messaging, especially the the message will trigger an interaction from the user to the server.

In-App messaging vs Push Messages: Pros and Cons

I am finding difficulty to know about in-App messaging.
And how to do it.
I have the following things in my mind,
in-App messaging:
Is an idea to receive contents from a server only the app is alive on screen.
This is possible only the app is active.
App should make a call to server and needs to receive contents.
Push messages
Is an idea to receive contents from a server even though the app is not active.
This is possible at any time, we can notify users while our app is closed and running also.
App do not need to make a call.
But the app should have code implemented to receive push notifications.
We can use GCM for Android and Push Notification for iOS.
Am i right with my understandings ?
If i am not and i missed something , please give your hand to take me out of this confusion.
Thanks,
When I think of in-app messaging, to me it means that you're sending a message from one part of your app to another. "Sending a message" is a very generic term that can be accomplished in a number of different ways. Among others:
Sending a broadcast to a message receiver. You'll need to call sendBroadcast to a BroadcastReceiver.
You can pass a Handler to another component and it can post messages to your handler where they're processed
You can use a third party library such as the open source "otto" library
You can build your own version using the observer pattern.
For push messages, your understanding seems about right. However, look at this post for details on the last item, "We can use GCM for Android and Push Notification for iOS".
You are right, though I would change the term in-App Messaging to Pull Messages, since you are referring to the app pulling messages from the server, while in-App Messaging implies that the application is sending the messages.
You points are mostly correct, though Pull Messages does not require the app to be in the foreground (on screen) - a part of your app can run in the background and fetch messages from the server. This is more doable on Android, since iOS limits the operation an app can do in the background.
Another point that should be added to your list is that Push messages also have the advantage of conserving battery life.
In-App Messaging can also be viewed from another standpoint. AT&T has an API for In-App messaging that allows you to send SMS cross carrier. The API can be found here. along with others. From this you can imagine the ability to message from within an app, say a game or a social app and retrieve responses. There are examples for all the platforms you have added as tags. It might be good for you to look this over as it can expand your understanding of the concept in a different direction than the other answers, Somewhere in all of these you will find what you are looking for.

Categories

Resources