Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bids Response hook #304

Merged
merged 15 commits into from
Sep 16, 2020
Merged

Bids Response hook #304

merged 15 commits into from
Sep 16, 2020

Conversation

yoalex5
Copy link
Collaborator

@yoalex5 yoalex5 commented Jun 19, 2020

A new overloaded fetchDemand function was created

func fetchDemand(completion: @escaping(_ result: ResultCode, _ kvResultDict: [String : String]?) -> Void)

This function:

  1. does not accept an AdServerObject(AdManager or MoPub) as a result it does not modify it under the hood
  2. returns Key/Value targeting pairs from auction response

Publisher is responsible for passing returned result into AdServerObject

Usage example:

Objective-C:

-(void) loadAMBanner {

    //adUnit is BannerAdUnit Type
    [self.adUnit fetchDemandWithCompletion:^(enum ResultCode resultCode, NSDictionary<NSString *,NSString *> * _Nullable targetingDict) {
        
        [self.request setCustomTargeting:targetingDict];
        [self.amView loadRequest:self.request];
    }];
}

-(void) loadMPRewardedVideo {

    //adUnit is RewardedVideoAdUnit Type
    [adUnit fetchDemandWithCompletion:^(enum ResultCode resultCode, NSDictionary<NSString *,NSString *> * _Nullable targetingDict) {
        
        NSString *keywords = [Utils.shared convertDictToMoPubKeywordsWithDict:targetingDict];
        [MPRewardedVideo loadRewardedVideoAdWithAdUnitID:@"46d2ebb3ccd340b38580b5d3581c6434" keywords:keywords userDataKeywords:nil mediationSettings:nil];
    
    }];
}

Swift:

func loadAMBanner() {
    
    //adUnit is BannerAdUnit type
    adUnit.fetchDemand { [weak self] (resultCode: ResultCode, targetingDict: [String : String]?) in
        
        self?.amRequest.customTargeting = targetingDict
        self?.amBanner.load(self?.amRequest)
    }
} 

func loadMPRewardedVideo() {

    //adUnit is RewardedVideoAdUnit type
    adUnit.fetchDemand { [weak self] (resultCode: ResultCode, targetingDict: [String : String]?) in
        
        let keywords = Utils.shared.convertDictToMoPubKeywords(dict: targetingDict)
        MPRewardedVideo.loadAd(withAdUnitID: "46d2ebb3ccd340b38580b5d3581c6434", keywords: keywords, userDataKeywords: nil, location: nil, mediationSettings: nil)
    }
}

@yoalex5 yoalex5 requested a review from ppuviarasu June 19, 2020 11:09
@yoalex5 yoalex5 linked an issue Jun 19, 2020 that may be closed by this pull request
@bszekely1 bszekely1 added this to the 1.8 milestone Jun 22, 2020
@bszekely1 bszekely1 mentioned this pull request Jun 25, 2020
…hook

# Conflicts:
#	PrebidMobile.xcodeproj/project.pbxproj
#	Source/AdUnits/AdUnit.swift
@yoalex5 yoalex5 merged commit 4bb9a98 into master Sep 16, 2020
@YuriyVelichkoPI YuriyVelichkoPI deleted the feature/response_hook branch May 20, 2022 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bids Response hook
3 participants