interstitial = DFPInterstitial(adUnitID: adId)
interstitial!.loadRequest(DFPRequest())
if interstitial.isReady && !interstitial.hasBeenUsed {
interstitial.presentFromRootViewController(self)
}<script type="text/javascript" src="//googleads.g.doubleclick.net/mads/static/mad/sdk/native/api/v1/google_mobile_app_ads.js"></script>
<script>
<!--
var _admDisplayTime='[%DisplayTime%]';
function _admScreenFitting(){
var _admPImage=document.getElementById('_admPortraitImage');
var _admLImage=document.getElementById('_admLandscapeImage');
var screenWidth=window.innerWidth;
var screenHeight=window.innerHeight;
var imageRatio=480/320;
if(screenWidth>screenHeight){
//landscape mode
var newWidth=screenWidth;
var newHeight=screenWidth/imageRatio;
if(newHeight>screenHeight){
var newWidth=screenHeight*imageRatio;
var newHeight=screenHeight;
}
}
else{
//portrait mode
var newWidth=screenHeight/imageRatio;
var newHeight=screenHeight;
if(newWidth>screenWidth){
var newHeight=screenWidth*imageRatio;
var newWidth=screenWidth;
}
}
displayDensity=window.devicePixelRatio?window.devicePixelRatio:1;
if(displayDensity!=1){
_admPImage.src=('[%PortraitImageHD%]'!='')?'[%PortraitImageHD%]':_admPImage.src;
_admLImage.src=('[%LandscapeImageHD%]'!='')?'[%LandscapeImageHD%]':_admLImage.src;
}
if('[%AllowScaling%]'=='yes'){
_admLImage.width=newWidth;
_admLImage.height=newHeight;
_admPImage.width=newWidth;
_admPImage.height=newHeight;
}
_admStartCountDown();
}
function _admPreCheckForThirdParty(){
// Check for third party impression tracker
if('[%ThirdPartyImpressionTracker%]'!=''){
var thirdImp=document.createElement('IMG');
thirdImp.src='[%ThirdPartyImpressionTracker%]';
with(thirdImp.style){width='1px';height='1px';position='absolute';top='-100%'};
document.body.appendChild(thirdImp);
}
_admScreenFitting();
}
function _admStartCountDown() {
setTimeout('admob.opener.close()',parseInt(_admDisplayTime)*1000)
}
function _admOnload() {
if (admob.opener.isOverlayShowing()) {
_admStartCountDown()
} else {
admob.events.addEventListener('onshow', _admStartCountDown)
}
}
if (window.addEventListener) {
window.addEventListener("load", _admPreCheckForThirdParty, false);
window.addEventListener("resize", _admScreenFitting, false)
} else {
window.attachEvent("onload", _admPreCheckForThirdParty)
}
//-->
</script> static let gameLength = 2static let gameLength = 8 function _admStartCountDown() {
setTimeout('admob.opener.close()', parseInt(_admDisplayTime) * 1000)
}
function _admOnload() {
if (admob.opener.isOverlayShowing()) {
_admStartCountDown()
} else {
admob.events.addEventListener('onshow', _admStartCountDown)
}
}
if (window.addEventListener) {
window.addEventListener("load", _admPreCheckForThirdParty, false);
window.addEventListener("resize", _admScreenFitting, false)
} else {
window.attachEvent("onload", _admPreCheckForThirdParty)
}When you are adding an event listener for "load" and "onload", you must link that to _admOnload(). Instead, you are having your _admPreCheckForThirdParty() function and in that, you are never calling _admOnload().function _admPreCheckForThirdParty(){
// Check for third party impression tracker
if(''!=''){
var thirdImp=document.createElement('IMG');
thirdImp.src='';
with(thirdImp.style){width='1px';height='1px';position='absolute';top='-100%'};
document.body.appendChild(thirdImp);
}
_admScreenFitting();
_admOnload();
}