Firebase Cloud Messaging - Identify delivery status for a particular push notification message - push-notification

Is it possible to identify whether a particular push notification message was delivered to a particular token via Firebase Cloud Messaging? And, if so, is it possible to do so via an API call or by listening to some callback?
I know that I can look at aggregate statistics in the console and even segment those statistics through analytics tags, but cannot find a way to get more discrete information.
I also know that the API will synchronously respond if a token is invalid but the process by which Apple and Google invalidate tokens is a bit opaque (to me) and doesn't help if someone simply turned off push notifications for my app.
Thanks!
Jason

If someone turned off push notification – you can check it with code
Swift ios check if remote push notifications are enabled in ios9 and ios10
Android app - detect if app push notification is off
But user can be offline, or APNs / Firebase service – can get some problems and your notification will be drop. You can check delivery status with some code in iOS and Android applications.
If you need check, delivery status for some push you can make push notification extension (in iOS). For send status about delivered notification in your API. More info about push notification extension.
https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension
It can be helpful
https://developer.apple.com/documentation/usernotifications
https://developer.apple.com/documentation/usernotifications/modifying_content_in_newly_delivered_notifications
https://firebase.google.com/docs/cloud-messaging/understand-delivery
https://firebase.google.com/docs/cloud-messaging/android/receive#handling_messages About handling messages in Android (you can send status delivered too)
I hope this answer will help with your problem.
UPD:
https://firebase.google.com/docs/cloud-messaging/understand-delivery
Received (available only on Android devices) — The data message or
notification message has been received by the app. This data is
available when the receiving Android device has FCM SDK 18.0.1 or
higher installed.

Related

React native app sending push notification while device is offline

I'm about to develop an app similar to a birthday reminder and I plan to use firebase for push notifications but what makes me second question my choice is whether users will be able to receive a birthday notification if they are offline(not connected to internet for the whole birthday day). I know firebase has some offline persistence support but I'm not sure if this includes push notifications support. Are there any options to achieve that with firebase or with any other tool compatible with react native?
If the device is not connected to the internet, it is going to be impossible to deliver messages to it through Firebase Cloud Messaging or other internet protocols.
The common way to deal with such a scenario is to deliver the message to the device when the user does have an internet connection, and then only display it once it's the right time. By sending a data-only message through FCM, your application code controls exactly what happens with the message data.
There are essentially two types of notifications: in app messaging and cloud messaging. Both are offered by Firebase: In App Messaging and FCM (Firebase Cloud Messaging).
The details you've given about your app is a little bit vague but if you're asking for push notifications, then FCM does the job. FCM will send notification when the app is on background or killed (exited out). When you say device is offline I'm assuming you mean when the user isn't using the phone. Yes, the notification will still come.
https://firebase.google.com/docs/cloud-messaging

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.

Firebase Push Notification Internationally

I was able to integrate Firebase Push Notification into my android/ios app. My apps started getting international users and my question is Firebase Push Notification still works fine for them?
Is there anything i need to do to support Firebase Push Notification internationally?
No extra implementation needed. The notifications target the devices. So long as the device meet the pre-requisite to receive a message (just a stable connection) then it should be able to receive the sent notifications.

How to View Firebase Notification Delivery Reports?

We use Firebase to send push notifications to both Android and iOS devices. We use Http (not XMPP).
How to get delivery reports for push notifications? We want to check if a push is delivered to devices (both Android and iOS).
I cannot see any stats or reports in Firebase console.
Please help.
As seen in the Possible Duplicate Post I linked, there is currently no available reports for FCM, other than what can be seen in the Firebase Console (if you sent the message using the console) and using the Diagnostics/Statistics tool in your Play Dev Console.
There is no API that retrieves these FCM log details as of the moment. However, there's been a recent improvement in the Firebase Notifications console where stats (sent count only for now) for messages sent using the FCM API is included in the Firebase Notification console stats. From my answer in the similar post:
As of August 2018, stats for messages sent using the FCM API are now visible from the console. From the Cloud Messaging section, click on the Reports tab. From there, you will be able to filter by message type (notification, data, and all)
It would seem that the Impressions and Opens are still only available for messages sent using the console. But Sends for sure now counts the messages sent using the FCM API.
Reference: https://firebase.googleblog.com/2018/08/in-app-messaging-crashlytics.html
Our findings: In order to view statistics for Data messages, the data messages will need to include an analytics label. Check to make sure that these are included. It is just a label, https://firebase.google.com/docs/cloud-messaging/understand-delivery#adding-analytics-labels-to-messages so even without the analytics label, the message should still be sent. It just won't be tracked by their reporting. Data messages do not automatically generate a notification though. Different app states and message types will have different message receiving behavior. A data message should be received in onMessage or setBackgroundMessageHandler for JavaScript clients. Try checking these callbacks to see if the message is received there. I'd highly recommend checking out the quickstart, which should be working fine. You can use it as a base to build off or reference to compare with your app to identify potential problem areas. So our understanding is that it needs to be handled properly on the mobile end, https://firebase.google.com/docs/cloud-messaging/js/receive (though this is the javascript client, it will still apply to mobile).
You can rather go to the Google cloud console to check messages sent.
Select period from available options on top right of the page.
https://console.cloud.google.com/apis/dashboard?folder=&organizationId=&project=[project-name]
The delivery report added to the FCM:
Received (available only on Android devices) — The data message or notification message has been received by the app. This data is available when the receiving Android device has FCM SDK 18.0.1 or higher installed.
https://firebase.google.com/docs/cloud-messaging/understand-delivery#message-delivery-reports

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!

Resources