Wiki

Clone wiki

mobile.mng-ads.com-mngperf / mopub-adaptor-ios

iOS Mopub Adaptor

It is also possible to use MNGAds SDK with Mopub. Preliminary steps:

  • Add the Mopub-Adapter to your application's project, you can checkout our Mopub-Demo project.

  • Install MngAds and MoPub sdks to your project weither via cocoapods or manually.

  • On your mopub dashboard, create a custom network for instance called MNGMopubInterstitial and set the following class name for interstitials: MNGInterstitialCustomEvent And for native ads: MNGNativeAdCustomEvent

  • On your mopub dashboard, create new banner inventory for a custom network and add the following class name for banners: MNGBannerCustomEvent You do not need to set any other custom data on the dashboard.

customAdnetwork.jpeg

  • CUSTOM EVENT CLASS = MNGInterstitialCustomEvent

MNGInterstitialCustomEvent.jpg

  • CUSTOM EVENT CLASS = MNGBannerCustomEvent MNGBannerCustomEvent.jpg

  • CUSTOM EVENT CLASS = MNGSquareCustomEvent

MNGSquareCustomEvent.jpg

  • CUSTOM EVENT CLASS = MNGNativeAdCustomEvent

MNGNativeAdCustomEvent.jpg

  • Finally you will need to make a small change in MoPub's source, specifically in MPNativeAd.h header file, you will need to add the line below at the end of the file:
#!objective-c

- (void)willAttachToView:(UIView *)view;
  • init the MoPub Framework
#!objective c 
-(void) initMopub {

    MPMoPubConfiguration *sdkConfig = [[MPMoPubConfiguration alloc] initWithAdUnitIdForAppInitialization:@"3656387f550d401fa05d9e6524726108"];

    //AD_UNIT_ID
    sdkConfig.globalMediationSettings = @[];

    [[MoPub sharedInstance] initializeSdkWithConfiguration:sdkConfig completion:^{
        NSLog(@"SDK initialization complete");
        // SDK initialization complete. Ready to make ad requests.
    }];

}
  • Initialize the placements

// If you use interstitials [MNGInterstitialCustomEvent setPlacement("Your_Placement")];

// If you use banners [MNGBannerCustomEvent setPlacement("Your_Placement")];

// If you use native ads [MNGNativeAdCustomEvent setPlacement("Your_Placement")];

add the mainImage + IconImageView + nativeView + callToActionButton + viewController to the MNGNativeAdCustomEvent :

#!objective c [MNGNativeAdCustomEvent setMainImage:_mainImageView andIconeImage:_iconImageView andNativeView:_nativeView andButton:_callToActionLabel andWithViewController:self];

  • Use Mopub as usual You may now use MoPubInterstitial, MoPubView and MoPubAdAdapter to show interstitials, banners and native ads as usual. The adapter code and the setup you did on your Mopub dashboard will allow MNGAds to deliver ads.

Updated