Firebase to send backend emails or format data for review - ios

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.

Related

Firebase insecurity/public endpoints with iOS app

I've frequently heard that the main issue we need Firebase security rules is because an application contains all the configurations needed to connect to the database and thus users could do something like db.delete('*'), read/write whatever they want, etc. etc.
I can see how this is possible on a web app, as you could check out the requests being sent over the network and thus get the endpoint needed to connect to the database, but, on an iOS app, how would this be possible?
For instance, say I created some chat app with Firebase and released it to the App Store. When a user downloads it, how would he/she gain access to my database through an API other than the buttons etc I provide with them with? Is there something equivalent to the "Network" section in google chrome that shows all outgoing requests, and, from, this they could send a malicious request to my database? Would this require installing 3rd party software onto their device to see all outgoing/incoming requests and they could get the required endpoint/database connection info from there?
Thanks.
When a user downloads it, how would he/she gain access to my database through an API other than the buttons etc I provide with them with?
It's not hard to reverse engineer the contents of the IPA file to get both the configuration you provided, and also see what the code is that queries the database. The IPA file can be obtained pretty easily - there is not much protecting that, given the user effectively has full control over the device (e.g. jailbreak). Given that information, it's possible to simply invoke the public Firestore REST API to not just duplicate all the operations in the app, and but invent operations of their own.

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.

Tracking active users on Firebase

Apologies if this question has already been asked but I have no been able to find it. I'm trying to figure out if there is a way to track how often a user opens my app if they're already logged in. Firebase only shows the last time they're signing in, but not if they're already signed in so I don't know when they've actually been opening my app last.
There is no presence tracking built into Cloud Firestore. It just doesn't match well to the protocol that Firestore uses to communicate between client and server.
The simplest way to get this working is to use the Realtime Database, and potentially synchronize the information to Cloud Firestore from there. For a walkthrough of this (quite involved) scenario have a look at the Firestore documentation on building a presence system.

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.

Swift : Upload pdf as "admin user" and send notification to other "normal users" that pdf is uploaded

I'm a swift beginner.
I'm trying to create an app that essentially does the following :
Users can sign up and login to the app to receive a new recipe weekly in a pdf (or word doc) format. Once the new recipe of the week is ready to be viewed the users will receive a notification that "recipe of the week is ready for viewing" and they can then login and access the new recipe (as well as recipes from previous weeks).
One admin user will be able to login and upload these pdfs/word doc that contain the recipe and once the upload is complete, the other normal users are notified of this new recipe.
My question :
1) Is it possible to have different users in one app? (ie normal users and admin users). I just want to make the app easy to use for the admin (a friend who is not a tech and who just want to upload recipes) without having to touch the codes or needing me to upload them manually. If its not possible, what could be an alternative way of doing this, so that an ordinary admin user can just upload into the app for other users viewing pleasure?
2) I just thought pdf/word doc might be an easier way for the friend to upload the recipes into app (the recipe might contain pics, tables, graphs etc), if there is a different way of doing this, open to suggestions :) At first I thought maybe putting the recipes on a shared directory and getting Apple's DirectoryMonitor.swift to monitor the directory so that everytime the friend uploads something to the directory, the app will detect this and send notifications to other users....but I thought maybe this isnt the best way to do it, not to mention it might send false notifications (ie when files are removed insteaf of added..)
I do know the basics of Swift, or think I do.So hopefully if you can provide me enough hints (ie framework or SDK or classes to use etc etc) I can use your suggestions to do further research on the subject.
If you need more details or clarifications, please let me know. Thanks!
You must use web services (server) to achieve this stuff.
Design api for login like if admin user login then you return something like this is admin and shows admin screens in your app like upload dishes etc.
If normal user will login then your api (web service) will return you that this is a normal user then show stuff regarding it in your app.
You required web services for uploading and retrieving recipes.
You can easily manage notification if admin upload new recipe to server.
So, it's basically depends on your server and mobile both side of proper management. Your database will take place server side. that's it.

Resources