I'm manually handling firebase notifications by overriding the onHandle intent of the FirebaseMessagingService.
And using the intent I generate a notification.
Is there a way to manually report the notification opened to the Firebase at all because I'm not getting opened statistics reported back to the firebase console.
As above, even when letting firebase notifications get handled per normal, these open notifications are not being reported either.
Thanks!
The stats shown in the notifications panel of the Firebase console are only for messages sent from that notification panel. There is currently no way to trigger the stats for messages sent through the Firebase Cloud Messaging API directly.
Update: since late 2018 the Firebase now also reports messages sent through called to the Firebase Cloud Messaging API.
According to https://firebase.google.com/docs/cloud-messaging/understand-delivery only "Sends" work for data-only messages:
Sends — The data message or notification message has been enqueued for delivery or has been successfully passed to a third-party service like APNs for delivery. See lifetime of a message for more information.
Impressions (available only for notification messages on Android devices) — The display notification has been displayed on the device.
Opens — The user opened the notification message.
For those curious to know my workaround at this time.
We run push campaigns.
For each campaign we created a distinct, reusable event.
We register the event "campaign_received" and "campaign_opened"
When a message is received, we trigger the event.
When the notification is opened, we trigger the event.
Then, under each event, we just select the event, and file their stats per day, week, month, etc.
One needs to select the event to get to the event dashboard area, since the event list view shows the total amount of events sent and or received.
For bespoke notifications the 500 event limit might be reached quite quickly, so be sure to bundle your notifications into reusable event categories if possible.
Related
I've been working in bulk web push notifications, migrating from OneSignal to Firebase. I've created a single FCM topic to which all users are subscribed immediately on startup.
At first messages arrive on the browser and the notification is shown correctly, but randomly after a few hours and in some devices, notifications cease to show. I've been recording every push message received using DevTools, and noticed that the messages are being received but the push event not dispatched in those cases.
In which cases something like this may happen? It's worth noting that the service worker has been healthly with no errors whatsoever.
Thanks
A week ago I experimented with FCM console and sent push messages to my Android device. But after that many (thousands) of users started to receive pushes every day in 23 h. I suppose, this is because of time zone difference. When I look at Cloud Messaging Reports, I see it really sends data notifications. But I even don't have active campaigns (including planned campaigns). How can it be?
UPDATE
I've got answers from Firebase and AppMetrica (an alternative analytics service) support. They say it is possible the app is not able to handle the data message (silent notification) sent.
I saw charts in FCM Reports, showing that every day it delivers data messages. Every day it's count slowly raised.
I've got answers from Firebase and AppMetrica (https://appmetrica.yandex.ru/docs/). Firebase support didn't find a problem, but suspected silent push messages. AppMetrica support found a problem. AppMetrica uses FCM to send push messages. I wrote a code for integration of AppMetrica and FCM incorrectly, so silent pushes haven't been handled right. After I unselected a checkbox in settings that updated tokens via silent push messages, Firebase charts dropped to zero.
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
Let say user A subscribe event source push notification at device A at 10am and subscribe event source push at device B at 11am without unsubscribe. If my backend send the push message, both devices will receive the push message? I actually just want to send the message to the latest devices user have subscribed. Is there anyway to do this?
Like Idan suggested you can inspect push subscriptions in the database . Susbscriptions have an associated timestamp entry . With this you can determine the latest one for the user.
You can then use WL.Server.notifyDevice(userSubscription, device, options) or WL.Server.notifyDeviceSubscription(deviceSubscription, notificationOptions) to target a specific device.
If the user subscribed to two different event sources then yes, the user will receive notifications in both event sources...
There is no built-in mechanism that will prevent "duplicate" subscriptions (of the same user), so perhaps you could implement some sort of a cron job on your server to inspect the subscriptions table in the database and check that there are no duplicate subscriptions. If a duplicate subscription is found, delete the older one.
I'm developing an app using Firebase, in the app there are groups and for groups there are multiple members. I want to send notifications to members in a particular group based on one of the users activity. As an example in a chat app, notification to others informing there is a new message.
I referred this blog post. As it seems best way to do this is Firebase Topic Messaging, all members can be subscribed to the group id as a topic.
My matter is how to avoid receiving notification to the member who's action causes to the notification.
I tried Firebase message sending to multiple topics but it only allows for two logical operations (&&, ||)
Firebase Cloud Messaging has two types of messages: notification messages and data messages.
The default behavior of Firebase is that notification messages will automatically be displayed if the app is in the background or not running. This behavior cannot be modified. If the app is in the foreground, the notification message will not be automatically shown, it will instead be delivered to your app's code.
Data messages on the other hand will always be delivered to your app's code.
Since the user sending the message will typically have the app open, the default behavior will automatically ensure the notification is not shown on the sending user's device.
But in the blog post you refer to there is a race condition for this. If the user closes the app between the time they send the notification to the server and the time the server sends out the notification, the notification may show on their device too.
If this is a concern for your app, you should not use a notification message. Use a data message instead and include enough information in the message to detect which user has sent it (e.g. the user's uid).