Rewarded video no callback on Android

I don’t know what I’m doing wrong but HandleShowResult doesn’t get called, the video plays fine and everything works in editor.

I’m using unity 5.5.0.p3 with the builtin ads and testing on Android 6.0.1. Am I missing some permission, does it need special permission? the video works and the logcat doesn’t show any errors.

public void showRewardedVideo(){
     if(Advertisement.IsReady("rewardedVideo")){
         ShowOptions options = new ShowOptions();
         options.resultCallback = HandleShowResult;
         Advertisement.Show("rewardedVideo", options);
     }
}
private void HandleShowResult(ShowResult result){
     debugText.text = "ads rez: " + result.ToString ();
     switch (result){
         case ShowResult.Finished:
             updateBonusScore(20, true);
             break;
         case ShowResult.Skipped:
             Debug.Log("The ad was skipped before reaching the end.");
             break;
         case ShowResult.Failed:
             Debug.LogError("The ad failed to be shown.");
             break;
     }
}

I also experienced such a phenomenon. I blocked ads from my released apps.

Hi @LSTGames ,

I copied your code into our example projectx at GitHub - Unity-Technologies/unity-ads-engineintegration-test in Unity 5.5.0f3, and the callback is called without problems, although on Android 5.1 here (only device I have at home)

Would it be possible to get access to your project, to see if we can reproduce the issue on our side? E.g. file a bug report including project files from Unity Editor using Help-Report a bug menu item, and post the bug id here (not the full url from mail, as that includes auth token, which gives everyone access to read bug report and project files)

Thanks,
Rasmus

it’s very late and I will post tomorrow more of what I did to find the problem.

I have a preloader scene that loads first, then I load another scene Additive and I call SceneManager.UnloadScene when it’s done so if I don’t call SceneManager.UnloadScene or if I load my scene Single the callback works but this problem is only on Android.

Ok, retried here with loading another scene using SceneManager.LoadScene and LoadSceneMode.Additive mode as described. Still callback is triggered here.

At what point do you unload the scene?

/Rasmus

I think it might be because the version is different.
I also use 5.5.0p3.
It is not 5.5.0f1.

Thank you for your time

I’ve attached a simplified version of my project, in the file preloader.cs I made 3 cases, please check it out you’ll see what I’m talking about, let me know if my code is correct because if I remember correctly you guys recently changed a bit the loading stuff.

EDIT: I’ve also test on android 5.1 and unity 5.5.0f3 and still doesn’t work

2913953–214939–Example.zip (14.7 KB)

Hi, sorry for delay. Will check this today

Thanks,
Rasmus

I had the same problem on iOS (opened a thread here, didn’t notice this one, sorry). Hope this can be resolved with a quick fix. :frowning:

@LSTGames , managed to repro issue here with your provided code. If I do a manual initialization of Ads from a script in the “Game” scene in your project (although have to wait a few seconds) it works.

Will try to step through code to see if I can spot why it fails to call callback in this situation.

Thanks,
Rasmus

@rasmus-unity I don’t know how you guys add the ads but maybe this is the problem (not likely since the callback works in editor) [Solved] Problem with Awake/Start when using SceneManager to load Additively - Unity Engine - Unity Discussions

Hi, haven’t figured out why, but in meantime is a workaround:

  • Import Unity Ads 2.0 SDK from Asset Store instead of using the engine integrated version (disable the “builtin Ads extension” in services window → Ads → Advanced)
  • Add following code to a game object in your “Scene” scene:
void Start ()
{
    Invoke ("InitAds", 5f);
}

void InitAds()
{
    #if UNITY_ANDROID
    UnityEngine.Advertisements.Advertisement.Initialize ("(Android game id)");
    #elif UNITY_IOS
    UnityEngine.Advertisements.Advertisement.Initialize ("(iOS game id)");
    #endif
}

You can see game ids in services window.

We need to further investigate why this happens in this case, but seems to be related to which scene is active at the time of initialization. Although we have tested Ads SDK with multiple scenes, this case seems to be special.

/Rasmus

@rasmus-unity thank you very much, it worked on iOS! Also quite a simple workaround, didn’t think about trying it before. We can now submit our game update. :slight_smile:

EDIT: it still doesn’t work on Android. Video ok, but no callback. :frowning:
Maybe this helps: my game starts from a “Main” scene and Ads are initialized there. Then, each subsequent scene is loaded with LoadSceneAsync (additive) and merged in “Main”. I only load one scene at time.

EDIT 2: okay, on iOS, if I play and Ad, then load and merge a new scene and play another Ad, it doesn’t work anymore. So, as far as I can understand… It works only if I play Ads in the same scene as the initialization.

EDIT 3: do UnityAds now create some hidden object in the scene that must not be destroyed? Because I wipe all the GameObjects that I don’t need between a scene and the other using GetRootGameObjects (and excluding the ones I need), so I suppose I’m deleting something vital to Ads. It already happened with the hidden GameObject “IAPUtil”: I was destroying it without knowing it even existed (not nice!) and iAPs were not working.

Solved for me. Adding a new post just to notify whoever subscribed the thread.

The problem was exactly the one I suspected: there is now (I guess from 5.5.0) an hidden GameObject in the scene called “UnityAdsCallbackExecutorObject”. In fact I found it inside the GameObject array returned by GetRootGameObjects(), and since I destroy most of the stuff there, that object got destroyed too.
Keeping the object alive in the scene solved the problem both on iOS and Android.

Hi, thanks for your feedback and nice finding. We also identified same gameobject and are working on a fix for this.

Thanks for helping us identifying the root cause of this, and not least provide us with sample code for repro. As said we do have internal tests with multiple scenes, but didn’t consider removing the first scene.

/Rasmus

I’m also currently encountering the problem. I tried tagging UnityAdsCallbackExecutorObject with DontDestroyOnLoad but it still disappears when loading the next scene.

I also tried calling Advertisement.Initialize again when I don’t find the callback object, but it seems that it can’t be recreated or reinitialized.

Is it only a bug when initializing the ads on the first scene?

I know I’m reviving an old thread, but this is just to say that none of the solution I’ve found worked until I encounter your post DanjelRicci. You are right about the UnityAdsCallbackExecutorObject. This is an issue that still occur on 2017.3.0f3 and we manage to fix it by making a hotfix in our loading screen code. Thank you !

Hey guys, fast forward to 2018.1 and I believe this is still occurring. @rasmus-unity can you provide some updated guidance here?

I just shipped broken ad code into production and this thread is the only clue on the entire internet as to what might be going wrong. Do I still need to implement a special hack to make sure this executor object stays alive, or… ?

Hi, please check [Solved] Engine integrated Ads SDK broken on iOS in Unity 2018.1.0f2 - upgrade package - Unity Services - Unity Discussions , is that the issue you are experiencing?

/Rasmus

Hey guys, I bump in to similar problem as well, the reward video callback works perfect in unity editor. However, the callback does not called when it is install on Android. I am using Unity Monetization 3.0 and following tutorial here. Thanks in advance guys!

1 Like