The plug-in that comes with cocos2dx3.0 includes third-party plug-ins in various aspects such as promotion and benefits, but it does not support iAd, probably because it is dedicated to IOS and there is no need to build a separate library, however, it is necessary to encapsulate an IAD plug-in for IOS in order to uniformly use the plug-in management of advertising. After a day, make a record here. If you are interested, refer to it, note: 1. If you do not need to create the XCODE library, the file structure is the same as that of the directories created in other ad libraries. There are three files in total :. pch AdsApple. h AdsApple. m 2: To join cocos2dx's PluginManager for unified management, our new class needs to inherit InterfaceAds and link iAd. framework. 3:. Go to the Code directly. Complete Note: header file: /// AdsApple // Created by kevin on 14-5-2. // Copyright (c) 20 Kevin. all rights reserved. // # import <Foundation/Foundation. h> # import "iAd/iAd. h "# import" InterfaceAds. h "// ad type typedef enum {kTypeBanner = 1, // ad column kTypeFullScreen, // full screen} AppleType; @ interface AdsApple: NSObject <InterfaceAds, ADBannerViewDelegate >{}@ property BOOL debug; @ property bool bannerVisible; @ property int bannerPos; @ property (assign, nonatomic) ADBannerView * bannerView; // set development (Void) configemediinfo: (NSMutableDictionary *) devInfo; // display advertisement-(void) showAds: (NSMutableDictionary *) info position :( int) pos; // hide the advertisement-(void) hideAds: (NSMutableDictionary *) info; // obtain the position-(void) queryPoints; // (void) spendPoints: (int) points; // switch debug mode-(void) setDebugMode: (BOOL) isDebugMode; // obtain the SDK version-(NSString *) getSDKVersion; // obtain the plug-in version-(NSString *) getPluginVersion; @ end implementation: /// AdsApple // AdsApple /// Created by kevin on 14-5-2. // Copyright (c) 2014 kevin. all rights reserved. // # import "AdsApple. h "# import" AdsWrapper. h "# define OUTPUT_LOG (...) if (self. debug) NSLog (_ VA_ARGS _); # define OUT_POS CGPointMake (-1024,-1024) @ implementation AdsApple @ synthesize debug = _ debug; // initialize-(id) init {self = [super init]; if (self) {} return self;} // release-(void) dealloc {if (Self. bannerView! = Nil) {[self. bannerView removeFromSuperview]; [self. bannerView release]; self. bannerView = nil;} [super dealloc] ;}# pragma mark InterfaceAds impl // set developer information-(void) configpolicinfo: (NSMutableDictionary *) devInfo {} // display advertisement-(void) showAds: (NSMutableDictionary *) info position :( int) pos {NSString * strType = [info objectForKey: @ "AppleType"]; int type = [strType intValue]; switch (type) {case KTypeBanner: {[self showBanner: pos]; break;} case kTypeFullScreen: OUTPUT_LOG (@ "Now not support full screen view in AppleType"); break; default: OUTPUT_LOG (@ "The value of 'appletype' is wrong (shocould be 1 or 2)"); break ;}- (void) hideAds: (NSMutableDictionary *) info {NSString * strType = [info objectForKey: @ "AppleType"]; int type = [strType intValue]; switch (type) {case kTypeBanner: {if (n Il! = Self. bannerView) {[self. bannerView removeFromSuperview]; [self. bannerView release]; self. bannerView = nil;} break;} case kTypeFullScreen: OUTPUT_LOG (@ "Now not support full screen view in AppleType"); break; default: OUTPUT_LOG (@ "The value of 'appletype' is wrong (shocould be 1 or 2)"); break ;}}-(void) queryPoints {OUTPUT_LOG (@ "AdsApple not support query points! ") ;}- (Void) spendPoints: (int) points {OUTPUT_LOG (@" AdsApple not support spend points! ");}-(Void) setDebugMode: (BOOL) isDebugMode {self. debug = isDebugMode;}-(NSString *) getSDKVersion {return @ "6.4.2";}-(NSString *) getPluginVersion {return @ "0.2.0 ";} // display the advertisement bar-(void) showBanner: (int) pos {// if yes, delete it first and recreate if (nil! = Self. bannerView) {[self. bannerView removeFromSuperview]; [self. bannerView release]; self. bannerView = nil;} // create self. bannerView = [[ADBannerView alloc] initWithFrame: CGRectZero]; self. bannerView. frame = CGRectOffset (self. bannerView. frame, 0,-50); self. bannerView. requiredContentSizeIdentifiers = [NSSet setWithObject: ADBannerContentSizeIdentifierPortrait]; self. bannerView. currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait; self. bannerView. delegate = self; [AdsWrapper addAdView: self. bannerView atPos: pos]; self. bannerView. center = OUT_POS; self. bannerPos = pos; [UIView commitAnimations]; self. bannerVisible = false;} // notice before loading the advertisement-(void) bannerViewWillLoadAd :( ADBannerView *) banner NS_AVAILABLE_IOS (5_0) {NSLog (@ "bannerViewWillLoadAd ");} // every time a new advertisement is loaded, the notification-(void) bannerViewDidLoadAd :( ADBannerView *) banner {NSLog (@ "bannerViewDidLoadAd"); if (self. bannerVisible = false) {[self. bannerView removeFromSuperview]; [AdsWrapper addAdView: self. bannerView atPos: self. bannerPos]; [UIView commitAnimations]; self. bannerVisible = true; // send an advertisement notice to the listener [AdsWrapper onAdsResult: self withRet: kAdsShown withMsg: @ "OK"];} // send the notification to the listener for receiving data [AdsWrapper onAdsResult: self withRet: kAdsReceived withMsg: @ "OK"] ;}// error-(void) bannerView :( ADBannerView *) banner didFailToReceiveAdWithError :( NSError *) error {NSLog (@ "didFailToReceiveAdWithError"); if (self. bannerVisible) {self. bannerView. center = OUT_POS; self. bannerVisible = false; // send an advertisement hidden (missed) notice to the listener [AdsWrapper onAdsResult: self withRet: kAdsDismissed withMsg: @ "OK"];} // send an advertisement to the listener for receiving data errors. [AdsWrapper onAdsResult: self withRet: kNetworkError withMsg: error. domain] ;}// when the user clicks the advertisement bar announcement, return the value BOOL to specify whether the advertisement is open-(BOOL) bannerViewActionShouldBegin :( ADBannerView *) banner willLeaveApplication :( BOOL) willLeave {NSLog (@ "bannerViewActionShouldBegin"); return TRUE;} // after the full-picture advertisement indicates that the interface is called, // After the interface is called, the current program is generally run as a background program // This interface needs to reply to the previously interrupted processing (if any)-(void) bannerViewActionDidFinish :( ADBannerView *) banner {NSLog (@ "bannerViewActionDidFinish"); // send an advertisement to the listener. Click the notification that is successfully closed. [AdsWrapper onPlayerGetPoints: self withPoints: 1] ;}@ end 4: load, display, hide, and uninstall plug-ins like other plug-ins .. # if CC_TARGET_PLATFORM = CC_PLATFORM_IOSm_pNowAdsPtl = dynamic_cast <ProtocolAds *> (PluginManager: getInstance ()-> loadPlugin ("AdsApple"); if (m_pNowAdsPtl) {m_mapAdsInfo ["AppleType"] = "1"; m_bUsingIAD = true;} # endif 5: iAd has Event Notifications before and after ad click switching. To ensure that the listening interface remains unchanged, getPoint is the listener callback after an advertisement is clicked. It is used to tip... 6: iAd is not supported in some countries. You can switch between ad platforms based on the time zone or other detection methods. I am using the number of failures detection and I will not write it here, different methods are available.