Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Display Google static map will get NSURLConnection finished with error and get blank image

Discussion in 'iOS and tvOS' started by yayapeter, May 16, 2018.

  1. yayapeter

    yayapeter

    Joined:
    Jun 24, 2014
    Posts:
    24
    I want to show google static map in the ios device.
    I have a url and getHttpImage function below , it's working in the web browser,ios Unity Editor and android device , but it will show blank and get an error below in the ios device.

    Error:

    "You are using download over http. Currently Unity adds NSAllowsArbitraryLoads to Info.plist to simplify transition, but it will be removed soon. Please consider updating to https.
    NSURLConnection finished with error - code -1002
    Error while downloading: Unknown Error

    "

    URL:
    https://maps.google.com/maps/api/st...pg9Xv-tpx47puQlvBCI6deN|33.282798,-111.856303




    Unity code snippet
    Code (CSharp):
    1.     IEnumerator getHttpImage (Image image,string url,int width,int height) {
    2.  
    3.         //A URL where the image is stored
    4.         //Call the WWW class constructor
    5.         WWW imageURLWWW = new WWW(url);
    6.  
    7.         //Wait for the download
    8.         yield return imageURLWWW;      
    9.  
    10.         //Simple check to see if there's indeed a texture available
    11.         if(imageURLWWW.texture != null) {
    12.  
    13.             if(getResponseCode(imageURLWWW) == 403){
    14.                 //do it again
    15.                 setHttpImage(image,url,width,height);
    16.                 yield return null;
    17.             }
    18.  
    19.            
    20.             //Create a new sprite using the Texture2D from the url.
    21.             //Note that the 400 parameter is the width and height.
    22.             //Adjust accordingly
    23.             Sprite sprite = Sprite.Create(imageURLWWW.texture, new Rect(0, 0, width, height), Vector2.zero);
    24.  
    25.             //Assign the sprite to the Image Component
    26.             image.sprite = sprite;
    27.             image.SetNativeSize ();
    28.  
    29.         }
    30.  
    31.         yield return null;
    32.     }

    XCode Info.plist content already include below:

    <key>NSAppTransportSecurity</key>

    <dict>

    <key>NSAllowsArbitraryLoads</key>

    <true />

    <key>NSExceptionDomains</key>

    <dict>

    <key>drive.google.com</key>

    <dict>

    <key>NSExceptionRequiresForwardSecrecy</key>

    <false />

    <key>NSIncludesSubdomains</key>

    <true />

    </dict>

    <key>maps.google.com</key>

    <dict>

    <key>NSExceptionRequiresForwardSecrecy</key>

    <false />

    <key>NSIncludesSubdomains</key>

    <true />

    </dict>

    </dict>

    </dict>


    How can I fix it?