<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: iOS Issue downloading portal item in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/ios-issue-downloading-portal-item/m-p/711458#M8959</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wonder if this has to do with iOS's enforcement of App Transport Security (ATS). &amp;nbsp;Beginning with iOS 9, apps have ATS enabled by default, which means that any non-SSL HTTP connections will fail. &amp;nbsp;Practically speaking, this means that a developer either needs to replace any &lt;A href="http://*" rel="nofollow noopener noreferrer" target="_blank"&gt;http://*&lt;/A&gt;&amp;nbsp;endpoints with &lt;A href="https://*," rel="nofollow noopener noreferrer" target="_blank"&gt;https://*,&lt;/A&gt;&amp;nbsp;or declare exceptions in the app project's Info.plist file (see Apple's reference doc &lt;A href="https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33" rel="nofollow noopener noreferrer" target="_blank"&gt;here&lt;/A&gt;). &amp;nbsp;Beta users would not have encountered this limitation because the Xamarin iOS Runtime was using the Mono networking stack under the covers, which does not enforce this restriction. &amp;nbsp;For final, the implementation has been modified to use iOS's native networking stack, which of course does enforce this. &amp;nbsp;The easiest way to test whether this is an issue would be to either swap out http endpoints with https, or, if that's not easily done, add this to the Info.plist file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;&lt;SPAN class="" style="color: #63a35c;"&gt;key&lt;/SPAN&gt;&amp;gt;NSAppTransportSecurity&amp;lt;/&lt;SPAN class="" style="color: #63a35c;"&gt;key&lt;/SPAN&gt;&amp;gt;
&amp;lt;&lt;SPAN class="" style="color: #63a35c;"&gt;dict&lt;/SPAN&gt;&amp;gt;
&amp;nbsp; &amp;lt;&lt;SPAN class="" style="color: #63a35c;"&gt;key&lt;/SPAN&gt;&amp;gt;NSAllowsArbitraryLoads&amp;lt;/&lt;SPAN class="" style="color: #63a35c;"&gt;key&lt;/SPAN&gt;&amp;gt;
&amp;nbsp; &amp;lt;&lt;SPAN class="" style="color: #63a35c;"&gt;true&lt;/SPAN&gt;/&amp;gt;
&amp;lt;/&lt;SPAN class="" style="color: #63a35c;"&gt;dict&lt;/SPAN&gt;&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That will essentially disable ATS in the app, allowing access to any http endpoint. &amp;nbsp;While that can be useful during development, it's generally not something that ought to be done in a production app. &amp;nbsp;Instead, exceptions for individual http endpoints should be declared where an https equivalent is not available.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 06:29:41 GMT</pubDate>
    <dc:creator>RichZwaap</dc:creator>
    <dc:date>2021-12-12T06:29:41Z</dc:date>
    <item>
      <title>iOS Issue downloading portal item</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/ios-issue-downloading-portal-item/m-p/711457#M8958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've upgraded my Xamarin Forms app from the beta version to the latest release and everything is working well except for downloading portal items on iOS. &amp;nbsp;The code below is what I am using to accomplish this download. &amp;nbsp;It works like a charm on Android, but on iOS the GetDataAsync call returns an empty stream. &amp;nbsp;The item I am trying to download is a zip file that we uploaded to the portal as a Code Sample if that matters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure if this is an iOS bug or if there is some obscure iOS setting I need to toggle, but any help here would be greatly appreciated. &amp;nbsp;Thanks ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var item = await PortalItem.CreateAsync(PortalUser.Portal, itemId);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var outFile = File.OpenWrite(fileName);&lt;BR /&gt; var stream = await item.GetDataAsync();&lt;BR /&gt; var reader = new BinaryReader(stream);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;using (var writer = new BinaryWriter(outFile))&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;writer.Write(reader.ReadBytes((int)stream.Length));&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;writer.Flush();&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;reader.Close();&lt;BR /&gt; }&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2016 18:30:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/ios-issue-downloading-portal-item/m-p/711457#M8958</guid>
      <dc:creator>AndyWright</dc:creator>
      <dc:date>2016-12-08T18:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: iOS Issue downloading portal item</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/ios-issue-downloading-portal-item/m-p/711458#M8959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wonder if this has to do with iOS's enforcement of App Transport Security (ATS). &amp;nbsp;Beginning with iOS 9, apps have ATS enabled by default, which means that any non-SSL HTTP connections will fail. &amp;nbsp;Practically speaking, this means that a developer either needs to replace any &lt;A href="http://*" rel="nofollow noopener noreferrer" target="_blank"&gt;http://*&lt;/A&gt;&amp;nbsp;endpoints with &lt;A href="https://*," rel="nofollow noopener noreferrer" target="_blank"&gt;https://*,&lt;/A&gt;&amp;nbsp;or declare exceptions in the app project's Info.plist file (see Apple's reference doc &lt;A href="https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33" rel="nofollow noopener noreferrer" target="_blank"&gt;here&lt;/A&gt;). &amp;nbsp;Beta users would not have encountered this limitation because the Xamarin iOS Runtime was using the Mono networking stack under the covers, which does not enforce this restriction. &amp;nbsp;For final, the implementation has been modified to use iOS's native networking stack, which of course does enforce this. &amp;nbsp;The easiest way to test whether this is an issue would be to either swap out http endpoints with https, or, if that's not easily done, add this to the Info.plist file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;&lt;SPAN class="" style="color: #63a35c;"&gt;key&lt;/SPAN&gt;&amp;gt;NSAppTransportSecurity&amp;lt;/&lt;SPAN class="" style="color: #63a35c;"&gt;key&lt;/SPAN&gt;&amp;gt;
