0

My game does not work when using URL in coroutines for Android 9. For lower levels of API it is working fine. Here's my code:

string url = "http://example.com";

void Start()
    {
        StartCoroutine(AccessURL(url));
    }

IEnumerator AccessURL(string uri)
    {
        using (UnityWebRequest webRequest = UnityWebRequest.Get(uri))
        {
            yield return webRequest.SendWebRequest();

        }
    }
Jatin
  • 71
  • 3
  • 11
  • https://stackoverflow.com/questions/53493077/download-manger-not-working-in-android-pie-9-0-networksecurityconfig-no-network – Quick learner Sep 25 '19 at 06:48
  • 1
    This question was specifically targeted for Unity Developers. A lot of developers might get confused that this is an issue with their Unity specially when it fails to fetch Android API level. This question will save them a lot of time, so don't mark it duplicate – Jatin Sep 26 '19 at 09:22

1 Answers1

1

For Android 9 and above upcoming versions, Android is blocking games and apps from connecting websites in cleartext (http, which is unsecure).
This is a big security issue. But using https is safe because data transferred between user and server is encrypted.
Change http://example.com
To https://example.com
And make sure that your website can be accessed with https.
Check out this link for more information: https://android-developers.googleblog.com/2018/08/introducing-android-9-pie.html

Jatin
  • 71
  • 3
  • 11