GoogleMobileAds-BidMachine-Adapters 1.9.5.7

GoogleMobileAds-BidMachine-Adapters 1.9.5.7

Appodeal ownerAppodealAppodeal 维护。



 
依赖项
BDMIABAdapter~> 1.9.5.1
Google-Mobile-Ads-SDK~> 10.11.0
 

  • Stack

BidMachine iOS

BidMachine IOS AdMob HeaderBidding 示例

入门

将以下行添加到您的项目Podfile中
target 'Target' do
  project 'Project.xcodeproj'
  pod 'GoogleMobileAds-BidMachine-Adapters', '~> 1.9.5.0'
end

注意:如果您想使用BidMachine Header Bidding,请,另外也添加以下行

target 'Target' do
  project 'Project.xcodeproj'
  pod 'GoogleMobileAds-BidMachine-Adapters', '~> 1.9.5.0'
  pod "BDMAdColonyAdapter", "~> 1.9.5.0"
  pod "BDMAmazonAdapter", "~> 1.9.5.0"
  pod "BDMCriteoAdapter", "~> 1.9.5.0"
  pod "BDMFacebookAdapter", "~> 1.9.5.0"
  pod "BDMMyTargetAdapter", "~> 1.9.5.0"
  pod "BDMSmaatoAdapter", "~> 1.9.5.0"
  pod "BDMTapjoyAdapter", "~> 1.9.5.0"
  pod "BDMVungleAdapter", "~> 1.9.5.0"
  pod "BDMPangleAdapter", "~> 1.9.5.0"
end

初始化SDK

警告:在初始化AdMob SDK之前,您应该启动BM SDK。在启动之前,必须设置BM SDK的所有参数。

注意: storeURLstoreId - 是必需参数

    BDMSdkConfiguration *config = [BDMSdkConfiguration new];
    config.testMode = YES;

    config.targeting = BDMTargeting.new;
    config.targeting.storeURL = [NSURL URLWithString:@"https://storeUrl"];
    config.targeting.storeId = @"12345";

    [BDMSdk.sharedSdk startSessionWithSellerID:@"5"
                                 configuration:config
                                    completion:nil];
您的初始化实现应类似于下面这样
    BDMSdkConfiguration *config = [BDMSdkConfiguration new];
    config.testMode = YES;

    config.targeting = BDMTargeting.new;
    config.targeting.storeURL = [NSURL URLWithString:@"https://storeUrl"];
    config.targeting.storeId = @"12345";

    [BDMSdk.sharedSdk startSessionWithSellerID:@"5"
                                 configuration:config
                                    completion:^{

        [[GADMobileAds sharedInstance] startWithCompletionHandler:^(GADInitializationStatus * _Nonnull status) {
            NSDictionary *statuses = status.adapterStatusesByClassName;
            NSLog(@"%@", [statuses.allKeys componentsJoinedByString:@","]);
        }];
    }];
以下示例中,设置了所有参数的方法

注意: storeIdstoreURL是必需的。其他参数是可选的。

    BDMSdkConfiguration *config = [BDMSdkConfiguration new];

    config.baseURL = [NSURL URLWithString:@"https://baseURL"];
    config.testMode = YES;
    config.targeting = BDMTargeting.new;
    config.targeting.userId = @"userId";
    config.targeting.gender = kBDMUserGenderFemale;
    config.targeting.yearOfBirth = @(1990);
    config.targeting.keywords = @"keywords";
    config.targeting.blockedCategories = @[@"bcat1", @"bcat2"];
    config.targeting.blockedAdvertisers = @[@"badv1", @"badv2"];
    config.targeting.blockedApps = @[@"bapp1", @"bapp2"];
    config.targeting.country = @"country";
    config.targeting.city = @"city";
    config.targeting.zip = @"zip";
    config.targeting.storeURL =  [NSURL URLWithString:@"https://storeUrl"];
    config.targeting.storeId = @"12345";
    config.targeting.paid = YES;
    config.targeting.storeCategory = @"storeCat";
    config.targeting.storeSubcategory = @[@"subcat1", @"subcat2"];
    config.targeting.frameworkName = BDMNativeFramework;
    config.targeting.deviceLocation = [[CLLocation alloc] initWithLatitude:1 longitude:2];
    
    BDMSdk.sharedSdk.publisherInfo = [BDMPublisherInfo new];
    BDMSdk.sharedSdk.publisherInfo.publisherId = @"pubId";
    BDMSdk.sharedSdk.publisherInfo.publisherName = @"pubName";
    BDMSdk.sharedSdk.publisherInfo.publisherDomain = @"pubdomain";
    BDMSdk.sharedSdk.publisherInfo.publisherCategories = @[@"pubcat1", @"pubcat2"];
    
    BDMSdk.sharedSdk.restrictions.coppa = YES;
    BDMSdk.sharedSdk.restrictions.subjectToGDPR = YES;
    BDMSdk.sharedSdk.restrictions.hasConsent = YES;
    BDMSdk.sharedSdk.restrictions.consentString = @"consentString";
    BDMSdk.sharedSdk.restrictions.USPrivacyString = @"usPrivacy";
    
    BDMSdk.sharedSdk.enableLogging = YES;
    [BDMSdk.sharedSdk startSessionWithSellerID:@"5"
                                 configuration:config
                                    completion:nil];
