Search code examples
iphoneobjective-ciadbanner-ads

How do you run a function when an iAd is clicked?


I have read up on the iAd docs and am familiar with the delegate methods and there doesn't appear to be a method that runs when an iAd Banner ad is clicked.

I want to be able to pause the game when the ad is clicked:

[self pause];

Is there an App Delegate method that runs or some other method that I can run so I can accomplish this?


Solution

  • Use these delegate methods of iAD :

    Called when the user tapped banner view.

    - (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
    {
       [self pause]
       return YES;
    }
    

    Called after a banner view finishes executing an action that covered your application’s user interface.

    - (void)bannerViewActionDidFinish:(ADBannerView *)banner
    { 
       [self play]
    }