I have added full screen Ads in my application but when i click on the cross button on the full screen Ads to close the Ads page and simultaneously click on the Ads Page to open the test window it sometimes gives error message attempt to call method 'didRemoveListener' a nil value, i have added code what i am writing in my application below, Please help to sort out this problem, thanks...
local RevMob = require("revmob")
display.setStatusBar(display.HiddenStatusBar)
local fullscreen
local revmobListener
local storyboard = require "storyboard"
local REVMOB_IDS = {
["Android"] = "",
["iPhone OS"] = ""
}
RevMob.startSession(REVMOB_IDS)
RevMob.setTestingMode(RevMob.TEST_WITH_ADS)
local function ShowAds()
fullscreen.RevMob.createFullscreen()
RevMob.showFullscreen(revmobListener, REVMOB_IDS)
end
revmobListener=function(event)
if(event.type=="adClicked" then
fullscreen:hide()
storyboard.gotoScene("scenes.Scene1")
elseif event.type=="adClosed" then
fullscreen:hide()
storyboard.gotoScene("scenes.Scene1")
end
ShowAds()
A way to solve it. Just accept the first touch.
local clicked = false
revmobListener=function(event)
if(event.type=="adClicked" and not clicked then
fullscreen:hide()
storyboard.gotoScene("scenes.Scene1")
clicked = true
elseif event.type=="adClosed" and not clicked then
fullscreen:hide()
storyboard.gotoScene("scenes.Scene1")
clicked = true
end
Related
I'm trying to add a reward AdMob video to my app my code in onCreate is
Android.Gms.Ads.MobileAds.Initialize(ApplicationContext, "APP_CODE" );
mRewardedVideoAd = MobileAds.GetRewardedVideoAdInstance(this);
mRewardedVideoAd.RewardedVideoAdListener = this;
mRewardedVideoAd.LoadAd(#"ca-app-pub-3940256099942544/5224354917",
new AdRequest.Builder().Build());
when i try to show the video by the following code
if (mRewardedVideoAd.IsLoaded)
mRewardedVideoAd.Show();
the mRewardedVideoAd.IsLoaded always return false
Is There any solution for this?
I've integrated Vungle video ads in my Corona Game it was working perfect but few days ago it stopped caching video ads completely, but after few days it stared it self without changing any thing in code. Now it again stopped caching video ads. I suspect this issue is either from Corona or Vungle side but am not sure.
local vungleInterstitial = "540e9681c7ec2b6d4400000e"
local videoCompletedCallback=nil
videoAddListener=function( event )
if (event.isError ) then
--Cached video ad not available for display
print("problem to show ad")
elseif event.type == "cachedAdAvailable" then
print("cachedAdAvailable")
elseif tostring(event.type) == "adView" then
print("called when add is viewed")
elseif event.type == "adStart" then
print("Corona ads started")
audio.pause()
elseif event.type == "adEnd" then
print("Corona ads ended")
videoCompletedCallback()
audio.resume()
end
end
showVideoAd = function(callbackFunc)
print("showVideoAd function called")
videoCompletedCallback=callbackFunc;
if ( vads.isAdAvailable() ) then
print(" if ( vads.isAdAvailable() ) then, is true")
print("vads.show")
vads.show( "interstitial", { isBackButtonEnabled = false } )
else
local alert = native.showAlert( "Video Ad", "The Video Ad is not available at the moment. Please Try after some time.", { "OK" } )
end
end
vads.init("vungle",vungleInterstitial,videoAddListener)
This might be related to geo or daily view limits.. can you try with vungleTest as your AppID? Also, if you have further questions, feel free to email me at tech-support#vungle.com
Cheers,
Jordyn / Vungle
I am trying to load an interstitial ad before actually showing it so that I can avoid lag. However everything I have tried has failed. With this code no ad ever appears:
local ads = require( "ads" )
ads.init( "admob", "ca-app-pub-2823622942892345/4361536298", adListener )
ads.load( "interstitial", { appId="ca-app-pub-2823622942892345/4361536298",
testMode=false } )
local function adListener( event )
if ( event.isError ) then
--Failed to receive an ad
else
ads.show( "interstitial", { x=0, y=0, appId="ca-app-pub-2823622942892345/4361536298" } )
end
end
With this code the ad loads but with lag...
local ads = require( "ads" )
ads.init( "admob", "ca-app-pub-2823622942892345/4361536298", adListener )
ads.load( "interstitial", { appId="ca-app-pub-2823622942892345/4361536298", testMode=false } )
ads.show( "interstitial", { x=0, y=0, appId="ca-app-pub-2823622942892345/4361536298" } )
Does anyone now why it does not work? If so how can I resolve it?
In your first example, your adListener function won't work. Since it's a local function and declared after you use it the first time, it will be nil on that first use. That function needs to be higher up in your code before it's used the first time.
In your second example, the ads.load() is an asynchronous call, that means we know it can take a while to work, so control returns to your app immediately and then you call ads.show() before the as has loaded and therefore nothing shows.
There is a tutorial that may help you with this:
http://coronalabs.com/blog/2014/07/15/tutorial-implementing-admob-v2/
How do i implement vungle in to corona sdk for only one scene. I followed the docs on corona site to implement vungle to my game. I implemented in only one scene of my game but it shows in every scene randomly, my question is how do i keep the vungle in only one scene.
I use also inmobi ads in game.
Here is the code i used.
I used this code in only one scene of my game.
local provider = "vungle"
local appId = "vungleTest"
local ads = require "ads"
local function adListener( event )
if event.type == "adStart" and event.isError then
-- cached video ad not available for display
end
end
ads.init( provider, appId, adListener )
local wasAdShown = ads.show( "interstitial", { isAnimated = false, isBackButtonEnabled = true } )
You didn't post all of your source so it's hard to tell the exact problem. It seems to me that you need to have some logic around the variable wasAdShown, also you might want to make it a global variable.
I would do something like this:
wasAdShown = false
if wasAdShown == false then
ads.show( "interstitial", { isAnimated = false, isBackButtonEnabled = true } )
wasAdShown = true
else
print "Ad Was Shown Already"
end
do it like this
if (ads.isAdAvailable()) then
local adShown = ads.show("interstitial", { isAnimated = false })
end
otherwise when ad get cached(loaded) it come to screen.
I have an application that requires a page refresh whenever the orientation changes (ipad/iphone). Within this application, HTML5 videos also gets presented at certain times in UX. Whenever a user is viewing a video in full screen mode, their first inclination is to rotate the device to landscape orientation if it was not already in that mode. When they do this, however, it triggers the nasty page reload, effectively ending their viewing session. By tapping into webkit full screen API I was able to write logic to control this behavior, which works perfectly on Safari desktop as well as with the iPad/iPhone user agent selected in developer tools, but it DOES NOT work on the native iphone/ipad.
document.webkitIsFullScreen returns false/true correctly in console in Safari, but comes up as undefined on iphone/ipad. Can anyone tell me how to accomplish this on ipad/iphone, since these are the only devices that require this functionality anyway? Or is there a much simpler solution that I am overlooking? Any help is greatly appreciated!
$(document).ready( function () {
var video = document.getElementById('video');
var canrefresh = true;
video.addEventListener("webkitfullscreenchange",function(){
// Detects if video is in full screen mode and toggles canrefresh variable
// canrefresh = false when webkitfullscreenchange event is heard
// canrefresh = true after exiting full screen
if (canrefresh == true) {
canrefresh = false;
} else {
canrefresh = true;
}
console.log(document.webkitIsFullScreen+' | '+canrefresh);
}, false);
$(window).resize(function() {
// Look to make sure not in full screen, and canrefresh variable is true before refreshing page
if((document.webkitIsFullScreen == false) && (canrefresh == true)){
window.location = window.location.href+'?v='+Math.floor(Math.random()*1000);
}
});
console.log(document.webkitIsFullScreen+' | '+canrefresh);
$('body .test').text(document.webkitIsFullScreen+' | '+canrefresh); // document.webkitIsFullScreen is returning 'false' in Safari (correct), but 'undefined' on native iphone/ipad device
});
The equivalent property which is compatible with Mobile Safari is the webkitDisplayingFullscreen property on the HTMLVideoElement DOM object.