Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Minimizing app on Android during ad skips the ad

Discussion in 'Unity Ads & User Acquisition' started by unitynoob24, Jun 28, 2023.

  1. unitynoob24

    unitynoob24

    Joined:
    Dec 27, 2014
    Posts:
    398
    Hey guys,

    I've implemented opt in video reward ads and forced interstitial video ads in my mobile game for iOS and Android.

    Everything seems to be working great. Unity version 2020.3.45f1 and Advertisement 4.3.0 - doing a round of QA uncovered that during an ad on Android, you can just take the app out of focus and open the app back up and the ad is gone. On iOS this is not the case and the ad will resume where it was when you swiped away from the app.

    Thoughts on how I can address this? Thanks!
     
  2. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    597
    One of the reason is the launchMode is singleTask. Please check the androidmanifest.xml of this app, and if the launchMode is singleTask, you can try to change it to standard.
     
  3. unitynoob24

    unitynoob24

    Joined:
    Dec 27, 2014
    Posts:
    398
    So I have a bit more information now. If an ad starts, I can hit the home button during the ad, then select the app from the mini view and it when it goes back into the app the ad will resume/restart. The issue seems to only be if I hit the home button during an ad then re-open the app via the app icon. The ad is then 100% stepped over every time doing it this way.

    So I started working on setting up a solution to detect if an ad was started and the app loses focus. I have it all set up with my pattern and working perfectly in the editor. But on device its never calling OnApplicationFocus or OnApplicationPause.

    I have not checked the androidmanifest - I would prefer not making tweaks there if at all possible, unless that is the only way I can get around this issue.
     
  4. craftercis

    craftercis

    Joined:
    Nov 27, 2017
    Posts:
    16
    Hello!

    Did you solved the problem by any chance?
     
  5. unitynoob24

    unitynoob24

    Joined:
    Dec 27, 2014
    Posts:
    398
    Yea, it got kind of hacky due to a bunch of other issues I discovered on Android specifically - Apple was always totally fine. Basically when you do that action (on Android) it is actually skipping the ad.. even for an unskippable ad lol so I added a check for if the non skippable ad was being skipped and then I flagged it as an 'exploit' and firing my own event to then tell the user they need to finish watching the ad.

    There were also issues I was running into where doing this in rapid succession could cause load/show ad error callbacks (again, Android only) and for those I also had to wrap some extra checks. It depends how granular you want to be. To solve that basically if the ad instance threw an error or if the user 'exploited' I would put a message on the screen saying that there was an error / or a reminder to watch the ad (reward only) entirely - with a 10 second count down. This time buffer seemed to fix the load/show errors.

    There was also an issue on Android 14 where if you interacted with the ad at all it was firing the OnShowClick which I wasn't handling originally which then also was breaking everything, so I added an event for that as well. Then basically in my app, when I want to show an ad I have the stuff that happens if the ad succeeds, the stuff that happens if the ad fails / clicks / exploits - then I create a new ad instance, add my callbacks to it then play the ad.

    Non-rewarded ads were a little more complicated for me to figure out with all of the errors on Android because I do allow skips for those but with a skip cap and made them time based, so basically the app has points in gameplay where it will try to play an ad, but the ad will only play if the time elapsed was over a threshold then upon not skipping that ad the counter would reset - and if they skipped a skippable ad 3 times the 4th time would make that ad non-skippable.

    TL;DR Android 14 on Pixel phones specifically were giving me a ton of issues but I was able to mostly get them all smoothed over with a lot of error checking and custom logic. :)