Requesting full location access

This commit is contained in:
Selim Mustafaev 2020-09-17 22:05:57 +03:00
parent a6bf78affe
commit f2aeec6fd2
3 changed files with 16 additions and 3 deletions

View File

@ -10,6 +10,7 @@ class SearchController: UIViewController, UISearchResultsUpdating {
let bag = DisposeBag()
let searchController = UISearchController(searchResultsController: nil)
var refreshControl = UIRefreshControl()
var filterRelay = BehaviorRelay<Filter>(value: Filter())
var filter = Filter()
@ -24,6 +25,10 @@ class SearchController: UIViewController, UISearchResultsUpdating {
searchController.searchBar.placeholder = "Search plate numbers"
navigationItem.searchController = searchController
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
if let cell = tableView.dequeueReusableCell(withIdentifier: "VehicleCell", for: indexPath) as? VehicleCell {
@ -51,6 +56,7 @@ class SearchController: UIViewController, UISearchResultsUpdating {
.do(onNext: {
self.navigationItem.title = "\($0.count) vehicles found"
self.showMapButton.isEnabled = $0.count > 0
self.refreshControl.endRefreshing()
})
.map { $0.groupedByDate() }
.bind(to: self.tableView.rx.items(dataSource: ds))
@ -114,4 +120,9 @@ class SearchController: UIViewController, UISearchResultsUpdating {
//self.navigationController?.pushViewController(controller, animated: true)
self.present(controller, animated: true)
}
@objc func refresh(_ sender: AnyObject) {
self.showMapButton.isEnabled = false
self.filterRelay.accept(self.filter)
}
}

View File

@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Access is needed for storing locations of vehicles</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
@ -42,8 +44,8 @@
</dict>
</dict>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Access is needed for storing locations of vehicles</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Access is needed for storing locations of vehicles (even when the app was sent to bacground)</string>
<key>NSMicrophoneUsageDescription</key>
<string>Access is needed for voice recordings</string>
<key>NSPhotoLibraryAddUsageDescription</key>

View File

@ -76,7 +76,7 @@ class LocationManager {
observer(.success(()))
break
case .notDetermined:
self.manager.requestWhenInUseAuthorization()
self.manager.requestAlwaysAuthorization()
let proxy = RxLocationManagerDelegateProxy.proxy(for: self.manager)
_ = proxy.authSubject.filter{ $0 != .notDetermined }.first().subscribe(onSuccess: { result in
if let status = result, [.authorizedWhenInUse, .authorizedAlways].contains(status) {