Skip to content

Latest commit

 

History

History
125 lines (98 loc) · 3.59 KB

README.md

File metadata and controls

125 lines (98 loc) · 3.59 KB

FirebaseKit

An easy way to include Firebase in iOS projects.

Features

  • Add a document
  • Get a document
  • Get multiple documents
  • Get documents using query fields
  • Remove a document
  • Add multiple documents
  • Update a document

Requirements

  • iOS 11.0+
  • Xcode 11.0+

Installation

CocoaPods

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

Manually

  1. Download and drop FirebaseKit in your project.
  2. Congratulations!

Usage example

  1. Import the framework.
import FirebaseKit
  1. Create a static variable for the collection name.
extension FirestoreCollectionName {
    static var events: Self {
        FirestoreCollectionName(name: "events")
    }
}
  1. Create a static function to find the proper document.
extension FirestoreDocumentName {
    static func document(withID docID: UUID) -> Self {
        FirestoreDocumentName(name: docID.uuidString)
    }
}
  1. 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))
            }
        }
    }
}

Contribute

Please feel free to contribute to FirebaseKit, check the LICENSE file for more info.

Meta

Charles Pisciotta – [email protected]

Distributed under the MIT license. See LICENSE for more information.