Send mail from Firebase Analytics after iOS logs an event - ios

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.

Related

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.

Firebase to send backend emails or format data for review

Just a quick question if anyone has any insight / knows any good tutorials or guides. An ios app I am making consists of user-generated content and because of App Store rules, it must provide the user with the ability to report offensive/illicit content.
When the user reports something, my app creates a node with all the information of the report on the Firebase Database. Now, I could just review by using the Firebase console, but this would be very tedious so I'd like to implement some code that, whenever a node is created under "Reports" gets all the data from the database and storage and sends it as an email to a given account or stores it in an easily reviewable format.
Does anyone know how to implement this sort of backend code?
Thank you
This sort of situation is ideally suited for Cloud Function for Firebase, which allows you to run small snippets of JavaScript code in response to events such as a node being written to the database.
I recommend that you have a look at the Cloud Functions for Firebase documentation, specifically at the list of sample use-cases and even more specifically at the sample of sending a confirmation email when a user signs up for a newsletter.

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.

Listen to iCal event changes from server

I am building the server side for a calendar application. The client side is iOS only. The original plan was the app will know of iCal event changes then tell the server. But that might be a problem with reminders (via Parse Push). For example, if the event pushed forward the reminder should come earlier.
Is it possible from the server side to be notified on iCal events? For example, when users create/update/delete an iCal event I want to know from a server to grab this information. Is this possible? Or does everything need to be done via a native app thats running?
My server is currently on parse.com. But I could use a separate server say NodeJS if needed.
As iCal is user/device dependent, unless user has synced his calendar events with iCloud. And in second case where user has activated syncing of calendar events, it is completly insecure for end-user to share his icloud details to other server.
How about creating 1 API at backend, which will update/delete requests from Apps for the calendar events, and that will update Parse notification events in background process. For this you can also write customized Parse apis either in NodeJS or any other technology stack.
And in the apps, you can sync the events with iCal using Event Kit:
https://developer.apple.com/library/mac/documentation/DataManagement/Conceptual/EventKitProgGuide/ReadingAndWritingEvents.html#//apple_ref/doc/uid/TP40004775-SW1
first, you need to able to let iOS wake up your app running in the background, that requires to classify your app to one of the mode stated in the Apple Background Execution, I think the "Background fetch" is appropriate in your case, then in your application:performFetchWithCompletionHandler: you could check the Calendar database for changed events and preform necessary updates to the server.
I think this is your best bet:
https://stackoverflow.com/a/23997912/1967872
In your implementation of the storeChanged: method mentioned in that answer, you should iterate through all the events, detect any changes and submit those to the server.
I don't know exactly that is possible or not but I am thinking it's hard because still I didn't find any library/any features that apple is provides like that.
But I am putting one link that might be helpful for you. Please check it.
http://kb.kerio.com/product/kerio-connect/os-x/support-for-apple-ical-calendar-using-the-caldav-standard-1494.html

Consuming external json with parse.com

I'm working on an iOS application developed with Swift. The application is going to need notifications to receive alerts when certain events occur.
To handle push notifications I'm using parse.com. I was able to create an account and integrate push notifications into my application, as it's explained in the Parse.com guide, and are working fine when I send something from the Push section.
What I'm trying to do, and I cannot figure it out, is consume a 3rd party JSON, process that JSON to check some status and report, to the users that are using the application, a status change via a push notification. I know I should process all this in the backend/server side and then push the result or what I'm trying to notify, but I don't know what to do.
Ex. of What I'm trying to archive:
3rd party website ---(json)---> parse.com ---(push notification)--->
My App
I'm aware the tools that Parse.com provides, such as REST API, Cloud Code, Webhooks and Jobs, but I'm totally lost here! I cannot find any guide or documentation that allows me to do what I previously described. I don't even know if its possible, and the documentation at parse.com it's not necesarily up to date.
I hope anyone can help me, or guide me, if parse.com it's not enought for my purpouse.
Thanks for reading.
I would suggest looking into Cloud Code or a Job from Parse and seeing if you can get one to run on a time interval to look for updated JSON.
You can decode JSON using JS, which is exactly what Parse Cloud Code is, you actually write it out on your own computer and then upload it. I've only use the afterSave functions. I would think you probably have to keep some type of object in parse to see what is updated and notify who ever needs to notified when that data is updated.
Also, you'll probably want to pass something to the app to actually update when the user selects the push alert. You can do this in the push alert itself. It converts to a dictionary in the app delegate's method for handling received notifications or launching with one.
Alternatively, if the web server is under your control, you can create a PHP script that will trigger the push to parse.
My best shot at this (after not having used Parse for a long while) would be to set up a Job on Parse that queries the 3rd-party service, and takes that response and throws it into a Cloud Code function, which in turn parses out that JSON and sends off a notification.
Parse's reference materials would probably be a good starting point.
The toughest part for you is the up-to-date-ness of your data. Since you're still polling that 3rd-party service at a regular interval, it's going to be a trade-off between freshness of updates and frequency of jobs (which cost money at a certain scale).

Resources