I have an app which uses the iOS Runtime SDK v100.6 which loads feature services from an on-premise installation of Portal for ArcGIS v10.7.1. The feature layers were loaded onto the map directly from their urls without requiring the user to authenticate with the portal. When the user creates a new feature and applies the edits, I can view the new feature in ArcGIS Pro, but the CREATIONUSER and LASTUSER fields both have the value "Esri_Anonymous".

I recognized that it is necessary to log the user into the portal before making edits, so I modified the initialization to do so (Slight variation from Esri documentation😞
override func <SPAN class="token function">viewDidLoad</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
self<SPAN class="punctuation token">.</SPAN>portal <SPAN class="operator token">=</SPAN> <SPAN class="token function">AGSPortal</SPAN><SPAN class="punctuation token">(</SPAN>url<SPAN class="operator token">:</SPAN> <SPAN class="token function">NSURL</SPAN><SPAN class="punctuation token">(</SPAN>string<SPAN class="operator token">:</SPAN> <SPAN class="string token">"https://mycompanysserver.com/portal"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="operator token">!</SPAN> as
URL<SPAN class="punctuation token">,</SPAN> loginRequired<SPAN class="operator token">:</SPAN> <SPAN class="token boolean">true</SPAN><SPAN class="punctuation token">)</SPAN>
self<SPAN class="punctuation token">.</SPAN>portal<SPAN class="operator token">?</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">load</SPAN><SPAN class="punctuation token">(</SPAN>completion<SPAN class="operator token">:</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="punctuation token">(</SPAN>err<SPAN class="punctuation token">)</SPAN> in
<SPAN class="keyword token">if</SPAN> let error <SPAN class="operator token">=</SPAN> err <SPAN class="punctuation token">{</SPAN>
<SPAN class="token function">print</SPAN><SPAN class="punctuation token">(</SPAN>error<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">else</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="token function">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Successfully logged into portal."</SPAN><SPAN class="punctuation token">)</SPAN>
self<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addOperationalLayersFromPortalItem</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
func <SPAN class="token function">addOperationalLayersFromPortalItem</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
var loadedCount <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN>
DispatchQueue<SPAN class="punctuation token">.</SPAN>main<SPAN class="punctuation token">.</SPAN>async <SPAN class="punctuation token">{</SPAN>
SVProgressHUD<SPAN class="punctuation token">.</SPAN><SPAN class="token function">showProgress</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> status<SPAN class="operator token">:</SPAN> <SPAN class="string token">"Loading Layer \(loadedCount)/25"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">}</SPAN>
self<SPAN class="punctuation token">.</SPAN>featureLayers<SPAN class="punctuation token">.</SPAN><SPAN class="token function">removeAll</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
self<SPAN class="punctuation token">.</SPAN>allLayers<SPAN class="punctuation token">.</SPAN><SPAN class="token function">removeAll</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">if</SPAN> let portal <SPAN class="operator token">=</SPAN> self<SPAN class="punctuation token">.</SPAN>portal <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> let user <SPAN class="operator token">=</SPAN> portal<SPAN class="punctuation token">.</SPAN>user <SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">//If logged in successfully</SPAN>
var loadedCount <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN>
DispatchQueue<SPAN class="punctuation token">.</SPAN>main<SPAN class="punctuation token">.</SPAN>async <SPAN class="punctuation token">{</SPAN>
SVProgressHUD<SPAN class="punctuation token">.</SPAN><SPAN class="token function">showProgress</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> status<SPAN class="operator token">:</SPAN> <SPAN class="string token">"Loading Layer \(loadedCount)/25"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">}</SPAN>
let featureStagingService <SPAN class="operator token">=</SPAN> <SPAN class="token function">AGSPortalItem</SPAN><SPAN class="punctuation token">(</SPAN>portal<SPAN class="operator token">:</SPAN> portal<SPAN class="punctuation token">,</SPAN> itemID<SPAN class="operator token">:</SPAN> self<SPAN class="punctuation token">.</SPAN>featureStagingServiceId<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> i in <SPAN class="number token">1</SPAN> <SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN> <SPAN class="number token">25</SPAN> <SPAN class="punctuation token">{</SPAN>
let layer <SPAN class="operator token">=</SPAN> <SPAN class="token function">AGSFeatureLayer</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="operator token">:</SPAN> featureStagingService<SPAN class="punctuation token">,</SPAN> layerID<SPAN class="operator token">:</SPAN> i<SPAN class="punctuation token">)</SPAN>
featureLayers<SPAN class="punctuation token">.</SPAN><SPAN class="token function">append</SPAN><SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">)</SPAN>
allLayers<SPAN class="punctuation token">.</SPAN><SPAN class="token function">append</SPAN><SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">)</SPAN>
layer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">load</SPAN><SPAN class="punctuation token">(</SPAN>completion<SPAN class="operator token">:</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="punctuation token">(</SPAN>error<SPAN class="punctuation token">)</SPAN> in
loadedCount <SPAN class="operator token">=</SPAN> loadedCount <SPAN class="operator token">+</SPAN> <SPAN class="number token">1</SPAN>
self<SPAN class="punctuation token">.</SPAN><SPAN class="token function">updateLoadingProgress</SPAN><SPAN class="punctuation token">(</SPAN>loadedCount<SPAN class="punctuation token">,</SPAN> outOf<SPAN class="operator token">:</SPAN> <SPAN class="number token">25</SPAN><SPAN class="punctuation token">,</SPAN> withMessage<SPAN class="operator token">:</SPAN> <SPAN class="string token">"Loading Layer"</SPAN><SPAN class="punctuation token">)</SPAN>
guard error <SPAN class="operator token">==</SPAN> nil <SPAN class="keyword token">else</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="token function">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Error loading layer "</SPAN><SPAN class="punctuation token">,</SPAN> i<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">": "</SPAN><SPAN class="punctuation token">,</SPAN> error<SPAN class="operator token">!</SPAN><SPAN class="punctuation token">.</SPAN>localizedDescription<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">return</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">}</SPAN>
self<SPAN class="punctuation token">.</SPAN><SPAN class="token function">onFinishedLoading</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>But loading the layers like this fails:
Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={_kCFStreamErrorCodeKey=8, NSUnderlyingError=0x2839092c0 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorCodeKey=8, _kCFStreamErrorDomainKey=12}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <340D6EFF-6BD9-47E7-AD68-F9508910203E>.<115>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <340D6EFF-6BD9-47E7-AD68-F9508910203E>.<115>"
), NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=https://company-server-behind-firewall.com/mapgallery/rest/services/EmergencyManagement/EM_FeatureStaging2/FeatureServer/15?f=json&returnAdvancedSymbols=true, NSErrorFailingURLKey=https://company-server-behind-firewall.com/mapgallery/rest/services/EmergencyManagement/EM_FeatureStaging2/FeatureServer/15?f=json&returnAdvancedSymbols=true, _kCFStreamErrorDomainKey=12}
The instance of portal is using a reverse-proxy, and although I'm using the publicly accessible urls to reach the feature services, they are returning the internal urls behind the firewall and the http request fails.
With this setup, what is the correct way to load portal items as a logged in user?