如果您正在使用Header Bidding网络,则需要进行如下参数设置

BidMachine文档中描述了所有网络所需字段和价值类型。(WIKI)。如果广告网络有初始化参数,则应在中介配置对象的根位置添加。广告单元特定的参数应添加到广告单元对象的根位置。

    BDMSdkConfiguration *config = [BDMSdkConfiguration new];

    config.targeting = BDMTargeting.new;
    config.targeting.storeURL = [NSURL URLWithString:@"https://storeUrl"];
    config.targeting.storeId = @"12345";

    config.networkConfigurations = @[[BDMAdNetworkConfiguration buildWithBuilder:^(BDMAdNetworkConfigurationBuilder *builder) {
        builder.appendName(@"criteo");
        builder.appendNetworkClass(NSClassFromString(@"BDMCriteoAdNetwork"));
        builder.appendParams(@{@"publisher_id": @"XXX"});
        builder.appendAdUnit(BDMAdUnitFormatBanner320x50, @{ @"ad_unit_id": @"XXX" }, nil);
    }]];

    [BDMSdk.sharedSdk startSessionWithSellerID:@"5"
                                 configuration:config
                                    completion:nil];

横幅实现

首先您需要创建一个请求并执行它

    self.request = [BDMBannerRequest new];
    self.request.adSize = BDMBannerAdSize320x50;
    [self.request performWithDelegate:self];

请求轮询后,您需要保存请求以供出价 [BDMRequestStorage.shared saveRequest:request];

#pragma mark - BDMRequestDelegate

- (void)request:(BDMRequest *)request completeWithInfo:(BDMAuctionInfo *)info {
    // After request complete loading application can lost strong ref on it
    // BidMachineFetcher will capture request by itself
    self.request = nil;
    // Save request for bid
    [BDMRequestStorage.shared saveRequest:request];
    // Here we define which Admob ad should be loaded
    [self makeRequest];
}

然后您可以创建AdMob对象并加载它

- (void)makeRequest {

    self.bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
    self.bannerView.delegate = self;
    self.bannerView.adUnitID = @UNIT_ID;
    self.bannerView.rootViewController = self;
    self.bannerView.translatesAutoresizingMaskIntoConstraints = YES;
    self.bannerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

    GADRequest *request = [GADRequest request];
    [self.bannerView loadRequest:request];
}

MREC实现

首先您需要创建一个请求并执行它

    self.request = [BDMBannerRequest new];
    self.request.adSize = BDMBannerAdSize300x250;
    [self.request performWithDelegate:self];

请求轮询后,您需要保存请求以供出价 [BDMRequestStorage.shared saveRequest:request];

#pragma mark - BDMRequestDelegate

- (void)request:(BDMRequest *)request completeWithInfo:(BDMAuctionInfo *)info {
    // After request complete loading application can lost strong ref on it
    // BidMachineFetcher will capture request by itself
    self.request = nil;
    // Save request for bid
    [BDMRequestStorage.shared saveRequest:request];
    // Here we define which Admob ad should be loaded
    [self makeRequest];
}

然后您可以创建AdMob对象并加载它

- (void)makeRequest {
  
    self.bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeMediumRectangle];
    self.bannerView.delegate = self;
    self.bannerView.adUnitID = @UNIT_ID;
    self.bannerView.rootViewController = self;
    self.bannerView.translatesAutoresizingMaskIntoConstraints = YES;
    self.bannerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

    GADRequest *request = [GADRequest request];
    [self.bannerView loadRequest:request];
}

插屏广告实现

首先您需要创建一个请求并执行它

    self.request = [BDMInterstitialRequest new];
    [self.request performWithDelegate:self];

请求轮询后,您需要保存请求以供出价 [BDMRequestStorage.shared saveRequest:request];

#pragma mark - BDMRequestDelegate

- (void)request:(BDMRequest *)request completeWithInfo:(BDMAuctionInfo *)info {
    // After request complete loading application can lost strong ref on it
    // BidMachineFetcher will capture request by itself
    self.request = nil;
    // Save request for bid
    [BDMRequestStorage.shared saveRequest:request];
    // Here we define which Admob ad should be loaded
    [self makeRequest];
}

然后您可以创建AdMob对象并加载它

- (void)makeRequest {
    GADRequest *request = [GADRequest request];
    [GADInterstitialAd loadWithAdUnitID:@UNIT_ID request:request completionHandler:^(GADInterstitialAd * _Nullable interstitialAd, NSError * _Nullable error) {
        if (error) {
            // fail load
        } else {
            self.interstitial = interstitialAd;
            self.interstitial.fullScreenContentDelegate = self;
        }
    }];
}

奖励广告实现

首先您需要创建一个请求并执行它

    self.request = [BDMRewardedRequest new];
    [self.request performWithDelegate:self];

请求轮询后,您需要保存请求以供出价 [BDMRequestStorage.shared saveRequest:request];

#pragma mark - BDMRequestDelegate

