Tracking active users on Firebase - ios

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.

Related

Firebase GoogleService-Info.plist file stolen

My GoogleService-Info.plist file for iOS was stolen, is it possible to disable access to my Firebase Firestore to all current iOS devices, and reset this file ?
I tried to delete my iOS app in Firebase, but I can still make request from my iPhone...
And I need to disable access only for iOS devices not Android.
As Doug Stevenson pointed out the contents of the GoogleService-Info.plist are public and accessible to every iOS user of your application. Therefore it is inaccurate to say they could be stolen as they're already publicly available.
As explained in the Firebase documentation the file fields contain identifiers used by your application and Firebase servers to route the requests being made to Firestore, Real Time Database and the rest of products the app might be using. Reading the documentation or the post shared by Doug you would see the information exposed is not a security threat.
Moreover, I would like to point out that everybody could try to access your Firestore collections and try to add/drop data. This is indeed expected as Firestore is publicly accessible by mobile and web clients. However, this doesn't mean Firestore is exposed to users to do whatever they please, instead, the actual access is totally under your control by the means of security rules, which enforce what actions a given user could do. In that sense, the developers who left will only have the access level that your security rules grant them, which shouldn't be a threat when having good rules in place.
Lastly, you may revoke the credentials completely removing the application. I'd say it's not a great idea as you would cause a service disruption to app users. Also, this won't improve security or diminish risks.
You can remove the app directly from the Firebase console
Before proceeding make sure to check and understand the consequences.
Click on Settings > General;
Scroll down to Your Apps;
Identify the app and click on Remove this app.

ios app based on Firebase database - to incorporate changes locally

In an iOS app, developed using Firebase Database, can a user make changes to database on his/her device that is reflected only locally on his/her device?
My app is a contacts app and I want any user be able to edit or favourite a contact which should be only reflected on his/her device and not to every user using the app.
I'd recommend reading up on structuring data in Firebase: https://firebase.google.com/docs/database/ios/structure-data
(When you're done, read all the docs or perhaps follow some video tutorials on Firebase.)
This will help you establish a better understanding of how Firebase works, helping you with more than just the problem at hand.

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.

iOS app trouble storing user's documents/photos anywhere other than the phone

I'm trying to find a way of letting a user store their photos/documents online for my app. They can upload these to the app after registering an email and they remain on the phone even when the user logs out and then in again. However if the user deletes the app, downloads it again (the developers are using TestFlight at the moment), and logs in, any photo or document that the user saved before deleting has vanished.
I've been told that the data hasn't been stored on the Kinvey SDK service that we have been using as it takes a while to upload the data and then was told the app would be better suited on Kinvey REST API as the SDK version doesn't support background mode which supposedly would help store the data quicker (but this still wouldn't be 100% sure the photos/documents would be stored)
I'm not a developer/coder so I'm afraid I don't know much technically but my app needs to be able to have access across devices for the user's photos and documents, if these are 'lost' it would be catastrophic.
Please could someone help me if there a way of doing this?
Thank you.
Well If you want to save pictures or data that do not get deleted here are few options.
Save them iPhone,iPad gallery if not the use REST API
"Kinvey" can be used for that.
The alternative of "Kinvey", Kindly look into this.
https://www.raywenderlich.com/126098/top-5-parse-alternatives.
and may be you can try this. It provides chat feature too.
http://quickblox.com/

Using Firebase with multiple users in an iOS app

A number of iOS apps I develop are used in scenarios where the Organisation has a number of Drivers and the iPhone is shared between them. Each Driver has his own app credentials, logs in to the app, and is presented with his own set of data. The Firebase data is persisted as he is offline most of the day and I use keepSynced(true) to ensure data is up-to-date.
The problem I'm having is that once a user logs out with the Firebase method FIRAuth.auth()!.signOut() then when a different user logs in, he sees the previous users' data. I'm guessing that because the data is persisted it is not cleared from the cache. However, I am retrieving the data by the user id so this doesn't quite explain it.
What is the best pattern to permit multiple users to use the same iOS app with Firebase ?
Try creating multiple instances of FIRApp, each with a different name, using the +configureWithName:options: method. Then use the different apps in FIRAuth +authWithApp and elsewhere as needed.
I haven't actually done this and am too new to Firebase to say it's the best pattern, but it seems like it should work.
One thing to note from the docs is that, "On Android and iOS, Analytics are only logged for the default app." One solution might to keep the __FIRAPP_DEFAULT app, and then make a named app for each user type.

Resources