Pretty much the title. I have the app register the device to receive push notifications when it runs, I need to unregister the device when it uninstalls. How to?
I guess you write about uninstall in the meaning of deleting the app from the device?
Unregistering from GCM on the device-side may take several minutes and therefor probably can not be done on uninstall, see answers here.
Your server should just stop sending push notifications. If he tries GCM returns an NotRegistered-error, see the docs here.
If you're using Appcelerator services for notifications then the error comes from their servers.
Related
Firebase push does not work on some devices when app is closed with only data payload. See this thread: https://github.com/firebase/quickstart-android/issues/41
I know when app is killed by swipe then some OEM kill all the services of the app which directly effect FirebbaseMessagingService and due to this onMessageReceived() method never invoked. I have also tried with high priority FCM but sadly no success. Here are the phones on which I am facing an issue: OnePlus, Lenovo, Huawei.
Currently, I am testing with OnePlus 5, when I change the battery setting to "Don't Optimise" then push notification started working.
I killed the app and run dumpsys package MY-PACKAGE | grep stopped command and I found that app is not stopped. It shows stopped=false. It means app is running.
The concept of push notification is to notify users when app is closed but currently, we are unable to do.
Any suggestion how can I fix this?
FirebaseMessagingService can receive PushNotification even when app is closed/killed.
But there are some problems in the way. The behavior of the apps changes between development and production, and because of the device provider.
The first thing you have to consider, is when the app is in development, if you force close the app (kill-process), FirebaseMessagingService stop being triggered. But this doesn't happen in production, so don't be aware of this if your APK is signed. link to source
The second thing, is that there some Android phone providers that manage processes by them selfs. We can see an example like Huawei phones and their "Protected applications", which make user decide if want to protect the app or not. Only famous apps are protected on installation like WhatApp or Twitter... link to source
At this point, your FirebaseMessagingService should be triggered, but there are other problems related with memory and processes managed by system (OS). Your Service can be canceled because of the time that it's spending to handle the PushNotification. You can find many ways to handle this problem, but the best way, is Firebase JobDispatcher. link to source
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 have an Android application where, among other things, I want to know how many installs are successfully answering to my push.
For example:
According to my database, 1000 people installed my app. After that, I send a push notification to all of them and google returns something like this:
{"multicast_id":fakeidblabla,"success":581,"failure":419,"canonical_ids":0,"results":[{"error":"NotRegistered"},{"message_id":"0:fakeidblabla"},{"error":"NotRegistered"},{"message_id":"0:fakeidblabla"},....]
What I want to really know is.. what does that "success":581 mean?
Does it mean that those 581 are fully functional apps that are still running and that haven't been uninstalled?
Because I have a system that returns an OK everytime an install receives a push notification, so I should receive exactly 581 OK's but I don't. I receive less OK's.
Is my control system not working properly or maybe that "success":581 doesn't mean that those installs are fully functional and still running?
Thanks a lot!
From the documentation:
success: Number of messages that were processed without an error.
So, the success parameter means the number of messages successfully proccessed by GCM, not received by the devices.
I am creating a app in android 4.0.3 i.e ICS version, which connects to the server when client gets login into the app.I am trying to get status of an client when he gets online or offline through server & seen onto the app screen.I am unable to proceed. Can anyone say me:
Is it possible to get the status of an user through server?
1-- How to proceed for first step...?
2-- How should I get a response from the server that the client is connected & viewed to other client example - when we login into skype our status shows available with green radio button, In same way how can I get it.?
It ll be very help full, If anybody guide me.
Many Thanks..
I'm assuming you're trying to develop a chat app ?
If this is the case, try using an XMPP library. XMPP is widely used for chat apps, including Facebook chat (and Google talk I think) and there are plenty of open source libraries available.
Otherwise, if you only want real-time notifications as a part of a bigger picture, try using push notifications. Google supports Cloud to Device Messaging (C2DM) for android. It allows to have push notifications to a specific device without you having to deal with persistent connections, battery and CPU use .etc.
C2DM approach comes down to this. When a client connects to your server, get a list of his friends and their 'C2DM IDs' and fire a C2DM push to their devices. This push is delivered to your app, and you can respond to it by firing a notification, or update UI .etc. (Your app doesn't necessarily have to be running. Push notification is delivered via a specific broadcast, and your app can register a receiver for it to wake up.)
Keep in mind that there is a quota for C2DM messages per device, per app and also a limit for the payload per message. So you're not supposed to send massive files via this. Just a notification to your app, so it can call your server and get an updated list, instead of polling.
You can get more info on C2DM and code samples here. https://developers.google.com/android/c2dm/
Hope this helps.
You may have moved on, but I'm posting for anyone who would run into this one in the future.
Firebase is a good solution to use in this scenario, if the app is always running when you want communication to happen. (It will not wake up your app as C2DM/CDM does, unless you have a service running all the time and still wouldn't wake up if the device is asleep... AFAIK)
It may be useful for some scenarios, but may be not for a chat app as you want the device to wake up when a message arrives.
Note that they have limitations on the free subscription though.
Problem Description:
We have a service which has applications for main mobile OS’s. We use push notifications. When user is log in, we store his device authorization data (lets say token) for later use in the push service. The problem is about few device authorizations for one user and properly keeping them valid when the user uninstall the application.
Example:
I gave my login to system to a few people, in case to try it. They logged in through the mob. application and the system automatically add a few device authorizations into database (tokens). So now we have N device tokens for 1 user. So that if we send push notification everyone will receive it. Now, suppose those who have installed applications want to uninstall it. Without logout they uninstall application through application manager. And at this time we have NOT VALID data for authorized device. And if we try to notify them, notification will be sent nowhere. Which is wrong, and useless work for server. How to let the core know that some of stored data is no longer valid?
Shortly – is there any possibility in Android / iOS to trigger application delete event. If the application is being delete application call server to clean-up data in the storage. Or if the application is open and the user uninstall it, would there onDestroy() trigger fired? Or some other?
I’m not iOS developer, not Android developer, just know a little about second one and nothing of the first. Any advice will be appreciated. Thanks in advance.
I cannot speak for iOS. You cannot get control when your application is uninstalled in Android.
That depends on which push service you are using. Afaik, if you are using C2DM, the act of uninstalling the application will automatically unregister it from C2DM.
Edit:
Oh, and about iOS - afaik it does not directly track uninstalled apps, it does however come with a failed notification feedback service that after a sequence of failed notifications (reported by the device to the push network) will notify you - allowing you to clean up after an uninstalled app.