It is necessary that even after the application is completely turned off by the user, notifications come from the node server. Tried to do through Broadcastreceiver and Service, but they only output if the app is in the background. I'm considering The firebase messages option, but I can't fully understand if it will work when the application is completely turned off. If there are options as it is possible to make it on another, prompt, please, in what direction to go.
When the user did not force stop(Settings -> app -> Force stop) the app, FCM will work.
It means, Firebase Cloud Messaging will work after user close the app
normally
Related
I want to know how to ensure your app stays alive, without the persistent notification method.
The most common solution I see is to have a sticky notification permanently on, which will keep the app alive.
But how do email apps do it? Outlook and Gmail and K9 don't have a notification permanently at the top of the screen, so there must be another way?
So far I have tried START_STICKY, and I've tried disabling battery optimisation on the app, but overnight it will still get killed for some reason, yet I can see apps like Outlook have been running for several days without me even having to open them.
How do email apps keep alive in the background?
They don't.
I want to know how to ensure your app stays alive, without the persistent notification method.
Create your own custom firmware build of Android and install that on your own hardware.
Outlook and Gmail and K9 don't have a notification permanently at the top of the screen, so there must be another way?
Yes: they let their processes terminate.
Outlook and Gmail could use Firebase Cloud Messaging (FCM) to restart their processes if/when needed for incoming messages. K9 uses WorkManager to poll mail servers periodically. Neither require continuously-running processes.
Also bear in mind that apps that are pre-installed, are from Google, or are from the device manufacturer do not have to play by the same rules that apps from developers like you and me have to.
I have the next doubt:
I am working on an app that needs to start a foreground service. I know that since Android O, you need to attach a notification to that foreground service. So far so good.
The question is: what happens if the user disables that notification from settings? I have been testing the app and everything seems to work, but I wanted to double check on internet and I couldn't find anything.
Should I force the user to have notifications enabled if he/she wants that feature (which needs the foreground service)?
Does anyone have some insights on it?
Yes, it is best practice to ask the user to enable notification services.
Nowadays most app does this exercise to show a notification to users. Even in some special manufacturer like MIUI it is compulsory to start notification service from setting. So many app shows prompt for same and on positive click they navigate the user to setting screen too
I'm testing Firebase Push notifications, sending a notification from the Firebase composer panel, and I noticed that if I close the app process from App Information panel, the push notifications sent doesn't reach the device. Even if I start again the app the notification is lost and is never received.
I also tryed this:
close the app process -> shut down the device -> power on the device -> send a notification... and the notification is not received!
It seems that firebase can only receive notifications if the device has the app started and not 100% closed, I mean, closing it just with back key but not killing the app process.
How is this possible? It is supossed that firebase should receive notifications even with the app closed.
I'm testing on a Nexus 5X with Android 8.0 and I'm using the last version of Firebase push Notifications.
Sorry for the late, but hope this help next users that will have this problem because there is no answer selected as "Solution".
When setup correctly the service, this will work even the app is closed. That because, Firebase Messages travel by Google Play Services so closing your app doesn't have a relation with the service.
At first, notification never came. By searching in the device settings I saw that the energy saving system for my app was active (when closed was removed from stack) so notification was sent but my app couldn't take and display these.
After disabling that option, I've test many time and I found that sometimes notification come with a late of 2-3 minutes when app is completely closed. Sometimes it touch the 5 minutes. You need to be patient and it will come!
Instead, When app is opened or closed simply by back button, notification come in few seconds.
In your AndroidManifest.xml file remove android:exported=false from your Messaging service.
Explanation: When your app is completely killed or removed from back stack. OS tries to restart the messaging service but if there is android:exported=false in your manifest file then OS will not able to restart the service because such service can only be restarted by the same app.
Reference: https://developer.android.com/guide/topics/manifest/service-element#exported
It seems that firebase can only receive notifications if the device
has the app started and not 100% closed, I mean, closing it just with
back key but not killing the app process.
No, FCMs are sent to all the devices that have Google Play services and the targeted application. That is why it is called Push Notifications.
Your application also get notifications when it is running, to handle those you need to override
onMessageRecieved(RemoteMessage mes);
There could be many reasons for the app not getting notifications. Some of them could be :
Messaging Services not included in the Manifest
Play services not configured correctly. Or not present in the Phone.
Sometimes Latency is High (rarely). I noticed it sometimes take take about 2-3 minutes
after composing.
SHA1 fingerprint not registered in Console and/or updated google-services.json not present in sources.
Uninstall and reinstall the app. So that token Regeneration may take place.
Please follow this link to get started with messaging.
https://firebase.google.com/docs/cloud-messaging/android/client
Have you added firebase services on Java code?
Here is the link: firebase/quickstart-android
You have to add those 3 java file in java folder and also add those service name in AndroidManifest.xml
if you are sending it from your firebase console it sends a notification message so those you will not get if your app is closed, you need to send messages that have the data payload which the console does not do.
https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages
Took this screenshot from Firebase documentation, seems its not possible with FCM
I am developing a IOS/android app which will used by our vendors, the app will send notifications to the vendors timely, i wonder if there is a way that the vendor MUST click "accept" or "read" for every notification, even he/she disable the notification permission for this app.
so, all of my perpose is the vendor must ready the notification and the server side should be able to know who is not read. the vendors should not has an execuse that he/she do not get a notice while the policy changed.
There is no way to 'force' a user to open a notification, but if you use a Push Notification service (AppBoy, etc) most of them have metrics and can track who has opened the notifications. So if your vendor comes back and says they never got it, you can say yes you did, and which device they opened it on. You could then continually send notifications to those who haven't opened it until they do.
This won't work if they have notifications disabled, though. No way to get past that without building a messaging system into your app.
I have used GCM to get push notifications, now if I Force stop the app from the settings on the Android device, will it be able to get push notifications?
I have read many posts that say in this case an app cannot receive notifications.
Is there any possibility to get notifications?
Once you force-stop your app from Settings, your code will not run until something manually runs one of your components (ie the user manually launches an activity).
Therefore after force-stopping your app from Settings, you will not receive GCM messages.
If you want to get notifications you have to manually restart your app.
This is by design since Android 3.1.
Apps that are in the stopped state do not receive broadcast Intents.
Stopped state is:
when the app is initially installed (before the user runs something in
the app) or
after a Force Stop.
You can find more about this here: http://developer.android.com/about/versions/android-3.1.html#launchcontrols