&amp;lt;&lt;SPAN class="" style="color: #63a35c;"&gt;dict&lt;/SPAN&gt;&amp;gt;
&amp;nbsp; &amp;lt;&lt;SPAN class="" style="color: #63a35c;"&gt;key&lt;/SPAN&gt;&amp;gt;NSAllowsArbitraryLoads&amp;lt;/&lt;SPAN class="" style="color: #63a35c;"&gt;key&lt;/SPAN&gt;&amp;gt;
&amp;nbsp; &amp;lt;&lt;SPAN class="" style="color: #63a35c;"&gt;true&lt;/SPAN&gt;/&amp;gt;
&amp;lt;/&lt;SPAN class="" style="color: #63a35c;"&gt;dict&lt;/SPAN&gt;&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That will essentially disable ATS in the app, allowing access to any http endpoint. &amp;nbsp;While that can be useful during development, it's generally not something that ought to be done in a production app. &amp;nbsp;Instead, exceptions for individual http endpoints should be declared where an https equivalent is not available.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:29:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/ios-issue-downloading-portal-item/m-p/711458#M8959</guid>
      <dc:creator>RichZwaap</dc:creator>
      <dc:date>2021-12-12T06:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: iOS Issue downloading portal item</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/ios-issue-downloading-portal-item/m-p/711459#M8960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rich,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It’s funny you should mention that.  I ran into that ATS error when attempting to access Esri basemaps on AGOL, so I already implemented your suggestion for another reason.  I originally thought this problem was related, but I got an error with the Esri basemaps and this does not throw any errors.  It appears that the download works, but the output stream is empty.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2016 19:27:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/ios-issue-downloading-portal-item/m-p/711459#M8960</guid>
      <dc:creator>AndyWright</dc:creator>
      <dc:date>2016-12-08T19:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: iOS Issue downloading portal item</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/ios-issue-downloading-portal-item/m-p/711460#M8961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I gave this a try and am able to repro what you're seeing. &amp;nbsp;The PortalItem.GetDataAsync method appears to be returning a ProgressStreamContent.ProgressStream on iOS. &amp;nbsp;That's an internal type, so I don't know precisely how it works, but it appears to download the file contents asynchronously after it's been initialized. &amp;nbsp;So it appears that the method is returning at the time the download has begun, rather than when it's ended. &amp;nbsp;I've found that one way around this is to copy the stream that's returned. &amp;nbsp;So I have something like so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DownloadStatus &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Downloading item data..."&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;// On iOS, we get a ProgressStream and on UWP, we get a ReadOnlyStream.&amp;nbsp; Neither of&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;// these internal types initialize their Length properties.&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; partialItemData &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;await&lt;/SPAN&gt; portalItem&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;GetDataAsync&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; fullItemData &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;new&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;MemoryStream&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; partialItemData&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;CopyTo&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fullItemData&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;// Copying causes the entire contents to be downloaded/read&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; DownloadStatus &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; $&lt;SPAN class="string token"&gt;"Download complete.&amp;nbsp; Data length: {fullItemData.Length}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here, the copy operation apparently waits for the download to complete. &amp;nbsp;Note that the same approach can also be used on UWP, which likewise doesn't make its Length available on the stream that's initially returned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:29:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/ios-issue-downloading-portal-item/m-p/711460#M8961</guid>
      <dc:creator>RichZwaap</dc:creator>
      <dc:date>2021-12-12T06:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: iOS Issue downloading portal item</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/ios-issue-downloading-portal-item/m-p/711461#M8962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rich,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the tip.  The CopyTo was actually hanging my app, but I switched to CopyToAsync and it seems to be working like a charm.  You got me out of a pickle there.  That almost makes up for not having related tables in the API. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So will this be logged as an API bug and fixed for an upcoming release?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2016 15:03:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/ios-issue-downloading-portal-item/m-p/711461#M8962</guid>
      <dc:creator>AndyWright</dc:creator>
      <dc:date>2016-12-09T15:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: iOS Issue downloading portal item</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/ios-issue-downloading-portal-item/m-p/711462#M8963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It will require a bit more looking into to confirm, but I'm inclined to think that this is not a bug. &amp;nbsp;Rather, the stream returned is just what gets passed back on iOS by the underlying HTTP calls employed by the API. &amp;nbsp;The fact that it changed from beta to final is likely because of the switch from the managed (Mono) to native (iOS) networking stack. &amp;nbsp;Nonetheless, initial indications are that&amp;nbsp;this is simply a by-product of how the platform works, much as length is likewise unavailable on the stream returned by the GetDataAsync&amp;nbsp;call on UWP. &amp;nbsp;The fact that length is not available&amp;nbsp;is not a bug there, either, but rather platform-specific behavior.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2016 15:15:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/ios-issue-downloading-portal-item/m-p/711462#M8963</guid>
      <dc:creator>RichZwaap</dc:creator>
      <dc:date>2016-12-09T15:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: iOS Issue downloading portal item</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/ios-issue-downloading-portal-item/m-p/711463#M8964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, thanks again for your help …&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2016 15:17:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/ios-issue-downloading-portal-item/m-p/711463#M8964</guid>
      <dc:creator>AndyWright</dc:creator>
      <dc:date>2016-12-09T15:17:42Z</dc:date>
    </item>
  </channel>
</rss>

