Hello I was looking at this async.
But I found for example.
delay(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
}
Works on some devices, but not on all the devices.
Basically my async method is
private async RestartGame ()
{
//count gameplay
let countGamePlay = localStorage.getItem("countGamePlay");
if (countGamePlay == null)
{
localStorage.setItem("countGamePlay", "0");
}
let count = parseInt(localStorage.getItem("countGamePlay"));
count++;
let isAdReady = AndroidNative.isInterstitialReady();
if(count>=3)
{
AndroidNative.showToast("Show Interstitial Game.ts",0)
AndroidNative.showInterstitial();//
// await this.delay(1500);//Doesn't work on all devices, not safe.
director.loadScene("Game");
}
else
{
AndroidNative.showToast("Count " + count.toString() , 0);
localStorage.setItem("countGamePlay", count.toString())
director.loadScene("Game");
}
}
But while it works fine on the editor and some devices I found this is not safe.
I wonder if this is officially supported ? Maybe other way to do this ?