Gerardo
Gerardo

Reputation: 5830

iAd intersitial loaded only once

I need to load an intersitial add randomly when a ViewController loads. In order to achieve this, I use this code:

self.interstitialPresentationPolicy = ADInterstitialPresentationPolicyAutomatic;

The problem is that the intersitial is loaded once, and then, it is not shown any more.

What is the problem?

Upvotes: 1

Views: 315

Answers (1)

Undo
Undo

Reputation: 25687

From the documentation, ADInterstitialPresentationPolicyAutomatic means that:

Automatic policy. The framework determines when an interstitial ad is presented.

(emphasis mine).

If you want it to be random, I think you need ADInterstitialPresentationPolicyManual, which allows you to control when an interstitial is shown:

Manual policy. The app determines when an interstitial ad should be presented. Use requestInterstitialAdPresentation to request the presentation of an interstitial ad at an appropriate time.

So use ADInterstitialPresentationPolicyManual, and call requestInterstitialAdPresentation when you want an ad to be shown.

It's unclear what you mean by "load an interstitial ad randomly", but with the manual approach you can control when you want it presented. For example, you could use the approaches in this question to generate a number between 0 and 1, inclusive, and if it's 1 show the ad. Otherwise, don't show it.

Upvotes: 3

Related Questions