Reputation: 607
I have my interstitial ads set up in a way where if the user dies 4 times then a full page ads pops up. numberOfLoses increases everytime the player dies.
numberOfLosses++
if numberOfLosses == 4 {
gameViewController?.showFullScreenAd()
numberOfLosses = 0
}
this works on the simulator and on my device the first time, but then i never see it working again, no matter how many times I die. Is this something that will work once its live on the app store or am i doing something wrong?
func showFullScreenAd() {
interstitial.delegate = self
self.interstitialPresentationPolicy = ADInterstitialPresentationPolicy.Manual
self.requestInterstitialAdPresentation()
}
if i println(self.requestInterstitialAdPresentation()) i get false after the first time
here is my updated code (works but multiple ads being loaded at same time)
//MARK: interstitial ad delegate
func showFullScreenAd() {
viewForAd = UIView(frame: screenbounds)
viewForAd.frame = CGRectOffset(viewForAd.frame, 0, screenbounds.size.height)
self.view.addSubview(viewForAd)
iADInterstitial = ADInterstitialAd()
iADInterstitial.delegate = self
self.interstitialPresentationPolicy = ADInterstitialPresentationPolicy.Manual
self.requestInterstitialAdPresentation()
}
func interstitialAdDidUnload(interstitialAd: ADInterstitialAd!) {
iADInterstitial = nil
println("did unload")
}
func interstitialAd(interstitialAd: ADInterstitialAd!, didFailWithError error: NSError!) {
viewForAd.removeFromSuperview()
viewForAd = nil
iADInterstitial = nil
println("failed with error: \(error.localizedDescription)")
}
func interstitialAdDidLoad(interstitialAd: ADInterstitialAd!) {
println("Ad did load")
iADInterstitial.presentInView(viewForAd)
UIView.beginAnimations("", context: nil)
viewForAd.frame = CGRectOffset(viewForAd.frame, 0, -screenbounds.size.height)
UIView.commitAnimations()
}
func interstitialAdActionDidFinish(interstitialAd: ADInterstitialAd!) {
UIView.beginAnimations("", context: nil)
viewForAd.frame = CGRectOffset(viewForAd.frame, 0, screenbounds.size.height)
UIView.commitAnimations()
println("action did finish")
}
Upvotes: 3
Views: 1355
Reputation: 1904
You don't need interstitial.delegate = self
(and whatever other code you've not shown that goes along with it.)
You only need two or three lines of code:
// Preloads an ad, so call on app startup (optional but recommended).
[UIViewController prepareInterstitialAds];
// Call once on your viewController when you create it.
self.interstitialPresentationPolicy = ADInterstitialPresentationPolicyManual;
// Call when you want to show an ad (will show if one is available)
[self requestInterstitialAdPresentation];
Thats all there is to the new methods in iOS 7. Whatever other code you have may be causing problems so remove it, and if you still have problems (especially in test with 100% fill rate) then that needs further investigation.
Upvotes: 2