An easy way to include Firebase in iOS projects.
- Add a document
- Get a document
- Get multiple documents
- Get documents using query fields
- Remove a document
- Add multiple documents
- Update a document
- iOS 11.0+
- Xcode 11.0+
You can use CocoaPods to install FirebaseKit
by adding it to your Podfile
:
platform :ios, '11.0'
use_frameworks!
pod 'FirebaseKit', :git => 'https://github.com/cpisciottadeveloping/FirebaseKit.git'
To get the full benefits import FirebaseKit
wherever you import UIKit
import UIKit
import FirebaseKit
- Download and drop
FirebaseKit
in your project. - Congratulations!
- Import the framework.
import FirebaseKit
- Create a static variable for the collection name.
extension FirestoreCollectionName {
static var events: Self {
FirestoreCollectionName(name: "events")
}
}
- Create a static function to find the proper document.
extension FirestoreDocumentName {
static func document(withID docID: UUID) -> Self {
FirestoreDocumentName(name: docID.uuidString)
}
}
- Create a function in
FirestoreManager
to make a get request.
extension FirestoreManager where T == NVEvent {
func getEvent(withID eventID: UUID, completion: @escaping FirestoreRequestResultCallback) {
router.getDocument(.document(withID: eventID)) { (result) in
switch result {
case .failure(let error): completion(.failure(error))
case .success(let documentSnapshot): completion(FirestoreDecoder().decodeDocumentSnapshot(documentSnapshot))
}
}
}
}
Please feel free to contribute to FirebaseKit, check the LICENSE
file for more info.
Charles Pisciotta – cpisciottadeveloping@gmail.com
Distributed under the MIT license. See LICENSE
for more information.