Requesting full location access
This commit is contained in:
parent
a6bf78affe
commit
f2aeec6fd2
@ -10,6 +10,7 @@ class SearchController: UIViewController, UISearchResultsUpdating {
|
|||||||
|
|
||||||
let bag = DisposeBag()
|
let bag = DisposeBag()
|
||||||
let searchController = UISearchController(searchResultsController: nil)
|
let searchController = UISearchController(searchResultsController: nil)
|
||||||
|
var refreshControl = UIRefreshControl()
|
||||||
|
|
||||||
var filterRelay = BehaviorRelay<Filter>(value: Filter())
|
var filterRelay = BehaviorRelay<Filter>(value: Filter())
|
||||||
var filter = Filter()
|
var filter = Filter()
|
||||||
@ -25,6 +26,10 @@ class SearchController: UIViewController, UISearchResultsUpdating {
|
|||||||
navigationItem.searchController = searchController
|
navigationItem.searchController = searchController
|
||||||
definesPresentationContext = true
|
definesPresentationContext = true
|
||||||
|
|
||||||
|
//self.refreshControl.attributedTitle = NSAttributedString(string: "")
|
||||||
|
self.refreshControl.addTarget(self, action: #selector(self.refresh(_:)), for: .valueChanged)
|
||||||
|
self.tableView.addSubview(self.refreshControl)
|
||||||
|
|
||||||
let ds = RxTableViewSectionedAnimatedDataSource<DateSection<Vehicle>>(configureCell: { dataSource, tableView, indexPath, item in
|
let ds = RxTableViewSectionedAnimatedDataSource<DateSection<Vehicle>>(configureCell: { dataSource, tableView, indexPath, item in
|
||||||
if let cell = tableView.dequeueReusableCell(withIdentifier: "VehicleCell", for: indexPath) as? VehicleCell {
|
if let cell = tableView.dequeueReusableCell(withIdentifier: "VehicleCell", for: indexPath) as? VehicleCell {
|
||||||
cell.configure(with: item)
|
cell.configure(with: item)
|
||||||
@ -51,6 +56,7 @@ class SearchController: UIViewController, UISearchResultsUpdating {
|
|||||||
.do(onNext: {
|
.do(onNext: {
|
||||||
self.navigationItem.title = "\($0.count) vehicles found"
|
self.navigationItem.title = "\($0.count) vehicles found"
|
||||||
self.showMapButton.isEnabled = $0.count > 0
|
self.showMapButton.isEnabled = $0.count > 0
|
||||||
|
self.refreshControl.endRefreshing()
|
||||||
})
|
})
|
||||||
.map { $0.groupedByDate() }
|
.map { $0.groupedByDate() }
|
||||||
.bind(to: self.tableView.rx.items(dataSource: ds))
|
.bind(to: self.tableView.rx.items(dataSource: ds))
|
||||||
@ -114,4 +120,9 @@ class SearchController: UIViewController, UISearchResultsUpdating {
|
|||||||
//self.navigationController?.pushViewController(controller, animated: true)
|
//self.navigationController?.pushViewController(controller, animated: true)
|
||||||
self.present(controller, animated: true)
|
self.present(controller, animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func refresh(_ sender: AnyObject) {
|
||||||
|
self.showMapButton.isEnabled = false
|
||||||
|
self.filterRelay.accept(self.filter)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
|
<key>NSLocationWhenInUseUsageDescription</key>
|
||||||
|
<string>Access is needed for storing locations of vehicles</string>
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
@ -42,8 +44,8 @@
|
|||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<key>NSLocationWhenInUseUsageDescription</key>
|
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
|
||||||
<string>Access is needed for storing locations of vehicles</string>
|
<string>Access is needed for storing locations of vehicles (even when the app was sent to bacground)</string>
|
||||||
<key>NSMicrophoneUsageDescription</key>
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
<string>Access is needed for voice recordings</string>
|
<string>Access is needed for voice recordings</string>
|
||||||
<key>NSPhotoLibraryAddUsageDescription</key>
|
<key>NSPhotoLibraryAddUsageDescription</key>
|
||||||
|
|||||||
@ -76,7 +76,7 @@ class LocationManager {
|
|||||||
observer(.success(()))
|
observer(.success(()))
|
||||||
break
|
break
|
||||||
case .notDetermined:
|
case .notDetermined:
|
||||||
self.manager.requestWhenInUseAuthorization()
|
self.manager.requestAlwaysAuthorization()
|
||||||
let proxy = RxLocationManagerDelegateProxy.proxy(for: self.manager)
|
let proxy = RxLocationManagerDelegateProxy.proxy(for: self.manager)
|
||||||
_ = proxy.authSubject.filter{ $0 != .notDetermined }.first().subscribe(onSuccess: { result in
|
_ = proxy.authSubject.filter{ $0 != .notDetermined }.first().subscribe(onSuccess: { result in
|
||||||
if let status = result, [.authorizedWhenInUse, .authorizedAlways].contains(status) {
|
if let status = result, [.authorizedWhenInUse, .authorizedAlways].contains(status) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user