- Home /
UnityAds : Test first if have internet connection?
Hi :), how can i test first if i have internet connection before showing the ads? or is there any call back for it when you call Advertisement.Initialize(AdId, true); ? TAI :)
Here is my code :
Advertisement.Initialize(AdId, true);
while (!Advertisement.isReady())
{
yield return null;
}
Advertisement.Show(null, new ShowOptions
{
pause = false,
resultCallback = result =>
{
res = result;
if (loader)
{
loader.NoOfTimesLoaded = 0;
loader.FadeInScene();
}
}
});
Here is my solution if you'll ask
IEnumerator CheckConnection()
{
message = "requesting";
WWW www = new WWW("https://www.google.com");
yield return www;
isCheckingConnection = false;
if (www.error == null)
{
hasInternet = true;
}
else
hasInternet = false;
}
Answer by HarshadK · Jun 01, 2015 at 06:12 AM
There are a few different solutions discussed to check for internet connection availability:
hey i have read your links and they are very helpful.. thanks :) I've got the solution by using WWW but it is slow... so I was thing king using the androids native Connectivity$$anonymous$$anager.. and make a plugin for that, but the problem is that i dont know how can you $$anonymous$$ch me how to do it? hehe sorry, I'm just a beginner hoping to be pro... :)
You can start learning about plugin development for Unity by going through the articles under this Plugins section from Unity $$anonymous$$anual. You can also watch this video tutorial on Writing Plugins.
Your answer
Follow this Question
Related Questions
Using AirBrakes on mobile device with Standard Assets AircraftController 0 Answers
How to make Input.GetAxis work on certain area only? 0 Answers
Script sets same value to other script in all objects instead of just one. 1 Answer
How to pause countdown 0 Answers
How to Set Animation Position on Slope (animation) help please 1 Answer