I have used AppLovin Ad Network to display fullscreen ads within the game.
So I want to turn off game music when fullscreen ad displayed and again turn on game music when fullscreen ad closed by the game player.
I have followed this guideline:
Unity3d Integration
Here we have different listeners available:
Ad Listeners in Unity
I was getting the problem in iOS only in Android automatically game background music gets paused and played again when I closed the fullscreen ad.
Code that I have tested up to now:
public void ShowAppLovinInsterstitial()
{
// Showing utilizing PreloadInterstitial and HasPreloadedInterstitial
if (AppLovin.HasPreloadedInterstitial())
{
// An ad is currently available, so show the interstitial.
AppLovin.ShowInterstitial();
#if UNITY_IOS
SoundManager.Instance.EnableGameMusic(false);
#endif
}
else
{
// No ad is available. Perform failover logic...
AppLovin.PreloadInterstitial();
}
}
void onAppLovinEventReceived(string ev)
{
if (ev.Contains("HIDDENINTER"))
{
// Ad ad was closed. Resume the game.
// If you're using PreloadInterstitial/HasPreloadedInterstitial, make a preload call here.
#if UNITY_IOS
SoundManager.Instance.EnableGameMusic(true);
#endif
AppLovin.PreloadInterstitial();
}
else if (ev.Contains("CLOSEDFULLSCREEN"))
{
#if UNITY_IOS
SoundManager.Instance.EnableGameMusic(true);
#endif
}
}
At present, game music gets paused after fullscreen ad displayed. On fullscreen ad, it was not again started.
Please give me some suggestion for the gameplay music turn on and off during fullscreen ads display.
Related
First, my problem is not this:
Unity - Admob hide banner doesn't work
I'm using Admob in Unity 2018.4.2f1
My problem is, everything work great on test id, but in the real id, the banner won't get destroyed or at least be hidden.
This is my code:
public void HideBanner()
{
lock (_syncRoot)
{
if (bannerView != null)
{
bannerView.Hide();
bannerView.Destroy();
this.BannerAdState = AdState.None;
}
}
}
My device can't test with the real AdmobID so I don't know what happened, but my client always feedbacks that the banner overdrawing the game's buttons in the Game Result Screen.
But I called AdsManager.Instance.HideBanner() when started Game Result Screen, and it work fine on test id. I don't know why it doesn't hide in the real id.
Thank you all.
I'm trying to add reward video from AppLovin to my application. Interstitial is work perfectly. But Reward video return "LOADREWARDEDFAILED".
Here is the part where I initialize
AppLovin.SetSdkKey(SDKKey);
AppLovin.InitializeSdk();
AppLovin.PreloadInterstitial();
AppLovin.LoadRewardedInterstitial();
AppLovin.SetUnityAdListener("ApplovinListener");
// AppLovin.SetTestAdsEnabled("true");
Here is the part where should be show
if (AppLovin.IsIncentInterstitialReady())
AppLovin.ShowRewardedInterstitial();
else
AppLovin.LoadRewardedInterstitial();
Message from xcode:
LOADREWARDEDFAILED
ApplovinListener:onAppLovinEventReceived(String)
So Ive been following this tutorial for implementing real time multiplayer with google play services for unity Tutorial. However I got stuck on part two whenever I test it between two devices I happen to use android. It wont move to the game scene It just hangs out in the main menu. I have not used adb but I have been able to invite people.
public void OnRoomConnected(bool success)
{
if (success)
{
ShowMpStatus("We are connected");
lobbyListener = null;
SceneManager.LoadScene(1);
} else
{
ShowMpStatus("Sorry not connected");
}
Try using this to load and send you to the next scene.
SceneManager.LoadScene ("OtherSceneName", LoadSceneMode.Single);
https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadScene.html
https://docs.unity3d.com/ScriptReference/SceneManagement.LoadSceneMode.html
Ive opted towards RevMob since the iAd network isn't accepting new apps and I'm trying to put a video ad after a round of my game is played like this:
func gameOver() {
RevMobAds.session().fullscreen().loadVideo()
RevMobAds.session().fullscreen().showVideo()
let transition = SKTransition.fadeWithDuration(0.5)
let gameScene = GameOver(size: self.size)
self.view!.presentScene(gameScene, transition: transition)
}
My fullscreen and banner ads are working perfectly, but when I end the game to load the video, I get this in the console with no ad being shown:
[RevMob] Ad received: (200) - 56ba71998e700003764c65b9
Is anyone else having this problem? If so, have you fixed it?
We have changed our documentation, please checkout the updated one here.
What I believe is happening is that you are not saving the fullscreen object. You should create a fullscreen object and save it into a variable:
video = RevMobAds.session().fullscreen()
Then you can load a video ad into the fullscreen object: video!.loadVideo()
And then showVideo on the fullscreen object: video!.showVideo()
Note that loadVideo() is an asynchronous call, so you should either call the methods with completion handlers or extend our delegate classes.
Best regards,
I have successfully integrated a working movie player with a pre-roll iAd video! Thanks to #Daniel Storm. However, I want information on how to exit the movie when the movie is finished or when the ad is finished. (exit means remove from the view), Also detect if the user has watched the ad. If there is internet connection failure or iAd failure, how can i detect if the pre-roll ad did not play.
I am making a game, and if a user decides to get more coins, that person must watch an ad. If they click on the watch ad button, I want to detect if the ad loaded successfully so that person can get coins after they watch the ad. Once the ad finishes I want to dismiss the MPMoviePlayerController view.
Thank you for your help!
Edit:
Is this correct? :
Is it ok to remove the MPMoviePlayerViewController from the view after it is played like this?: Is this the correct way to remove it?
moviePlayer.playPrerollAdWithCompletionHandler { (error) -> Void in
NSLog("\(error)")
self.moviePlayer.view.removeFromSuperview()
I am supposing this is correct because it removes the view, but is this what apple intends us to do?