@Nicholas-Furness One thing I noticed that may be causing the issue is that I'm having trouble authenticating while offline.
While online, I authenticate like this:
AGSAuthenticationManager.shared().delegate = self
func authenticationManager(_ authenticationManager: AGSAuthenticationManager, didReceive challenge: AGSAuthenticationChallenge) {
let username = "USERNAME"
let password = "PASSWORD"
let credentials = AGSCredential(user: username, password: password)
challenge.continue(with: credentials)
}
However, this delegate function never gets called while I'm loading an offline map. It's the same view controller that loads online/offline, so the delegate gets set no matter what.
When I'm loading an online map I use this code:
let portal = AGSPortal.arcGISOnline(withLoginRequired: false)
let itemId = portalItem.itemID
let portalItem = AGSPortalItem(portal: portal, itemID: itemId)
let map = AGSMap(item: portalItem)
mapView.map = map
And when loading offline map I use mobile map package like this:
let mobileMapPackage = AGSMobileMapPackage(fileURL: self.offlineMapUrl)
let tpkUrl = self.offlineMapUrl.absoluteString.replacingOccurrences(of: "gismap", with: "tpk")
var tileLayer: AGSArcGISTiledLayer?
if let tpkUrl = URL(string: tpkUrl) {
tileLayer = AGSArcGISTiledLayer(url: tpkUrl)
}
mobileMapPackage.load { [weak self] (error) in
self?.mapView.map = mobileMapPackage.maps.first
self?.mapView.map?.operationalLayers.insert(tileLayer, at: 0)
self?.delegate?.loadOfflineMapLayers()
}
When using a mobile map package is there another way we need to authenticate? I've tried caching the credentials to see if that helped but it did not.