Implement Bidding with In-House Mediation in your iOS App

This topic explains how to integrate Bidding Kit 2.0 with your iOS app. Integration requires the following steps:

  1. Import the Bidding Kit 2.0 Module
  2. Initialize Bidding Kit 2.0
  3. Implement the FBBKWaterfall and FBBKWaterfallEntry Protocols
  4. Add Bidders
  5. Implement the FBBKAuction Protocol

1. Import the Bidding Kit 2.0 Module

Import the Bidding Kit 2.0 module into your Xcode project as follows:

  1. Drag and drop FBBiddingKit.framework into your project.
  2. Select Copy items if needed.
  3. If necessary, choose a target in the Add to targets block.
  4. Add the following umbrella header.
#import <FBBiddingKit/FBBiddingKit.h>

2. Initialize Bidding Kit 2.0

Initialize Bidding Kit 2.0 by passing an FBBKConfiguration object to the FBBKBiddingKit.initializeWithConfiguration method.

FBBKConfiguration *configuration = [[FBBKConfiguration alloc] init];
configuration.auctionTimeout = 10;
configuration.verboseLoggingEnabled = YES;
[FBBKBiddingKit initializeWithConfiguration:configuration];

3. Implement the FBBKWaterfall and FBBKWaterfallEntry Protocols

Bidding Kit 2.0 uses the FBBKWaterfall and FBBKWaterfallEntry protocols to read from and interact with your in-house implementation of a waterfall. Your application needs to conform to both of these protocols.

The following example demonstrates how to use your application's Bidding Kit 2.0 implementation to create a waterfall with two entries.

id<FBBKWaterfall> waterfall = [[Waterfall alloc] init];
[waterfall insertEntry:[[WaterfallEntry alloc] initWithName:@"NetworkA" cpm:0.3]];
[waterfall insertEntry:[[WaterfallEntry alloc] initWithName:@"NetworkB" cpm:0.2]];

4. Add Bidders

Add the bidders that will compete in your auction. The following example shows how to add a bidder for Audience Network.

The bidderToken will not be available if you have not integrated FBAudienceNetwork.framework.

#import <FBAudienceNetwork/FBAdSettings.h>

// Provide required values for the Facebook bidder.
NSString *appId = @"YOUR_APP_ID";
NSString *placementId = @"YOUR_PLACEMENT_ID";
NSString *bidToken = [FBAdSettings bidderToken];
FBBKFacebookAdBidFormat adBidFormat = FBBKFacebookAdBidFormatInterstitial;

// Create parameters for the Facebook bidder.
FBBKFacebookBidderParameters *parameters =
  [[FBBKFacebookBidderParameters alloc] initWithAppId:appId
// Set up additional fields if needed.
parameters.testMode = YES;

// Create the Facebook bidder.
FBBKFacebookBidder *facebookBidder = [[FBBKFacebookBidder alloc] initWithParameters:parameters];

Bidding Kit 2.0 also predefines bidders for the AppLovin and TapJoy ad networks. For other bidders, you can implement the FBBKBidder protocol to create an object that you can add to your auction.

#import <AppLovinSDK/AppLovinSDK.h>
#import <Tapjoy/Tapjoy.h>
#import <FBAudienceNetwork/FBAudienceNetwork.h>

// Initialize the AppLovin SDK.
[[ALSdk shared] initializeSdk];

// Initialize the Tapjoy SDK.
[Tapjoy connect:@"TAPJOY_SDK_KEY"];

// Initialize the Facebook Audience Network SDK.
[FBAudienceNetworkAds initializeWithSettings:nil completionHandler:nil];

5. Implement the FBBKAuction Protocol

Pass the bidders to your implementation of the FBBKAuction protocol.

id<FBBKAuction> auction = [[FBBKAuctionImpl alloc] initWithBidders:@{
    testA : @[facebookBidder],
    control : @[],

Set up a delegate to handle callbacks from the auction.

auction.delegate = self;

- (void)fbbkAuction:(id<FBBKAuction>)auction didCompleteWithWaterfall:(id<FBBKWaterfall>)waterfall
    // TODO: Use your waterfall to show ads.

Pass the waterfall to your auction and start it.

[auction startUsingWaterfall:auction waterfall:waterfall];