// Update is called once per frame void Update() { if (!triedToFetchAdvertisingId || !sentSessionRequest) { return; } if (!refreshingVideos && ( (AdGemPlugin.usingInterstitialVideos && !interstitialVideoIsWebview && AdGemPlugin.CurrentTimeMillis() > AdGemPlugin.standardVideoExpirationDate) || (AdGemPlugin.usingRewardVideos && !rewardedVideoIsWebview && AdGemPlugin.CurrentTimeMillis() > AdGemPlugin.rewardVideoExpirationDate) || (AdGemPlugin.usingInterstitialVideos && !AdGemPlugin.interstitialVideoReady) || (AdGemPlugin.usingRewardVideos && !AdGemPlugin.rewardVideoReady) ) ) { StartCoroutine(refreshAdGemVideos()); } //No offer wall caching for now. We will just load it when needed. //if (osVersionIsHighEnoughForUniwebview && !refreshingOfferWall && AdGemPlugin.usingOfferWall && (!AdGemPlugin.offerWallReady || AdGemPlugin.CurrentTimeMillis() > AdGemPlugin.offerWallExpirationDate)) //if (!refreshingOfferWall && AdGemPlugin.usingOfferWall && (!AdGemPlugin.offerWallReady || AdGemPlugin.CurrentTimeMillis() > AdGemPlugin.offerWallExpirationDate)) //{ // refreshOfferWall(); //} if (AdGemPlugin.pollingForOfferCompletion && !pollProcessRunning) { StartCoroutine(pollForOfferCompletion()); } }
public void initWebviewIfNeeded() { if (webView == null) { UniWebView.SetAllowAutoPlay(true); UniWebView.SetAllowInlinePlay(true); webView = gameObject.AddComponent <UniWebView>(); webView.SetLoadWithOverviewMode(true); webView.SetBackButtonEnabled(false); //Prevent the back button from destroying and recycling the webview webView.OnShouldClose += (view) => { closeWebView(); return(false); //returning false stops the webview from being closed. }; webView.OnPageFinished += (view, statusCode, url) => { if (webviewMode == WebviewMode.offerWall) { offerWallLoading = false; adLoading = false; AdGemPlugin.offerWallExpirationDate = AdGemPlugin.CurrentTimeMillis() + (AdGemPlugin.milliesPerMinute * 300); if (AdGemManager.staticRef != null) { AdGemManager.staticRef.refreshingOfferWall = false; } failCount = 0; StartCoroutine(refreshWindowDimensions()); } if (webviewMode == WebviewMode.videoAd) { offerWallLoading = false; adLoading = false; webView.Show(); StartCoroutine(waitThenStartAdVideoWithJavascriptCall()); StartCoroutine(refreshWindowDimensions()); } }; webView.OnPageErrorReceived += (view, statusCode, errorMessage) => { if (AdGemManager.staticRef != null) { AdGemManager.staticRef.refreshingOfferWall = false; } if (failCount < 15) { failCount++; } Debug.Log("ERROR Loading web page! " + errorMessage); }; webView.OnOrientationChanged += (view, orientation) => { StartCoroutine(refreshWindowDimensions()); }; webView.AddUrlScheme("adgem"); webView.OnMessageReceived += (view, message) => { processAdgemUrlSchemeMessage(message); }; } }