Example iOS app using Firebase with Firestore, Swift 4.2, Xcode 10, iOS12. Demonstrates the Firebase Cloud Firestore Database, Storage (Images), Authentication, and Analytics modules.
Example iOS app using Firebase, Swift 4.2, Xcode 10 with Auto Layout and Segues, and iOS 12. Demonstrating the Firebase Cloud Firestore, Storage (Images), Authentication, and Analytics modules. Firebase is a mobile platform from Google. The most distinguishing feature for iOS development is a local database in a mobile app that synchronizes with the cloud while gracefully handling offline modes and queueing up changes for the next connected session.
pod install
as the CocoaPods repository is stored elsewhere (e.g. ~/.cocoapods/repos/master). If you do not already have a repository, you may see the first step, “Setting up CocoaPods master repo”, run for more than 15 minutes.Firebase offers a remote administration of users and their authorizations for your mobile apps. At this point, Firebase offers providers for Facebook, Google+ and others. For simplicity, I used only the email address provider for this sample project.
By default, Firebase collects usage data such as device type, country, and view controllers. Firebase can additionally capture data from the iOS AdSupport as long as the user has not disabled advertiser tracking. To include that data such as age and gender, you must:
Firebase provides string constants for common events. You can also define your own strings, but take care to avoid clashing with reserved system values such as “first_open_time”
This replacement for the Firebase Realtime Database provide a local database in the same way as CoreData. The Firebase database is distinguished from CoreData at the time of this development by its syncrhonization with the cloud and by gracefully handling offline mode, queueing up changes for the next connected session. In order to query data with Firebase, you attach listener handlers which are commonly defined in viewDidAppear methods. With this sample app, you can monitor data being created in the cloud using the Firestore console. Look under the “users” collection, then “bucketlists”.
By default, your Firebase Storage project will be setup to allow any authenticated user to download any data. You will eventually want to further restrict storage access using the Firebase console. You can find the documentation here and an example below:
service firebase.storage {
match /b/[REPLACED WITH YOUR FIREBASE STORAGE BUCKET]/o {
// Public (e.g. app images): Must be an app user to write
match /public/{allPaths=**} {
allow read, write: if request.auth != null;
}
// Shared (e.g. user thumbnail images): Must be an app user to read
match /shared/{userId}/{allPaths=**} {
allow read: if request.auth != null;
allow write: if request.auth.uid == userId;
}
// Private (e.g. user date)
match /private/{userId}/{allPaths=**} {
allow read: if request.auth.uid == userId;
allow write: if request.auth.uid == userId;
}
}
}