banner



How To Fix Malformed Url

Search Unity

Unity ID

A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate in the Unity community.

  1. Unity Version: 2019.4.1f1
    Issue with: UnityWebRequestTexture()
    Error message: URL Malformed
    Only occurring on iOS build.

    I'm having an issue with, UnityWebRequestTexture() working with the google map api in the iOS build. It works perfectly in the Unity editor, and Android port. Does not work in the iOS port. I'm not sure where to post this question. Should I instead ask it at Google, or Apple?

    In case it matters, the url field is not public. It is a private field.

    The funness:

    1. //This (modified for privacy) URL is the troublemaker:
    2.            url = "https://maps.googleapis.com/maps/api/staticmap?size=640x640&center=33.3307%2C-98.7862&zoom=14&format=png&style=feature:administrative|visibility:off&style=feature:landscape|visibility:off&style=feature:poi|visibility:off&style=feature:transit|visibility:off&key=[SUPER SECRET GOOGLE TOKEN]" ;
    3. //This URL of a random PNG file off the Internet works just fine.
    4.            url = "https://png.pngtree.com/png-clipart/20190516/original/pngtree-social-media-icons-set-facebook-instagram-whatsapp-png-image_3556903.jpg" ;
    5.             StartCoroutine(GetTextureRequest(url, (response) => {
    6.             spriteRenderer. sprite = targetSprite;
    7. IEnumerator GetTextureRequest( string url, System . Action <Sprite> callback)
    8. using ( var www = UnityWebRequestTexture. GetTexture (url) )
    9. yield return www. SendWebRequest ( ) ;
    10. if (www. isNetworkError || www. isHttpError )
    11.                 webInfo. text = www. error + "\n" + url;
    12. var texture = DownloadHandlerTexture. GetContent (www) ;
    13. var rect = new Rect( 0, 0, 600f, 600f) ;
    14. var sprite = Sprite. Create (texture, rect, new Vector2(0.5f, 0.5f) ) ;
    15. // Reminder: I don't see any errors in the editor debug, as it runs fine in the editor.
    16.                     Debug. Log ( "MapFinder.cs " + url) ;
    17. // webinfo.text is where I see the error message on my iPhone: "Malformed URL" + url
    18.                     webInfo. text = "MapFinder.cs " + url;
    For the sake of over communication, I just did a quick and dirty copy/paste of the code into this post. If you find an error with the code, it's from the copy paste. The code does work. It works in the Editor, and in my Android build. It only doesn't work in iOS. So weird.

    Thank you,
    hotcarl

  2. Hi! I have a similar error. Did you solve the problem in ios?
  3. I am trying to download static images from mapbox. When I was using Unity version 2019.4.18f1 it worked fine but when I recently update to Unity version 2020.3.2f1 it works in the UNITY Editor but not in android and iOS device. This error appears Xcode or Android logcat:

    "Error while Receiving: HTTP/1.1 422 Unprocessable Entity"

    And this is my code:

    url = "https://api.mapbox.com/styles/v1/angelsm/ckm67d265c27817rzq1xixdtf/static/" + fixLon + "," + fixLat + "," + zoom + "/1280x1280@2x?access_token=" + key;

    UnityWebRequest www1 = UnityWebRequestTexture.GetTexture(url);

    yield return www1.SendWebRequest();

    while (!www1.isDone)
    {
    Debug.LogError("loading map...");
    yield return null;
    }

    if (www1.isNetworkError || www1.isHttpError)
    {
    Debug.Log("Error while Receiving: " + www1.error);
    Instantiate(Resources.Load("_Canvas_MENSAJECONEXION"), transform.position, transform.rotation);
    }
    else
    {
    maprender.material.mainTexture = ((DownloadHandlerTexture)www1.downloadHandler).texture;
    }

  4. I mean report a bug using Unity Editor with a repro project, so that our QA could look into it.
  5. Ok. But Unity Editor doesn't show any error. I can see the error in Xcode when debug the iOS app in the iPhone or in Android Logcat with other android device. Then, how can I report a bug using Unity Editor with a repro project?
  6. If you have a Unity project, which gives the mentioned error when built for iOS, then report a bug with that project from Editor. Just mention that the error only happens on iOS and our QA will handle it.
  7. Has there been any resolution for this? I am experiencing it as well.
  8. I don't think anyone has reported a bug.
  9. I was able to resolve my issue. This is something I did during testing on Android but then found that if I took it out, the call still worked just fine.

    We are using custom image urls to replace the default location marker that Google uses to mark the locations you pass in with the map request. You can see from their examples that the "|" character is replaced with its encoded value "%7C". While it's not essential to manually swap these on Android, it appears that you do need to make the swap for iOS.

    I believe there are url encoding methods supported in c#, but I did a simple string replacement and it worked just fine. It may be worth noting that our image urls are being sent to the client already encoded as well.

    This is the return statement of our function that creates the query url to the Google static maps api.

    1. // ios doesn't like the bar, replace it with encoding
    2. return queryString. Replace ( "|", "%7C" ) ;

How To Fix Malformed Url

Source: https://forum.unity.com/threads/malformed-url-error-with-google-maps-api-url-only-happens-in-ios.924488/

Posted by: dillinghaminci1989.blogspot.com

0 Response to "How To Fix Malformed Url"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel