Showing notification from server directly in app - android

Android push notification show notification in title bar.But i want notification to be directly shown in the app if the app is opened.For example in driving apps when customer request for cabs, notification is directly shown in the driver app which is opened.Driver don't need to refresh the app or click on any link.How can i do that?Should i use push notification only?

Its upto you how you want to use the data you get from the GCM.In a typical case you get the data from the GCM server which invoke your Broadcast receiver and which starts the service where you parse the data and then create a notification and show it.If you don't want to create a notification just parse the data and populate the view and show it wherever you want in the current activity or somewhere else.Its entirely upto you how you want to implement it,there are many ways to implement it

Related

How to control whether to display notification or not based on the screen that is being displayed in android studio?

I am making a chat application and I am using Firebase Cloud Messaging to send push notifications. Everything is working fine but I do not want to display notification if the app is already in chat screen. I am using jetpack compose for UI and have single-activity architecture.
So in my chat screen, I don't want to display the notification. However, if the user is at other screens, I want to display the notification.
How can I achieve this?
There can be two possible solutions
Declare boolean in Activity or SharedPreference and toggle value according to lifecycle event's.
Once you receive firebase notification send broadcast and listen in activity. Inside activity identify top most visible screen using navController like below and decide wheather to show notification or not.
val visibleScreenRoute = parentNavController.currentBackStackEntry?.destination?.route?.split(Constants.KEY_QUESTION_MARK)?.getOrNull(0)
Hope this will help you to solve the issue.
I have the same case as you.
First, you need to create a custom notification and control push notifications manually.
Second, you have a module which checks whether activity is displaying or not.
Finally, when you receive notification data from firebase, using above module to decide display notification or not.
Check this document for more details : Build Notification

Access notification log data

I wanted to know how can I access the data which comes with our notification in notification log. Like I just want to know which app sent the notification, if the user opened that notification or not and when the notification arrived. I want to use these data in my app to process these data items and display it on my android app.
Please help.

notification click event, best way to show activity data from service while app is closed android

i have made an app where i made a unbound service that is continuously requesting to server api, if server send json then notification will show and on notification click i take the user to one activity to show some data. everything working well while apps is opened or background. but when the app is closed, notification showing but when on notification click trigger to specific activity, there is no data showing(data should come through a server req).
what is the best way to do this?

Show only notification with multi application when call push from server

I created two applications and installed them on a device. Both apps have the same notification id. Whenever I send a push notification from my service, two notification show up.
I want to show only one notification (instead of displaying the same notification twice). Can I do it? If so then how can I do it?
You can use a shared preferences between the two apps and write a value when some app show the notification. Then just before to show it you should check the shared preferences to know if the other application has shown the notification or not. Even you can add delay in one of the applications giving preference to the other one.

Notification service in Android

I'm developing an Android application, i have created one activity that show different messages (like a bacheca) in a listview.
To do this i get data from a database on a server, what that i must do is
notify the user when a new information is inserted into the database.
Basically I want to pop up a notification on the screen (like when he gets a text message on whatsapp ), when the user presses on the notification initiates the activity containing the news ( bulletin board).
I would like to create a function like that of Facebook, ( I suppose a service ) that monitors the db and when you notice that there is a question notification starts.
How i can do this ?
Use GCM push notification Check this tutorial.
The thing you are talking about is called Push Notification Service. There are many such service providers. One obvious here is Google's GCM. You can also look into Amazon SNS. https://aws.amazon.com/sns/

Categories

Resources