What is the best way to send android notification - java

I am making an android app and I need to send notifications across devices. For example, A performs an action and B will be notified about the A's action.
I have also WebSocket with background services but the battery doesn't like..
What is the best practice to do this?
And whats about firebase?
Thank you

The best practice is to use Push Notification. Firebase provides an excellent support to implement Push Notification. Please refer this for more information:
https://firebase.google.com/docs/cloud-messaging/

Related

is it possible to make push notifications to all devices which had installed my application without Firebase Cloud Messaging (FCM)?

I want make a push notification when there is data insert to table of the database. I use REST API in android using retrofit. Could it possibly to make push notification every "insert" to all devices without firebase cloud messaging???
FCM is just a framework that allows you to send push notifications. I know that Samsung has their own framework that they use. And maybe there are others.
So, technically it's possible to create your own framework to do this, but I would never recommend it. There is so much to consider to get this done correctly (power use, security, registration of devices, etc. etc.) and using FCM is quite easy.

Android Push Notifications on Android Device that can not install Google Play Services

I have a Android Device that does not have Google Play Services on it and can not because it is not a certified device.
I am looking for a way to send Push Notifications to this device to wake it up and process an incoming message.
We have the ability to customize the Android BSP (ASOP) if there is any possible way to create our own custom Push Notification server to accomplish this?
Yes there is. Just the other day I had the same question. My scenario involved real time notifications though. Everything is updated in real time . and the idea of using web sockets came to me. And luckily I knew socket.io , luckily android had a native build with gradle. Consider researching into this concept.
Right off the bat. Features like back off time checks, back pressure and timeouts.

Implementing status update for android

I am developing an android application that is connected to a restful API.
There is a challenging situation that the user of the app changes a setting on the website that should be changed on the android app too...
but I don't know how to notify the android app about the recent change made on the server.
can you help me solve this problem?
I was thinking about a push notification. is it a good practice to do so?
thank you for your time...
One way is to use Google Cloud Messaging to send a push notification, another way is occasionally poll server for updates. Obviously first way is better because GCM batches that polling for all apps that use it => less battery drain etc.
In your case you probably also want to poll server for settings right before showing them in the app.

Notifications when the app is turned off

I wonder if it is possible to have notifications show up even if the app is turned off.
say for example I have an app and I set some kind of notification for 13.00 the next day and then turn the app off or restart my phone or something.
Is it possible to still get a notification in the notification bar with some text that starts the app or do the app need to run in the background to be able to use notifications?
if it is possible, what is the best way to do this? (get a notification at a certain time that starts the app) and if not, how do you recommend doing notifications?
The type of notifcations I want to do are reminder notifications.
thanks for all help!
A combination of AlarmManager and Service will help you to perform the task you are looking for, I had performed this thing.Check out the android tutorials for it.
What you're looking for is a background service. See this Android Services tutorial.
In the background service, your app should check periodically and when necessary, create and issue new notifications. See this Android Notifications tutorial.
The background service can be set to automatically start when the phone is restarted, and to re-issue any uncleared notification again.
Many apps such as Gmail already do this. Although you must be careful in resource usage or Android might kill your service.

Android - Code design of notification feature

I am working on an Android social app. It contains notification feature such as when A send a friend request to B, B should later get a notification icon shows 1 friend request on App bar (not a toast).
In order to know if the user has a friend request or not, the app will need to periodically send HTTP request to my backend API query for any notification. This should be performed in background. I am not sure what is a good way of implement such a feature. Should I use a Android Service? or should I spin a thread by myself? How to design and implement this to make sure it won't drain the data and battery? If I want to add a toast feature later, how should I design the whole client side notification system to make sure its easy to add the toast functionality?
Code pointers or suggestions will be greatly helpful. Thank you!
Periodically sending web-requests to check whether the user has any notifications or not is very expensive task for battery life.
Rather I suggest to use Push Notifications. There are third-party libraries available for this. Also recently Google Cloud has started Google Cloud Messaging for Android which is powerful framework to sync data between devices for specific app on certain events.
http://developer.android.com/google/gcm/index.html
Please follow the link above for more information to use Google Cloud Messaging for Android.
Also please have a look at following framework. It may of your interest.
https://parse.com/tutorials/android-push-notifications
sending web-requests periodically is even more expensive task (for battery) when the internet is not available in the device.

Categories

Resources