When view controller is loaded, it makes an API call to our server with the app identifier which is used by the API to generate a token using ArcGIS service. The response contains portal URL, token and mapId. The portal URL can be of following format:
and then use following code to load map and related basemaps
agsCredential = AGSCredential(token: portalToken, referer: referer)
let portal = AGSPortal(url: portalURL, loginRequired: true)
portal.credential = agsCredential
let portalItem = AGSPortalItem(portal: portal, itemID: mapId)
let map = AGSMap(item: portalItem)
esriMapView.map = map
map.load { (error) in
// handle error or handle successfully loaded map
// load base maps
}
Although I have provided the credentials, I still see credential challenge popup. If I create AGSCredentials using userName and password, it works fine.
Our requirement is to use token rather than userName and password, what is the best approach to use the token?
I also been communication on git, so I tried and what worked is in following link of ESRI iOS Repo.
https://github.com/Esri/arcgis-runtime-samples-ios/issues/1012