Track Firebase notification for iOS - ios

Is there any way to see number of successfully sent and failed push notifications in Firebase Cloud Messaging (FCM) ? I can see the messages sent using the Firebase console but I need to track the number of messages sent via the web app to the devices.
Google explains how to get access to statistics on android https://support.google.com/googleplay/android-developer/answer/2663268. But is there a similar way for iOS?

In one word yes, You can do it.
Firebase API have a message_id as a response parameter. It's indicate notification is deliver or not.
message_id: String specifying a unique ID for each successfully processed message.
Please find below attached screenshots.
Please do refer this reference.
Update:
You can not track user activity for notification in iOS application. If you want to
implement above functionality then call any custom API and store required data into your
database. You can not get any history directly.

Related

Send mail from Firebase Analytics after iOS logs an event

Is this possible to send out mail from Firebase when a particular event is logged on firebase dashboard?
In an iOS app, when particular API is failed, an event is logged in Firebase. I want to send out mail for this event from Firebase (like Firebase Crashlytics - firebase sends out mail when crash occur).
There is currently no option built into Firebase console to send an email when a specific event occurred. It is an interesting idea though, so I'd recommend filing a feature request.
It might be possible to do this through the Google Analytics dashboard, which you can also open for the analytics data that is gathered through Firebase. A quick search shows some help center pages, although I'm not completely certain.
If neither of those works, you can build it yourself. Here I see two options:
You can use Cloud Functions that are triggered on conversion events to run any code you want. From this Node.js code you'd then check the conditions on the event, and send the email if necessary.
By exporting the analytics data to BigQuery, you can run any custom queries on it you want, at any interval, and take whatever actions you deem necessary. It's admittedly not ideal, but depending on how important this feature is for you might be worth it.

How do I get notifications sent to each device when a child is added, using Swift and Firebase?

I have a fully functioning application that uses Firebase as a backend. I want to be able to have a user receive a notification when a child is added to my Firebase database under that users ID.
I have looked everywhere but all I can find are links to OneSignal or people telling me to "make a custom server" as if it can be done by magic. How do I go about making a server? What language? What do I do with OneSignal? Can someone guide me step by step without telling me to simple make a custom server.
I believe Cloud Functions for Firebase is exactly what you're looking for. Specifically, Realtime Database Triggers:
The Realtime Database supports the onWrite() event, which triggers anytime data is created, destroyed, or changed in a specified database location.
In a typical lifecycle, a Firebase Realtime Database function does the following:
Waits for changes to a particular database location for write events.
Fires when a write event occurs and performs its tasks (see What can I do with Cloud Functions? for examples of use cases).
Receives an event data object that contains two snapshots of the data stored at the specified path: one with the original data prior to the change, and one with the new data.
And going through the What can I do with Cloud Functions?, theres Notifying users:
Notify users when something interesting happens
Developers can use Cloud Functions to keep users engaged and up to date with relevant information about an app. Consider, for example, an app that allows users to follow one another's activities in the app. In such an app, a function triggered by Realtime Database writes to store new followers could create Firebase Cloud Messaging (FCM) notifications to let the appropriate users know that they have gained new followers.
The function triggers on writes to the Realtime Database path where followers are stored.
The function composes a message to send via FCM.
FCM sends the notification message to the user's device.
To review working code, see Send FCM notifications.
Other interesting notification use cases
Send confirmation emails to users subscribing/unsubscribing to a newsletter.
Send a welcome email when a user completes signup.
Send an SMS confirmation when a user creates a new account.

Push Notifications with Firebase and OneSignal

I'm looking for some guidance.
I'm using Firebase as the backend server for an app I'm building and I would like to alert users when somebody has either liked or disliked some content the user generated.
I understand that Firebase offers cloud messaging through which I can target very specific users and send updates to them; I have implemented that functionality. However, I would like to send updates based on changes in the database, and, as far as I understand, FCM is not built for this purpose.
I have come across OneSignal and it seems promising. Has anybody implemented this with Firebase and could it do what I'm looking for?
Thanks!
I have it set upon such a way that when a message is send by a user to another user, a notification is also send via OneSignal. You just need to store the OneSignal userId in a node with the firebase user UID.
I you like someone's content, then that would also send a notification out directly to the other user.

Firebase Cloud Messaging - Send message to all users

I'm new using the Firebase Cloud Message. I built an IOS app to receive push notifications. The app works fine. I send messages from the Firebase console and they're displayed correctly.
Now I`m trying to build an web api to allow my customer to send the push messages (without accessing the firebase console). Studying the documentation here I realized that I've always to have a "to", meaning a group, topic or device id.
My question is: can I send a message to all devices (like I can do in the console)? I yes, how so?
Thanks in advance!
You can make use of topics. Given that all of your users are subscribed to a specific one. Just like what I mentioned here (removed some parts, just check them out if you want):
If you are looking for a payload parameter to specify that you intend the message for all your users, unfortunately, it doesn't exist.
Commonly, when sending notifications to multiple users, you can make use of the registration_ids parameter instead of to. However, it only has a maximum of 1000 registration tokens allowed. If you intend to use this, you can make batch requests of 1000 registration tokens each, iterating over all the registration tokens you've stored in your app server.
However, do keep in mind that Diagnostics for messages sent to Topics are not supported.
I found this:
!('TopicA' in topics)
With this expression, any app instances that are not subscribed to
TopicA, including app instances that are not subscribed to any topic,
receive the message.
So you could probably use
condition="!('nonExistingTopic' in topics)"

Web App Interfacing with iOS app for push notifications

I have a basic web app that is able to send push notifications (via UrbanAirship) to my iOS app.
My questions is, how can my webapp know that I have a new iOS app user? So I can then put the push DeviceID into a database (along with other data as required).
i.e. what is the interface for getting data into the Webapp, is it new code in the iOS app, or is there some other interface from UA?
Thanks..
I'm not an iOS developer, so it's hard for me to be too specific, but I'm assuming you need to store a device ID and (possibly) a token so that you can send messages to that device. I'm assuming (also) that you have access to this information on the device.
The correct way to do this would be to create datastore table of devices and the information associated with them (tokens, various IDs, I also like to have the last time I sent them a message, etc.) Then you send a request (should be a POST request, semantically) to your app when the user registers their device. Send the information you need in the POST request, then store it in your datastore through a handler.
Hope that helps? That's how things are done with Android Cloud to Device messages, and from my quick perusal of Urban Airship, that's how their service works, too.

Resources