I’ve built an app following exactly the swift tutorial but, when I try the app, it does not work.
The functions indoorLocationManager are never called even on error neither on success.
Any suggest?
import Foundation
import WebKit
import UIKit
class LocationBeacon: NSCoder, EILIndoorLocationManagerDelegate, WKNavigationDelegate{
var appID: String
var appToken: String
var locationID: String
let locationManager = EILIndoorLocationManager()
var location: EILLocation
let url = Bundle.main.url(forResource: "index", withExtension: "html")!
var webView: WKWebView!
init(appID: String, appToken: String, locationID:String){
self.appID=appID
self.appToken=appToken
self.locationID=locationID
self.location = EILLocation()
super.init()
self.locationManager.delegate = self
webView = WKWebView()
webView.navigationDelegate = self
webView.loadFileURL(url, allowingReadAccessTo: url)
webView.load(URLRequest(url: url))
ESTConfig.setupAppID(appID, andAppToken: appToken)
let fetchLocationRequest = EILRequestFetchLocation(locationIdentifier: locationID)
fetchLocationRequest.sendRequest{ (location, error) in
if location != nil {
self.location = location!
self.startPositioning()
} else {
print("errore!")
//TODO impossibile trovare la location
}
}
}
func startPositioning(){
self.locationManager.start()
self.locationManager.startMonitoring(for: self.location)
self.locationManager.startPositionUpdates(for: self.location)
}
func indoorLocationManager(manager: EILIndoorLocationManager!, didFailToUpdatePositionWithError: NSError!){
print("failed")
//TODO errore nell'aggiornamento della posizione
}
func indoorLocationManager(manager: EILIndoorLocationManager!, didUpdatePostition position: EILOrientedPoint!, withAccuracy positionAccuracy: EILPositionAccuracy, inLocation location: EILLocation!) {
print("cambia")
let first = position.description()
webView.loadHTMLString(first , baseURL: url)
}
func getView() -> UIView{
return webView
}
}