- (void)request:(BDMRequest *)request completeWithInfo:(BDMAuctionInfo *)info {
    // After request complete loading application can lost strong ref on it
    // BidMachineFetcher will capture request by itself
    self.request = nil;
    // Save request for bid
    [BDMRequestStorage.shared saveRequest:request];
    // Here we define which Admob ad should be loaded
    [self makeRequest];
}

然后您可以创建AdMob对象并加载它

- (void)makeRequest {
    GADRequest *request = [GADRequest request];
    [GADRewardedAd loadWithAdUnitID:@UNIT_ID request:request completionHandler:^(GADRewardedAd * _Nullable rewardedAd, NSError * _Nullable error) {
        if (error) {
            // fail load
        } else {
            self.rewarded = rewardedAd;
            self.rewarded.fullScreenContentDelegate = self;
        }
    }];
}

原生广告实现

首先您需要创建一个请求并执行它

    self.request = [BDMNativeAdRequest new];
    [self.request performWithDelegate:self];

请求轮询后,您需要保存请求以供出价 [BDMRequestStorage.shared saveRequest:request];

#pragma mark - BDMRequestDelegate

- (void)request:(BDMRequest *)request completeWithInfo:(BDMAuctionInfo *)info {
    // After request complete loading application can lost strong ref on it
    // BidMachineFetcher will capture request by itself
    self.request = nil;
    // Save request for bid
    [BDMRequestStorage.shared saveRequest:request];
    // Here we define which Admob ad should be loaded
    [self makeRequest];
}

然后您可以创建AdMob对象并加载它

- (void)makeRequest {
    GADRequest *request = [GADRequest request];
    [self.nativeLoader loadRequest:request];
}

- (GADAdLoader *)nativeLoader {
    if (!_nativeLoader) {
        _nativeLoader = [[GADAdLoader alloc] initWithAdUnitID:@UNIT_ID
                                           rootViewController:self
                                                      adTypes:@[kGADAdLoaderAdTypeNative]
                                                      options:@[self.viewOptions, self.videoOptions, self.mediaOptions]];
        _nativeLoader.delegate = self;
    }
    return _nativeLoader;
}

- (GADAdLoaderOptions *)videoOptions {
    GADVideoOptions *options = GADVideoOptions.new;
    options.startMuted = YES;
    return options;
}

- (GADAdLoaderOptions *)mediaOptions {
    GADNativeAdMediaAdLoaderOptions *options = GADNativeAdMediaAdLoaderOptions.new;
    options.mediaAspectRatio = GADMediaAspectRatioLandscape;
    return options;
}

- (GADAdLoaderOptions *)viewOptions {
    GADNativeAdViewAdOptions *options = GADNativeAdViewAdOptions.new;
    options.preferredAdChoicesPosition = GADAdChoicesPositionTopRightCorner;
    return options;
}

更新日志

版本 1.9.5.4

  • 更新 'Google-Mobile-Ads-SDK' 到 '10.5.0'

版本 1.9.5.3

  • 更新 'Google-Mobile-Ads-SDK' 到 '10.3.0'

版本 1.9.5.2

  • 更新 'Google-Mobile-Ads-SDK' 到 '10.1.0'

版本 1.9.5.1

  • 更新 'Google-Mobile-Ads-SDK' 到 '10.0.0'

版本 1.9.5.0

  • 更新 BidMachine 至 1.9.5.0 +
  • 更新 'Google-Mobile-Ads-SDK' 至 '9.14.0'

版本 1.9.4.0

  • 更新 BidMachine 至 1.9.4.0 +
  • 更新 'Google-Mobile-Ads-SDK' 至 '9.8.0'

版本 1.9.2.0

  • 更新 BidMachine 至 1.9.2.1
  • 更新 'Google-Mobile-Ads-SDK' 至 '9.3.0'

版本 1.8.0.0

  • 更新 BidMachine 至 1.8.0.0

版本 1.7.4.0

  • 更新 BidMachine 至 1.7.4.0
  • 更新 'Google-Mobile-Ads-SDK' 至 '8.12.0'

版本 1.7.3.0

  • 将 BidMachine 更新到 1.7.3.0

版本 1.7.1.0

  • 将 BidMachine 更新到 1.7.1.0

版本 1.6.5.0

  • 将 BidMachine 更新到 1.6.5

版本 1.6.4.0

  • 将 BidMachine 更新到 1.6.4
  • 将 'Google-Mobile-Ads-SDK' 更新到 '8.2.0.1'

版本 1.5.2.0

  • 将 BidMachine 更新到 1.5.2

版本 1.5.0.1

  • 将 'Google-Mobile-Ads-SDK' 更新到 '7.62.0'

版本 1.5.0.0

  • 将 BidMachine 更新到 1.5.0

版本 1.4.2.0

  • 将 BidMachine 更新到 1.4.2

版本 1.4.1.0

  • 将 BidMachine 更新到 1.4.1

版本 1.4.0.0

  • 将 BidMachine 更新到 1.4.0
  • 添加本地广告支持

版本 1.3.0.0

  • 将 BidMachine 升级到 1.3.0
  • 添加头部竞价支持