Keine Ergebnisse gefunden

Probeer een andere of meer specifieke zoekopdracht
Developer Console
Vielen Dank für deinen Besuch. Diese Seite ist nur in Englisch verfügbar.

Use Amazon Mobile Ads IOS API with Mediation SDKs

Banner ads and Interstitial ads from the Amazon Mobile Ad Network can also be retrieved through select mediator SDKs. General guidelines for integration are listed below.

Loading Ads from Multiple SDKs

The Amazon Mobile Ads API can be used in conjunction with other advertising SDKs. We recommend providing the Amazon Mobile Ad Network with the first look. Before loading an Amazon Ad you'll want to implement the optional callbacks for success and failure from the AmazonAdViewDelegate. If no ads were available from the Amazon Mobile Ad Network, then the adViewDidFailToLoad callback method can be used to call another ad SDK.

Below is a simple example of a program that first tries to load an ad from the Amazon Ad Network. On failure, it makes a second ad request via the other SDK.

public class SimpleAdActivity extends Activity implements AdListener
    - (void)viewDidLoad {
      [super viewDidLoad];

      // Load an ad
      // Create an AmazonAdView instance with size 320x50.
      self.amazonAdView = [AmazonAdView amazonAdViewWithAdSize:AmazonAdSize_320x50];

      // Set the adOptions.
      AmazonAdOptions *options = [AmazonAdOptions options]; options.isTestRequest = YES;

      // Register the ViewController with the delegate to receive callbacks.
      amazonAdView.delegate = self;

      // Call loadAd
      [amazonAdView loadAd:options];

Here's how you would implement the AmazonAdViewDelegate protocol within your ViewController. The viewControllerForPresentingModelView protocol method should be implemented so that the AmazonAdView is aware of the ViewController that will be used for presenting/dismissing modal views, such as the browser view when a user clicks on an Ad. You may also choose to lazily add the AmazonAdView to your parent view in the adViewDidLoad optional callback method:

// #pragma mark AmazonAdViewDelegate
// @required
- (UIViewController *)viewControllerForPresentingModalView {
  return self;

- (void) adViewDidLoad:(AmazonAdView *)view {
  NSLog(@"Ad loaded");
  if (!self.hasAmazonAdView) {
    [self.otherSDKAdView removeFromSuperview];

  // Add the AmazonAdView to your viewController’s view.
  [self.view addSubView:self.amazonAdView];
  self.hasAmazonAdView = YES;

- (void)adViewDidFailToLoad:(AmazonAdView *)view withError:(AmazonAdError *)error {
  NSLog(@"Ad Failed to load. Error code %d: %@", error.errorCode, error.errorDescription);
  if (self.hasAmazonAdView) {
    [self.amazonAdView removeFromSuperView];
  // Make an adRequest for the view of the other SDK and add it to this view.
  [self.view addSubView:otherSDKAdView];

Integrating with DFP using Custom Events

To integrate Amazon Mobile Ads API, your class which conforms to the GADCustomEventBanner protocol must implement the requestBannerAd:parameter:label:request: method to load an Amazon ad.

Below is a code excerpt based on the DFP Banner Example to load a banner ad from Amazon Ad Network.

#pragma mark GADCustomEventBanner impl

- (void)requestBannerAd:(GADAdSize)adSize
              parameter:(NSString *)serverParameter
                  label:(NSString *)serverLabel
                request:(GADCustomEventRequest *)request
    // Assumption: adSize matches one of the ad sizes available in the Amazon ad network
    // See AmazonAdOptions.h for all available sizes
    // If not, you will need to explicilty specify an amazon ad size
    amazonAdView = [AmazonAdView amazonAdViewWithAdSize:adSize.size];
    amazonAdView.delegate = self;

    // Load a test ad
    AmazonAdOptions *options = [AmazonAdOptions options];
    options.isTestRequest = YES;
    [amazonAdView loadAd:options];

#pragma mark AmazonAdViewDelegate impl

- (UIViewController *)viewControllerForPresentingModalView
    return self;

- (void) adViewDidLoad:(AmazonAdView *)view
    // Place the Amazon ad view at the appropriate place.
    // In this example, we place it at the bottom since the google ad is already at top.
    self.amazonAdView.frame = CGRectMake(0, self.view.frame.size.height - amazonAdView.frame.size.height,
                                         self.amazonAdView.frame.size.width, self.amazonAdView.frame.size.height);

    [self.view addSubview:self.amazonAdView];
    NSLog(@"Amazon ad loaded");
    [self.delegate customEventBanner:self didReceiveAd:amazonAdView];

- (void)adViewDidFailToLoad:(AmazonAdView *)view withError:(AmazonAdError *)error
    NSLog(@"Amazon ad Failed to load. Error code %d: %@", error.errorCode, error.errorDescription);
    NSError *err = [NSError errorWithDomain:@"AmazonAdError" code:error.errorCode userInfo:nil];
    [self.delegate customEventBanner:self didFailAd:err];

- (void)adViewWillExpand:(AmazonAdView *)view
    NSLog(@"Amazon ad will expand");
    [self.delegate customEventBannerWillPresentModal:self];

- (void)adViewDidCollapse:(AmazonAdView *)view
    NSLog(@"Amazon ad has collapsed");
    [self.delegate customEventBannerDidDismissModal:self];