This framework helps you to get geometry data from Firebase with geohash. Basic logic is the same as GeoFireX by codediodeio.
To run the example project, clone the repo, and run pod install
from the Example directory first.
GeoFireX-Swift query result is returned as Combine, so you have to make a subscriber to get result. within() makes Publisher, you can make a subscriber just by executing sink().
import Firebase
import Combine
import GeoFireX_Swift
let client = GeoFireClient()
let query = client.query("markers")
let center = FirePoint(geopoint: GeoPoint(latitude: 35.68123620000001, longitude: 139.7671248))
var result : [[String:Any]]!
let subscriber = query.within(center: center, radius: 1.5, field: "geography", opts: GeoQueryOptions(units: .kilometer, log: true))?.sink( receiveCompletion: { completion in
switch completion {
case .finished:
print(".sink() received the completion:", String(describing: completion))
break
case .failure(let anError):
print("received the error: ", anError)
break
}
}) { (dataList) in
result = dataList
}
- iOS 13.0 later
- Conbine
- Firebase
GeoFireX-Swift is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'GeoFireX-Swift'
You have to setup Firebase emulator to invoke Unit Test. Official guide is here.
$ npm install -g firebase-tools
$ firebase setup:emulators:firestore
$ mv firebase
$ firebase emulators:start --only firestore
- Promise Binding
- Converting result to JSON
GeoFireX-Swift is available under the MIT license. See the LICENSE file for more info.