prebid / prebid-mobile-ios

Prebid Mobile SDK for iOS applications
Apache License 2.0
48 stars 92 forks source link

How Prebid is working internally ? #8

Closed rohitnewscorp closed 6 years ago

rohitnewscorp commented 7 years ago

As I am implementing Prebid SDK in my app. Before this we were also showing ad so We were already using DFPBannerView . So just want to understand in implemetation we just set up sdk in Appdelegate after that I didn't find any call back from prebid side which It give us after getting the winning bid. Rather it simply load request

self.banner.load(GADRequest())

and there is no such call back while It provide call back in android.Please advise on this.

nhedley commented 7 years ago

Prebid Mobile works by requesting for additional demand in AppDelegate and if there are any bids, it attaches them as extra keywords to the DFPBannerView load method when the setBidsOnAdObject method is called. If the Prebid bids' line items win, the Prebid ad will be displayed. The functionality of Prebid is described in more detail in the documentation here -http://prebid.org/prebid-mobile/prebid-mobile.html.

Let me know if you still have questions!

rohitnewscorp commented 7 years ago

So we will not get any call back before rendering the banner in viewcontroller?

nhedley commented 7 years ago

There is no call back in the iOS code after calling the load method on DFPBannerView before rendering the banner in the ViewController.

We do have a call back after setting the bid keywords on the banner view before calling the load method, shown below. That snippet of code is from the documentation on iOS code integration (http://prebid.org/prebid-mobile/code-integration-ios.html).

[PrebidMobile setBidKeywordsOnAdObject:YOUR-AD-VIEW withAdUnitId:@"YOUR-AD-UNIT-ID-HERE" withTimeout:600 completionHandler:^{ [YOUR-AD-VIEW YOUR-ADS-LOAD-METHOD]; }];

rohitnewscorp commented 7 years ago

We have configure Id, Account Id but I am little confused about the AdUnitId. In Demo It is showing the screen name but If I have to show ad on multiple screen.

dominicfreeston commented 7 years ago

@nhedley thanks for your responses, we now understand no information is provided in the callback because the appropriate properties have been set on the advert view directly

What is the primary difference between the following two methods?

open class func setBidKeywordsOnAdObject(_ adObject: Any, withAdUnitId adUnitId: String)
open class func setBidKeywordsOnAdObject(_ adObject: Any, withAdUnitId adUnitIdentifier: String, withTimeout timeoutInMilliseconds: Int32, completionHandler handler: (() -> Swift.Void)? = nil)

The documentation mentions

your app can ask Prebid Mobile for a bid price and creative without waiting

but then shows the example with timeout and a callback block. This API suggests there may be delay before we're able to show the advert. Are you able to clarify this for us?

And finally, these MPUs are shown in a list view and as such the views might be reused - are the keys only valid for the next request, or is there something we should do to clear these when/if the view is reused?

nhedley commented 7 years ago

@rohitnewscorp AdUnitId is a unique arbitrary identifier that the client developer (you) must set. It can be whatever string you would like. We use AdUnitId to associate the bids with the appropriate ad unit.

nhedley commented 7 years ago

@dominicfreeston Both methods will set the bid keywords on the ad object immediately if bids have been returned from Prebid Server.

The difference is when a bid has not been returned from Prebid Server yet, the first method without the timeout will not set any keywords. The second method with the timeout will poll for when the bid is returned from Prebid Server and set the bid keywords on the ad object as soon as the bid is returned within the timeout.

For the final question, Prebid Mobile automatically clears the keys after they are used from the ad object, so no need to do anything on your end. If you are reusing the ad object, simply call setBidKeywordsOnAdObject again to get the current valid bids before loading the ad.

rohitnewscorp commented 7 years ago

@nhedley Thanks for your response Now One more question We are having two Configure Id that we need to register Ad unit id so Do We need to map it against one Ad unit id?

    let adUnit1 = PBBannerAdUnit.init(adUnitIdentifier: ConfigKey.prebidAdUnitID.keyValue,
                                     andConfigId: ConfigKey.prebidConfigurationID1.keyValue)

    let adUnit2 = PBBannerAdUnit.init(adUnitIdentifier: ConfigKey.prebidAdUnitID.keyValue,
                                     andConfigId: ConfigKey.prebidConfigurationID2.keyValue)

    PrebidMobile.register([adUnit1, adUnit2], withAccountId: ConfigKey.prebidAccountID.keyValue)

CC: @dominicfreeston

nhedley commented 7 years ago

Each configId maps to a list of demand sources (bidders) and any information each bidder needs (ie placementId) that is stored on the server. If you have the exact same demand sources & placements for multiple ad units, a configId can be re-used in those other ad units.

Each adUnitId must be unique to an ad unit object. Meaning adUnit1 and adUnit2 in your example must have different adUnitIds.

rohitnewscorp commented 7 years ago

@nhedley Thanks for the clarification but when we use setBidKeywordsOnAdObject method to DFPView then, How would we detect that Which adUnitId to use?

czakuma commented 7 years ago

@nhedley Just to clarify. Would each DFP or Mopub ad view need their own unique PBBannerAdUnit and thus their own adUnitId? Looking at the code in PBBidManager in startNewAuction it appears that it would clear it out for each new request, correct?

ppuviarasu commented 6 years ago

@czakuma yes your understanding is correct. each adunit would require unique adunitid to be tagged.