swiftmetaprogrammingadsfacebook-audience-network

Swift Show Meta Audience Network Native Ad


I am using Facebook's Audience Network SDK to show a native ad in my app. The question is:

Where should we get the Bid Payload String to populate the field?

Code:

private func loadFacebookAd() {

    // Remove the previous view before loading a new one
    adView?.removeFromSuperview()

    // Create a native ad request with a unique placement ID (generate your own on the Facebook app settings).
    // Use different ID for each ad placement in your app.
    let ad = FBNativeAd(placementID: "PLACEMENT_ID")

    // Set the delegate of the ad object before loading the ad
    ad.delegate = self

    // TODO: - Initiate a request to load an ad. What goes in the bid payload field?
    ad.loadAd(withBidPayload: <#T##String#>)
}

Solution

  • According to this link you get the bid payload by making a request to an auction server, presumably used for mediation. The response contains the bid payload which can then be used to load an ad.

    self.payload = json[@"bid_payload"];
    

    The documentation in my opinion seems a little outdated though.