Quantcast
Channel: Questions in topic: "ads"
Viewing all articles
Browse latest Browse all 1416

Unity ad is showing in editor but not on android device.

$
0
0
I have created a sample project which shows an ad on clicking on a button. This works fine in the editor but when I do build and run on an android device then ads are not showing on the android device. Here is my sample code: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Advertisements; public class Ads : MonoBehaviour, IUnityAdsListener { public static string interstitialAd = "video"; public static string rewardedAd = "rewardedVideo"; public static string bannerAd = "banner"; private string playstoreId = "3890871"; private string applerStoreId = "3890870"; public bool testMode = true; // Start is called before the first frame update void Start() { init(); Advertisement.AddListener(this); } private void init() { if (Application.platform == RuntimePlatform.IPhonePlayer) { Debug.Log("iOS Ad Initilizing"); Advertisement.Initialize(applerStoreId, testMode); } else { Debug.Log("Android Ad Initilizing"); Advertisement.Initialize(playstoreId, testMode); } } // Update is called once per frame void Update() { } public void showRewarededAd() { Debug.Log(">>>>>>>>>>>>>>"); StartCoroutine(showAdd()); //Advertisement.Show(rewardedAd); } public IEnumerator showAdd() { while (!Advertisement.IsReady(rewardedAd)) { Debug.Log("Ad is not ready yet"); //init(); yield return new WaitForSeconds(1); } Advertisement.Show(rewardedAd); } public void OnUnityAdsReady(string placementId) { Debug.Log("OnUnityAdsReady>> " + placementId); } public void OnUnityAdsDidError(string message) { Debug.Log("OnUnityAdsDidError>> " + message); } public void OnUnityAdsDidStart(string placementId) { Debug.Log("OnUnityAdsDidStart>> " + placementId); } public void OnUnityAdsDidFinish(string placementId, ShowResult showResult) { Debug.Log("OnUnityAdsDidFinish>> " + placementId + ", showResult = " + showResult); } } Advertisement.IsReady(rewardedAd) is always false in android device.

Viewing all articles
Browse latest Browse all 1416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>