iAd or Admob integration



Version:1.0 StartHTML:0000000167 EndHTML:0000008652 StartFragment:0000000454 EndFragment:0000008636

iAds

1.To Use iAd In Your Application, You Must Join the iAd Network For more information on the iAd Network, see http://developer.apple.com/iad/.

2.The ADBannerView class allows you to dedicate a portion of a user interface screen to display a banner ad. Once created, a banner view automatically downloads new advertisements to display to the user.

3.To Display banner in your application
i.You need to add the iAd Framework in your application
ii.You can create bannerview programmatically or from an object library
Programmatically creating a portrait banner view :

ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
[self.view addSubview:adView];
4.To Allowing an action to be triggered:
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
    BOOL shouldExecuteAction = [self allowActionToRun]; // your application
implements this method
    if (!willLeave && shouldExecuteAction)
    {
        // insert code here to suspend any services that might conflict with the
advertisement
}
    return shouldExecuteAction;
}
Note:It decides whether to allow the action to be triggered. 
If the action will cover your application’s user interface, this method pauses any activities that require user interaction.

4. Below code will do Animating after a new advertisement is loaded:
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    if (!self.bannerIsVisible)
    {
        [UIView beginAnimations:@"animateAdBannerOn" context:NULL];
// Assumes the banner view is just off the bottom of the screen.
banner.frame = CGRectOffset(banner.frame, 0, -banner.frame.size.height);
[UIView commitAnimations];
self.bannerIsVisible = YES;
} }
5.The below code will remove the addbanner when add is not available
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError
*)error
{
   if (self.bannerIsVisible)
    {
        [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// Assumes the banner view is placed at the bottom of the screen.
        banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
        [UIView commitAnimations];
        self.bannerIsVisible = NO;
} }

Please Note:The BannerView will not be displayed when Wi-Fi is not available in your device 

No comments:

Post a Comment