How to distinguish uninstalled apps as a result of sending from Firebase Cloud Messaging (FCM)? - firebase

In my app, the FCM token is sent to the server immediately after issuance.
The server receives the client FCM token, stores it, and sends a message to the FCM token for the client when needed.
However, on iOS devices, even if the client uninstalled the app, the result of sending on the server is showed as a success.
(For Android devices, failure(NotRegistered) is received. this is the ideal result.)
{
"multicast_id":****************,
"success":1,
"failure":0,
"canonical_ids":0,
"results":[
{
"message_id":"0:**********************"
}
]
}
Can you explain why the result on the sever showed that the sending FCM tokens was succeded even when the client uninstalled the apps?
As showed on the following document, it says "failure" with the result "NotRegiestered".
Is this only for Android?
So, how can I get these results on iOS?
https://firebase.google.com/docs/cloud-messaging/concept-options#lifetime
Finally, when FCM attempts to deliver a message to the device and the app was uninstalled, FCM discards that message right away and invalidates the registration token. Future attempts to send a message to that device results in a NotRegistered error.
Can you tell me how to get the result as "failure" like in Android when sending the token to client who uninstalled the apps?
To classify the client that uninstalled the app, i should get the result of failure(NotRegistered) like Android.
[The same issues]
FCM detect app uninstall on IOS (firebase cloud messaging push notifications)
https://developer.apple.com/forums/thread/88332

Related

Cloud Messaging of Flutter - Can't send message any device with token

when I want to send test message with token from firebase console, it works very well in debug mode. But in release mode, I cannot send a message to the device with token. Anyone having problems with this?

Can my phone receive Firebase push notification if I have installed an app that support it but I have never open it before

Do I need to open the app at least once in order for my phone to receive a push notification?
The must run at least once so it can collect a device ID token and send that to the backend that will send the message. Without that token collected, the app can never receive a message on that device.
Read more about it: What is FCM token in Firebase?
Actually you do not need the device token to send/receive the messages.
However, it is required that the user give permission to receive notifications, and that would only happen during runtime. I tested this and can confirm it works. The device token is only used to subscribe users to specific topics, but you can send a message to all users that have your app installed without needing to specify device tokens.

Firebase Cloud Messaging returns 200 OK for token that has unsubscribed

We use the Firebase Java SDK (com.google.firebase:firebase-admin) to send Push Notifications to iOS and Android devices.
We can successfully construct a notification, and send it to a device using the registered FCM token.
On such a device, we opened System Settings, and disabled push notification for the application.
We sent a new notification using FCM, and it did not appear on the device - as expected.
However, we now expect that the Firebase API should throw an Exception, because the FCM token is no longer valid / has been revoked.
We figured it may be cached for a while, but it has now been over 24 hours. We need to be able to fallback to other delivery methods if push has been disabled on a device.
Why does FCM still return 200 OK?
Disabling notifications for the application does not automatically unregister that application with Firebase Cloud Messaging. If you re-enable notifications to that application, the OS will happily deliver notifications again, and it will (as far as I know) continue to use the same token.

Accessing FCM message logs

I'm having trouble figuring out whether or not FCM keeps logs of sent FCM push notifications, and if so, how to access them. I'm having intermittent issues with sending push notifications from an FCM server to an iphone app, and would love to be able to see at what stage the push is failing.
I found the below documentation that suggests that these logs should be kept somewhere:
https://support.google.com/googleplay/android-developer/answer/2663268?hl=en
("You can look up messages sent through Firebase Cloud Messaging with a registration token or message ID.")
However, I can't seem to figure out how to access them. Since my app is currently iOS only, I don't have an app in the Google Play Developer console, and my firebase console doesn't seem to contain any such logs. However, based on the possible message statuses in the documentation above (e.g. Accepted, sent to APNS), it seems like google / firebase should store message logs sent to iOS as well as to Android.
Thanks in advance for your help!

GCM: Message sent on a topic does not reach the browser

My setup include a webapp, a backend server and an android app.
I want to be able to chat between my android app and webapp.
Init:
Android app has subscribed to the topic /topics/chatGroupName
Similarly on browser, I get the registrationToken and send it to my server where I use code similar in https://github.com/ToothlessGear/node-gcm/pull/211/files (addToTopicNoRetry) to subscribe the browser to the topic: /topics/chatGroupName
When I send a message from the web, I use my backend server to send a GCM message on a topic like /topics/chatGroupName and the android app receives this message.
But when I send GCM message from Android app on this topic /topics/chatGroupName, I dont get any notification on the browser app.
Even my https://iid.googleapis.com/iid/info/REGISTRATION_TOKEN?details=true shows that this registration token has already subscribed to /topics/chatGroupName
Firebase has now released javascript library that supports FCM push notifications with support for topics.
Ref: https://firebase.google.com/docs/cloud-messaging/js/client

Resources