انتقال SDK

این صفحه انتقال‌های نسخه‌های فعلی و قبلی Google Mobile Ads SDK برای iOS را پوشش می‌دهد. نسخه 11.0.0 انتظار می رود در ژانویه 2024 منتشر شود.

از نسخه SDK نسخه 10 به نسخه 11 مهاجرت کنید

حداقل هدف استقرار

حداقل هدف استقرار به iOS 12 افزایش یافته است.

حداقل نسخه Xcode

حداقل نسخه Xcode پشتیبانی شده به 15.1 افزایش یافته است.

تبلیغات در iOS 12 متوقف می شود

Google Mobile Ads SDK نسخه 11.0.0 تبلیغات را فقط در دستگاه‌های دارای iOS 13 و بالاتر ارائه می‌کند.

وابستگی GoogleAppMeasurement حذف شد

در نسخه 11.0.0، وابستگی به GoogleAppMeasurement حذف شده است. این وابستگی که به تغییر معیارهای کاربر در AdMob کمک می‌کند، در اوایل سال 2024 متوقف می‌شود. برای ادامه جمع‌آوری معیارهای کاربر در AdMob، برنامه AdMob خود را به Firebase پیوند دهید و Google Analytics برای Firebase SDK را در برنامه خود ادغام کنید.

تغییرات در ارائه تبلیغات تمام صفحه

تغییرات زیر بر فرمت های تبلیغاتی مختلف تأثیر می گذارد:

  • برنامه باز شد
  • بینابینی
  • پاداش داده شد
  • بینابینی با پاداش

پارامتر view controller در -canPresentFromRootViewController:error: و -presentFromRootViewController: قابل تهی است. اگر صفر تصویب شود، تبلیغ از بالاترین نمایش کنترلر در سلسله مراتب view controller ارائه می شود.

روش ها حذف شد

روش های زیر حذف می شوند.

v11.0.0 نوع روش یادداشت
GADAppOpenAd load(withAdUnitID adUnitID: String, request: GADRequest?, orientation: UIInterfaceOrientation) به جای آن از load(withAdUnitID adUnitID: String, request: GADRequest?) استفاده کنید.
GADMediationBannerAdEvent Delegate willBackgroundApplication() بدون جایگزینی
GADMediationInterstitialAdEvent Delegate willBackgroundApplication() بدون جایگزینی
GADMediationNativeAdEvent Delegate willBackgroundApplication() بدون جایگزینی
GADMediationRewardedAdEvent Delegate didRewardUser(with reward: GADAdReward) به جای آن didRewardUser() استفاده کنید.
GADMediatedUnifiedNativeAdNotificationSource mediatedNativeAdWillLeaveApplication(_ mediatedNativeAd: GADMediatedUnifiedNativeAd) بدون جایگزینی
پیکربندی GADRequest setSameAppKeyEnabled(_ enabled: Bool) به جای آن از setPublisherFirstPartyIDEnabled(_ enabled: Bool) استفاده کنید.
tagForUnderAge(ofConsent underAgeOfConsent: Bool) به جای آن از ویژگی tagForUnderAgeOfConsent استفاده کنید.
tag(forChildDirectedTreatment childDirectedTreatment: Bool) به جای آن از ویژگی tagForChildDirectedTreatment استفاده کنید.

خواص حذف شد

ویژگی های زیر حذف می شوند.

کلاس v11.0.0 ویژگی یادداشت
GADMediationAdConfiguration hasUserLocation بدون جایگزینی
userLatitude
طول کاربر
userLocationAccuracyInMeters
کودک جهت درمان به جای آن از GADMobileAds.sharedInstance.requestConfiguration.tagForChildDirectedTreatment استفاده کنید.
GADResponseInfo adNetworkClassName به جای آن از adNetworkClassName از loadedAdNetworkResponseInfo استفاده کنید.

GADAdFormatUnknown حذف شد

GADAdFormatUnknown بدون جایگزینی حذف شد.

تغییرات در ورود به سیستم نسخه SDK

نسخه 11.0.0 sdkVersion را حذف می کند. برای ورود به نسخه Google Mobile Ads SDK، به جای آن از versionNumber استفاده کنید.

نسخه 10.0.0

GADMobileAds.sharedInstance().sdkVersion

نسخه 11.0.0

GADGetStringFromVersionNumber(GADMobileAds.sharedInstance().versionNumber)

تغییرات در مدیریت خطای GADAdLoader

با شروع نسخه 11.0.0، GADAdLoader در صورتی که delegate آن با پروتکل نمایندگی انواع تبلیغات درخواستی مطابقت نداشته باشد، درخواست تبلیغاتی نمی کند. پیش از این، پس از درخواست آگهی انجام نشد.

تغییرات در رفتار تست

جدولی را ببینید که شرایط به‌روزرسانی شده را برای زمانی که ویژگی‌های زیر true می‌شوند نشان می‌دهد.

کلاس ویژگی
GADMediationAdConfiguration isTestRequest
GADCustomEventRequest isTesting
نسخه 10.0.0 نسخه 11.0.0
  • دستگاه به صراحت به عنوان یک دستگاه آزمایشی در testDeviceIdentifiers اعلام شده است.
  • دستگاه به صراحت به عنوان یک دستگاه آزمایشی در testDeviceIdentifiers اعلام شده است.
  • دستگاه شبیه ساز است.
  • این دستگاه به صراحت به عنوان یک دستگاه آزمایشی در رابط کاربری AdMob اعلام شده است.

از نسخه 9 به نسخه 10 مهاجرت کنید

تبلیغات در iOS 11 متوقف می شود

Google Mobile Ads SDK نسخه 10.0.0 تبلیغات را فقط در دستگاه‌های دارای iOS 12 و بالاتر ارائه می‌کند.

ارتقاء به Google Mobile Ads SDK نسخه 10.0.0 برنامه شما را در دستگاه‌های iOS 11 و iOS 10 خراب نمی‌کند، با این حال، هیچ تبلیغی در آن دستگاه‌ها نمایش داده نمی‌شود.

ساخت با بیت کد دیگر پشتیبانی نمی شود

اکنون برای ادغام Google Mobile Ads SDK، غیرفعال کردن بیت کد در برنامه های تلفن همراه شما لازم است.

انواع حذف شده است

تایپ کنید یادداشت
GADGender بدون جایگزینی
پروتکل GADMRewardBasedVideoAdNetworkAdapter همه آداپتورهای واسطه‌ای پاداش‌دار فهرست‌شده در Choose Networks استفاده از این پروتکل‌ها را برای بیش از یک سال متوقف کرده‌اند. از GADMediationAdapter برای میانجیگری و رویدادهای سفارشی استفاده کنید.
پروتکل GADMRewardBasedVideoAdNetworkConnector

خواص حذف شد

ویژگی های زیر بدون جایگزینی حذف می شوند.

کلاس v10.0.0 ویژگی
GADMediationAdRequest تولد کاربر
userGender
userHasLocation
userLatitude
طول کاربر
userLocationAccuracyInMeters
userLocationDescription
GADCustomEvent Request userHasLocation
userLatitude
طول کاربر
userLocationAccuracyInMeters
userLocationDescription
،

تبلیغات در iOS 11 متوقف می شود

Google Mobile Ads SDK نسخه 10.0.0 تبلیغات را فقط در دستگاه‌های دارای iOS 12 و بالاتر ارائه می‌کند.

ارتقاء به Google Mobile Ads SDK نسخه 10.0.0 برنامه شما را در دستگاه‌های iOS 11 و iOS 10 خراب نمی‌کند، با این حال، هیچ تبلیغی در آن دستگاه‌ها نمایش داده نمی‌شود.

ساخت با بیت کد دیگر پشتیبانی نمی شود

اکنون برای ادغام Google Mobile Ads SDK، غیرفعال کردن بیت کد در برنامه های تلفن همراه شما لازم است.

انواع حذف شده است

تایپ کنید یادداشت
GADGender بدون جایگزینی
پروتکل GADMRewardBasedVideoAdNetworkAdapter همه آداپتورهای واسطه‌ای پاداش‌دار فهرست‌شده در Choose Networks استفاده از این پروتکل‌ها را برای بیش از یک سال متوقف کرده‌اند. از GADMediationAdapter برای میانجیگری و رویدادهای سفارشی استفاده کنید.
پروتکل GADMRewardBasedVideoAdNetworkConnector

خواص حذف شد

ویژگی های زیر بدون جایگزینی حذف می شوند.

کلاس v10.0.0 ویژگی
GADMediationAdRequest تولد کاربر
userGender
userHasLocation
userLatitude
طول کاربر
userLocationAccuracyInMeters
userLocationDescription
GADCustomEvent Request userHasLocation
userLatitude
طول کاربر
userLocationAccuracyInMeters
userLocationDescription

از نسخه 8 به نسخه 9 مهاجرت کنید

تبلیغات در iOS 10 متوقف می شود

حداقل نسخه iOS که Google Mobile Ads SDK نسخه 9.0.0 پشتیبانی می کند iOS 11 است.

ارتقاء به Google Mobile Ads SDK نسخه 9.0.0 برنامه شما را در دستگاه‌های iOS 10 خراب نمی‌کند، اما هیچ تبلیغی در آن دستگاه‌ها نمایش داده نمی‌شود.

اجرای دقیق تر کنترل های نوار وضعیت

با شروع از نسخه 9.0.0، هنگامی که تبلیغات با فرمت تمام صفحه را ارائه می کنید، برنامه شما باید اطمینان حاصل کند که تبلیغات قادر به کنترل نمایش نوار وضعیت هستند. اگر این کار را انجام ندهید، یک پیغام خطا در گزارش ها مشاهده خواهید کرد.

بسته به طرح‌بندی خاص کنترل‌کننده‌های نمایش در برنامه‌تان، ممکن است نیازی به ایجاد هیچ تغییری برای اطمینان از این نداشته باشید. در نظر بگیرید که آیا باید ویژگی childViewControllerForStatusBarHidden را در rootViewController آگهی خود تنظیم کنید.

تغییر نام adDidPresentFullScreenContent: به adWillPresentFullScreenContent:

هیچ تغییر رفتاری وجود ندارد. روش delegate درست قبل از ارائه آگهی فراخوانی می شود، بنابراین نام روش جدید عملکرد آن را بهتر نشان می دهد.

API تنظیم مکان را در GADRequest حذف کنید

- (void)setLocationWithLatitude:longitude:accuracy: از GADRequest حذف شده است زیرا اطلاعات مکان توسط Google برای هدف‌یابی تبلیغات استفاده نمی‌شود. در صورت لزوم از API های شخص ثالث برای ارائه اطلاعات به شبکه های تبلیغاتی شخص ثالث استفاده کنید.

منسوخ شدن رابط های رویداد سفارشی

رویدادهای سفارشی ناشران را با استفاده از AdMob Mediation قادر می‌سازند تا میانجی‌گری آبشار را برای یک شبکه تبلیغاتی که یکی از شبکه‌های تبلیغاتی پشتیبانی‌شده نیست اضافه کنند.

همه پروتکل های رویداد سفارشی منسوخ شده اند. در عوض، از پروتکل‌های GADMediationAdapter و GADMediationAdEventDelegate موجود برای دستیابی به عملکردهای مشابه استفاده کنید. این تغییر وضوح را بهبود می‌بخشد و شما را قادر می‌سازد رویدادهای سفارشی را برای آگهی‌های دارای پاداش و آگهی‌های بین اسکرولری که قبلاً در دسترس نبودند ایجاد کنید.

API ها

جدول زیر APIهای آداپتور میانجی مربوط به APIهای رویدادهای سفارشی را فهرست می‌کند که باید از نسخه 9.0.0 استفاده شوند.

v8 v9
GADCustomEventBanner
GADCustomEventInterstitial
GADCustomEventNativeAd
GADMediationAdapter GADMediationBannerAd
GADMediationInterstitialAd
GADMediationInterscrollerAd
GADMediationRewardedAd
GADMediationNativeAd
delegate Delegate توسط کنترل کننده تکمیل بار هر تابع بار از کلاس GADMediationAdapter برگردانده می شود.
-init -init
-requestBannerAd:parameter: label:request: -loadBannerForAdConfiguration: completionHandler:
-requestInterstitialAdWith Parameter:label:request: -loadInterstitialFor AdConfiguration: completionHandler:
-requestNativeAdWithParameter: request:adTypes:options: rootViewController: -loadNativeAdFor AdConfiguration: completionHandler:
N/A -loadInterscrollerAdFor AdConfiguration: completionHandler:
N/A -loadRewardedAdFor AdConfiguration: completionHandler:
-presentFromRootViewController: -presentFromViewController:
-handlesUserClicks -handlesUserClicks
-handlesUserImpressions -handlesUserImpressions

روش های تفویض اختیار

جدول زیر روش‌های انتقال رویداد آگهی میانجی‌گری مربوط به روش‌های واگذاری رویداد سفارشی را فهرست می‌کند که باید از نسخه 9.0.0 استفاده شوند.

v8 v9
GADCustomEventBannerDelegate
GADCustomEventInterstitialDelegate
GADCustomEventNativeAdDelegate
GADMediationAdEvent Delegate GADMediationAd
-customEventBanner:didReceiveAd:
-customEventInterstitialDidReceiveAd:
وضعیت بار آگهی در کنترل کننده تکمیل بار هر تابع بار در کلاس GADMediationAdapter گنجانده شده است.
-customEventBanner:didFailAd:
-customEventInterstitial:didFailAd:
-customEventBannerWasClicked:
-customEventInterstitialWasClicked:
-reportClick
-customEventBannerWill PresentModal:
-customEventInterstitialWill PresentModal:
-willPresentFullScreenView
-customEventBannerWill DismissModal:
-customEventInterstitialWill DismissModal:
-willDismissFullScreenView
-customEventBannerDid DismissModal:
-customEventInterstitialDid DismissModal:
-didDismissFullScreenView
-customEventBannerWill LeaveApplication:
-customEventInterstitialWill LeaveApplication:
-willBackgroundApplication
viewControllerFor PresentingModalView -[GADMediationBannerAd view]

سایر روش ها و ثابت های حذف/جایگزین شده

تغییرات در روش، ثابت یا ویژگی
kGAD- ثابت های پیشوند حذف شده. از ثابت های پیشوند GAD- استفاده کنید.
GADAdNetworkResponseInfo credentials حذف شد به جای آن از adUnitMapping استفاده کنید.
GADCustomNativeAd mediaView در GADCustomNativeAd منسوخ شده است. به جای آن mediaContent استفاده کنید.
APIهای خرید درون برنامه ای در GoogleMobileAds APIهای inAppPurchase در GoogleMobileAds حذف شدند.

از نسخه 7 به نسخه 8 مهاجرت کنید

Google Mobile Ads SDK نسخه 8.0.0 چند تغییر عمده و همچنین برخی تغییر نام ها و حذف API ها را معرفی می کند.

به روز رسانی API با فرمت تمام صفحه

با شروع نسخه 8.0.0، تبلیغات بینابینی و دارای پاداش، یک سبک عمومی تبلیغات تمام صفحه را برای ثبات بیشتر به اشتراک می گذارند. این APIهای تبلیغات تمام صفحه جدید دو تفاوت عمده با APIهای تبلیغات تمام صفحه نسخه 7 دارند:

  1. load روش کلاس استاتیک

    روش قبلی برای بارگیری/نمایش آگهی تمام صفحه به شرح زیر است:

    1. یک نمونه شیء تبلیغاتی ایجاد کنید و یک مرجع به آن نگه دارید.
    2. نماینده ای اختصاص دهید که بارگیری و نمایش تماس های برگشتی را انجام دهد.
    3. یک تبلیغ را بارگیری کنید.
    4. بررسی کنید که آیا آگهی با استفاده از isReady بارگیری شده است.
    5. آگهی را نمایش دهید.

    در نسخه 8، رویکرد کمی تغییر می کند. تماس‌های بارگیری دیگر بخشی از یک نماینده نیستند. در عوض، آنها به عنوان یک کنترل کننده تکمیل به روش load منتقل می شوند:

    1. یک روش بار استاتیک در کلاس تبلیغات فراخوانی کنید و یک کنترل کننده تکمیل بار ارائه دهید.
    2. در پاسخ به تماس تکمیل بارگذاری، به آگهی بارگیری شده که برگردانده شده است اشاره کنید.
    3. نماینده ای اختصاص دهید که پاسخگوی تماس های نمایشی را کنترل کند.
    4. آگهی را نمایش دهید.

    رویکرد جدید این مزایا را فراهم می کند:

    • شما هرگز به تبلیغی که بارگذاری نشده است اشاره ای نخواهید داشت.
    • در حین بارگذاری یک شیء تبلیغاتی مجبور نیستید آن را نگه دارید.
  2. رویدادهای تبلیغاتی مداوم

    نوع رویداد API موجود v8 API
    بارگذاری رویدادها GADInterstitialDelegate یا GADRewardedAdDelegate GADInterstitialAdLoadCompletionHandler یا GADRewardedAdLoadCompletionHandler
    رویدادهای ارائه GADFullScreenContentDelegate

    قبلاً، برای گوش دادن به رویدادهای تبلیغاتی، کلاسی را ثبت می‌کردید که پروتکل GADInterstitialDelegate را در ویژگی نماینده یک بینابینی پیاده‌سازی می‌کند، یا کلاسی را ثبت می‌کنید که پروتکل GADRewardedAdDelegate را بسته به قالبی که از آن استفاده می‌کنید، در ویژگی نماینده آگهی پاداش‌دهی شده پیاده‌سازی می‌کند. همین نماینده روش‌هایی داشت که هم به چرخه عمر بارگذاری و هم ارائه آگهی مربوط می‌شد.

    با نسخه 8، رویدادهای بارگذاری و ارائه جداگانه هستند. اکنون می‌توانید یک GADFullScreenContentDelegate را هر زمان که بخواهید قبل از نمایش آگهی ثبت کنید، به‌جای اینکه قبل از بارگیری آگهی، یک نماینده را تعیین کنید. رویدادهای بار آگهی، که مخصوص هر قالب هستند، به یک کنترل کننده تکمیل بار منتقل می شوند که در روش بارگذاری ارسال شده است.

بینابینی

بارگذاری آگهی

قطعه کد زیر به شما نشان می دهد که چگونه یک تبلیغ بینابینی را بارگیری کنید و در صورت موفقیت یا عدم بارگیری آگهی به رویدادها گوش دهید.

v7

سریع

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADInterstitialDelegate {

  var interstitial: GADInterstitial!

  override func viewDidLoad() {
    super.viewDidLoad()
    interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/44118910")
    interstitial.delegate = self
    let request = GADRequest()
    interstitial.load(request)
  }

  /// Tells the delegate an ad request succeeded.
  func interstitialDidReceiveAd(_ ad: GADInterstitial) {
    print("Interstitial ad loaded.")
  }

  /// Tells the delegate an ad request failed.
  func interstitial(_ ad: GADInterstitial, didFailToReceiveAdWithError error: GADRequestError) {
    print("Interstitial ad failed to load with error: \(error.localizedDescription)")
  }
}

هدف-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADInterstitial *interstitial;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  self.interstitial = [[GADInterstitial alloc]
      initWithAdUnitID:@"ca-app-pub-3940256099942544/44118910"];
  self.interstitial.delegate = self;
  GADRequest *request = [GADRequest request];
  [self.interstitial loadRequest:request];
}

/// Tells the delegate an ad request succeeded.
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad {
  NSLog(@"Insterstitial ad loaded.");
}

/// Tells the delegate an ad request failed.
- (void)interstitial:(GADInterstitial *)ad
    didFailToReceiveAdWithError:(GADRequestError *)error {
  NSLog(@"Interstitial ad failed to load with error: %@", [error localizedDescription]);
}

v8

سریع

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADFullScreenContentDelegate {

  var interstitial: GADInterstitialAd?

  override func viewDidLoad() {
    super.viewDidLoad()
    let request = GADRequest()
    GADInterstitialAd.load(withAdUnitID:"ca-app-pub-8123415297019784/4985798738",
                                request: request,
                      completionHandler: { (ad, error) in
                        if let error = error {
                          print("Failed to load interstitial ad with error: \(error.localizedDescription)")
                          return
                        }
                        self.interstitial = ad
                        self.interstitial.fullScreenContentDelegate = self
                      }
    )
  }
}

هدف-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADInterstitialAd *interstitial;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  GADRequest *request = [GADRequest request];
  [GADInterstitialAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/44118910"
                              request:request
                    completionHandler:^(GADInterstitialAd *ad, NSError *error) {
    if (error) {
      NSLog(@"Failed to load interstitial ad with error: %@", [error localizedDescription]);
      return;
    }
    self.interstitial = ad;
    self.interstitial.fullScreenContentDelegate = self;
  }];
}

نمایش تبلیغ

v7

سریع

func showInterstitial() {
  ...
  if interstitial.isReady {
    interstitial.present(fromRootViewController: self)
  } else {
    print("Ad wasn't ready")
  }
}

هدف-C

- (void)showInterstitial: {
  ...
  if (self.interstitial.isReady) {
    [self.interstitial presentFromRootViewController:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

v8

سریع

func showInterstitial() {
  ...
  if let ad = interstitial {
    ad.present(fromRootViewController: self)
  } else {
    print("Ad wasn't ready")
  }
}

هدف-C

- (void)showInterstitial: {
  ...
  if (self.interstitial) {
    [self.interstitial presentFromRootViewController:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

رویدادهای تبلیغاتی ارائه

تکه‌های کد زیر به شما نشان می‌دهند که چگونه می‌توانید با تماس‌های زمانی که آگهی ارائه می‌شود (با موفقیت یا ناموفق) و زمانی که رد می‌شود، تماس بگیرید.

v7

سریع

override func viewDidLoad() {
  super.viewDidLoad()
  interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/44118910")
  interstitial.delegate = self
  ...
}

/// Tells the delegate that an interstitial will be presented.
func interstitialWillPresentScreen(_ ad: GADInterstitial) {
  print("Interstitial ad will be presented.")
}

/// Tells the delegate the interstitial is to be animated off the screen.
func interstitialWillDismissScreen(_ ad: GADInterstitial) {
  print("Interstitial ad will be dismissed.")
}

/// Tells the delegate the interstitial had been animated off the screen.
func interstitialDidDismissScreen(_ ad: GADInterstitial) {
  print("Interstitial ad dismissed.")
}

/// Tells the delegate that a user click will open another app
/// (such as the App Store), backgrounding the current app.
///
/// This is not a reliable callback for an ad click event and is removed in
/// version 8. If you wish to listen to an ad causing a user to leave the app,
/// use applicationWillResignActive: or sceneWillResignActive: instead.
func interstitialWillLeaveApplication(_ ad: GADInterstitial) {
  print("Interstitial ad will leave application.")
}

هدف-C

- (void)viewDidLoad {
  [super viewDidLoad];
  self.interstitial = [[GADInterstitial alloc] initWithAdUnitID:"ca-app-pub-3940256099942544/44118910"];
  self.interstitial.delegate = self;
  ...
}

/// Tells the delegate that an interstitial will be presented.
- (void)interstitialWillPresentScreen:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad will be presented.");
}

/// Tells the delegate the interstitial is to be animated off the screen.
- (void)interstitialWillDismissScreen:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad will be dismissed.");
}

/// Tells the delegate the interstitial had been animated off the screen.
- (void)interstitialDidDismissScreen:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad dismissed.");
}

/// Tells the delegate that a user click will open another app
/// (such as the App Store), backgrounding the current app.
///
/// This is not a reliable callback for an ad click event and is removed in
/// version 8. If you wish to listen to an ad causing a user to leave the app,
/// use applicationWillResignActive: or sceneWillResignActive: instead.
- (void)interstitialWillLeaveApplication:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad will leave application.");
}

v8

سریع

override func viewDidLoad() {
  super.viewDidLoad()
  let request = GADRequest()
  GADInterstitialAd.load(withAdUnitID:"ca-app-pub-8123415297019784/4985798738",
                              request: request,
                    completionHandler: { (ad, error) in
                      if let error = error {
                        print(error.localizedDescription)
                        return
                      }
                      self.interstitial = ad
                      self.interstitial.fullScreenContentDelegate = self
                    }
  )
}

func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Ad did present full screen content.")
}

func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
  print("Ad failed to present full screen content with error \(error.localizedDescription).")
}

func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Ad did dismiss full screen content.")
}

هدف-C

- (void)viewDidLoad {
  [super viewDidLoad];
  GADRequest *request = [GADRequest request];
  [GADInterstitialAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/44118910"
                              request:request
                    completionHandler:^(GADInterstitialAd *ad, NSError *error) {
    if (error) {
      NSLog(@"interstitial:didFailToReceiveAdWithError: %@", [error localizedDescription])
      return;
    }
    self.interstitial = ad;
    self.interstitial.fullScreenContentDelegate = self;
  }];
}

- (void)adDidPresentFullScreenContent:(id)ad {
  NSLog(@"Ad did present full screen content.");
}

- (void)ad:(id)ad didFailToPresentFullScreenContentWithError:(NSError *)error {
  NSLog(@"Ad failed to present full screen content with error %@.", [error localizedDescription]);
}

- (void)adDidDismissFullScreenContent:(id)ad {
  NSLog(@"Ad did dismiss full screen content.");
}

پاداش داده شد

بارگذاری آگهی

v7

سریع

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADRewardedAdDelegate {
  /// The rewarded ad.
  var rewardedAd: GADRewardedAd?

  override func viewDidLoad() {
    super.viewDidLoad()
    rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313")
    rewardedAd.delegate = self
    rewardedAd?.load(GADRequest()) { error in
      if let error = error {
        print("Rewarded ad failed to load with error: \(error.localizedDescription)")
      } else {
        print("Rewarded ad loaded.")
      }
    }
  }
}

هدف-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADRewardedAd *rewardedAd;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  self.rewardedAd = [[GADRewardedAd alloc]
      initWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"];
  self.rewardedAd.delegate = self;
  GADRequest *request = [GADRequest request];
  [self.rewardedAd loadRequest:request completionHandler:^(GADRequestError * _Nullable error) {
    if (error) {
      NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
    } else {
      NSLog(@"Rewarded ad loaded.");
    }
  }];
}

v8

سریع

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADFullScreenContentDelegate {
  /// The rewarded ad.
  var rewardedAd: GADRewardedAd?

  override func viewDidLoad() {
  super.viewDidLoad()
  let request = GADRequest()
  GADRewardedAd.load(withAdUnitID: "ca-app-pub-8123415297019784/9501821136",
                          request: request, completionHandler: { (ad, error) in
                            if let error = error {
                              print("Rewarded ad failed to load with error: \(error.localizedDescription)")
                              return
                            }
                            self.rewardedAd = ad
                            self.rewardedAd?.fullScreenContentDelegate = self
                          }
  )
  }
}

هدف-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADRewardedAd *rewardedAd;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  GADRequest *request = [GADRequest request];
  [GADRewardedAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"
                          request:request
                completionHandler:^(GADRewardedAd *ad, NSError *error) {
    if (error) {
      NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
      return;
    }
    self.rewardedAd = ad;
    NSLog(@"Rewarded ad loaded.");
    self.rewardedAd.fullScreenContentDelegate = self;
}

نمایش تبلیغات و مدیریت پاداش

تبلیغات پاداش از شما می‌خواهد تا زمانی که کاربر پاداشی کسب می‌کند، رویداد را مدیریت کنید. با نسخه 7 API GADRewardedAd ، rewardedAd:userDidEarnReward: به عنوان بخشی از پروتکل GADRewardedAdDelegate پیاده سازی می کنید. برای نسخه 8، شما GADUserDidEarnRewardHandler را برای ارائه آگهی پیاده سازی می کنید.

v7

سریع

func showRewardedAd() {
  ...
  if rewardedAd.isReady {
    rewardedAd.present(fromRootViewController: self delegate:self)
  } else {
    print("Ad wasn't ready")
  }
}

/// Tells the delegate that the user earned a reward.
func rewardedAd(_ rewardedAd: GADRewardedAd, userDidEarnReward: GADAdReward) {
  // TODO: Reward the user.
}

هدف-C

- (void)showRewardedAd: {
  ...
  if (self.rewardedAd.isReady) {
    [self.rewardedAd presentFromRootViewController:self delegate:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

/// Tells the delegate that the user earned a reward.
- (void)rewardedAd:(GADRewardedAd *)rewardedAd userDidEarnReward:(GADAdReward *)reward {
  // TODO: Reward the user.
}

v8

سریع

func showRewardedAd() {
  ...
  if let ad = rewardedAd {
      ad.present(fromRootViewController: self,
               userDidEarnRewardHandler: {
                 let reward = ad.adReward
                 // TODO: Reward the user.
               }
      )
  } else {
    print("Ad wasn't ready")
  }
}

هدف-C

- (void)showRewardedAd: {
  ...
  if (self.rewardedAd) {
    [self.rewardedAd presentFromRootViewController:self
                          userDidEarnRewardHandler:^ {
      GADAdReward *reward = self.rewardedAd.adReward;
      // TODO: Reward the user.
    }];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

رویدادهای تبلیغاتی ارائه

با GADRewardedAd API شما یک GADRewardedAdDelegate را به روشی که تبلیغ را ارائه می دهد، ارسال می کنید. با GADRewardedAd API، یک GADFullscreenContentDelegate به عنوان یک ویژگی روی آگهی قبل از ارائه آگهی تنظیم می کنید.

v7

سریع

func showRewardedAd() {
  ...
  if rewardedAd.isReady {
    rewardedAd.present(fromRootViewController: self delegate:self)
  } else {
    print("Ad wasn't ready")
  }
}

/// Tells the delegate that the rewarded ad was presented.
func rewardedAdDidPresent(_ rewardedAd: GADRewardedAd) {
  print("Rewarded ad presented.")
}
/// Tells the delegate that the rewarded ad was dismissed.
func rewardedAdDidDismiss(_ rewardedAd: GADRewardedAd) {
  print("Rewarded ad dismissed.")
}
/// Tells the delegate that the rewarded ad failed to present.
func rewardedAd(_ rewardedAd: GADRewardedAd, didFailToPresentWithError error: Error) {
  print("Rewarded ad failed to present with error: \(error.localizedDescription).")
}

هدف-C

- (void)showRewardedAd: {
  ...
  if (self.rewardedAd.isReady) {
    [self.rewardedAd presentFromRootViewController:self delegate:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

/// Tells the delegate that the rewarded ad was presented.
- (void)rewardedAdDidPresent:(GADRewardedAd *)rewardedAd {
  NSLog(@"Rewarded ad presented.");
}

/// Tells the delegate that the rewarded ad failed to present.
- (void)rewardedAd:(GADRewardedAd *)rewardedAd didFailToPresentWithError:(NSError *)error {
  NSLog(@"Rewarded ad failed to present with error: %@",
        [error localizedDescription]);
}

/// Tells the delegate that the rewarded ad was dismissed.
- (void)rewardedAdDidDismiss:(GADRewardedAd *)rewardedAd {
  NSLog(@"Rewarded ad dismissed.");
}

v8

سریع

override func viewDidLoad() {
  super.viewDidLoad()
  let request = GADRequest()
  GADRewardedAd.load(withAdUnitID: "ca-app-pub-8123415297019784/9501821136",
                          request: request, completionHandler: { (ad, error) in
                            if let error = error {
                              print(error.localizedDescription)
                              return
                            }
                            self.rewardedAd = ad
                            self.rewardedAd?.fullScreenContentDelegate = self
                          }
  )
}

/// Tells the delegate that the rewarded ad was presented.
func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Rewarded ad presented.")
}
/// Tells the delegate that the rewarded ad was dismissed.
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Rewarded ad dismissed.")
}
/// Tells the delegate that the rewarded ad failed to present.
func ad(_ ad: GADFullScreenPresentingAd,
    didFailToPresentFullScreenContentWithError error: Error) {
  print("Rewarded ad failed to present with error: \(error.localizedDescription).")
}

هدف-C

- (void)viewDidLoad {
  [super viewDidLoad];

  GADRequest *request = [GADRequest request];
  [GADRewardedAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"
                          request:request
                completionHandler:^(GADRewardedAd *ad, NSError *error) {
    if (error) {
      NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
      return;
    }
    self.rewardedAd = ad;
    NSLog(@"Rewarded ad loaded.");
    self.rewardedAd.fullScreenContentDelegate = self;
}

/// Tells the delegate that the rewarded ad was presented.
- (void)adDidPresentFullScreenContent:(id)ad {
  NSLog(@"Rewarded ad presented.");
}

/// Tells the delegate that the rewarded ad failed to present.
- (void)ad:(id)ad
    didFailToPresentFullScreenContentWithError:(NSError *)error {
  NSLog(@"Rewarded ad failed to present with error: %@",
       [error localizedDescription]);
}

/// Tells the delegate that the rewarded ad was dismissed.
- (void)adDidDismissFullScreenContent:(id)ad {
  NSLog(@"Rewarded ad dismissed.");
}

حذف API Legacy GADRewardedBasedVideoAd

API جدیدتر GADRewardedAd برای اولین بار در مارس 2019 معرفی شد و برای بیش از 18 ماه بهترین API پاداش دار بوده است. در مقایسه با API قدیمی GADRewardedBasedVideoAd ، پیشرفت‌های بیشتری داشته است، از جمله توانایی بارگیری بیش از یک آگهی با پاداش در یک زمان.

API قدیمی GADRewardedBasedVideoAd در SDK نسخه 8.0.0 حذف شده است.

منسوخ شدن بنر هوشمند به نفع بنر تطبیقی

تبلیغات بنری هوشمند به نفع تبلیغات بنری تطبیقی ​​منسوخ شده است. بنرهای تطبیقی ​​عملکرد برتر و انعطاف پذیری بیشتری را در تنظیم عرض آگهی ارائه می دهند. اگر ترجیح می دهید به استفاده از بنرهای تمام عرض ادامه دهید، همچنان می توان با استفاده از بنر تطبیقی، همانطور که در قطعه کد زیر نشان داده شده است، این کار را انجام داد:

سریع

class ViewController: UIViewController {

  override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    // Note: The safe area is not known until viewWillAppear.
    let adSize = getFullWidthAdaptiveAdSize()
  }

  func getFullWidthAdaptiveAdSize() -> GADAdSize {
    // Here safe area is taken into account, hence the view frame is used after the
    // view has been laid out.
    let frame = { () -> CGRect in
      if #available(iOS 11.0, *) {
        return view.frame.inset(by: view.safeAreaInsets)
      } else {
        return view.frame
      }
    }()
    return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(frame.size.width)
  }
}

هدف-C

@implementation ViewController

- (void)viewDidAppear:(BOOL)animated {
  [super viewDidAppear:animated];
  // Note: The safe area is not known until viewWillAppear.
  GADAdSize adSize = [self getFullWidthAdaptiveAdSize];
}

- (GADAdSize)getFullWidthAdaptiveAdSize {
  CGRect frame = self.view.frame;
  // Here safe area is taken into account, hence the view frame is used after
  // the view has been laid out.
  if (@available(iOS 11.0, *)) {
    frame = UIEdgeInsetsInsetRect(self.view.frame, self.view.safeAreaInsets);
  }
  return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(frame.size.width);
}

@end

حذف پاسخ تماس برنامه را ترک کنید

willLeaveApplication برای همه قالب‌های تبلیغاتی به نفع روش‌های applicationDidEnterBackground: و sceneDidEnterBackground: حذف شده است. استفاده از API های سطح سیستم عامل هر زمان که کاربران برنامه شما را ترک می کنند، صرف نظر از اینکه به دلیل تعامل تبلیغاتی باشد یا نه، به شما اطلاع می دهد.

توجه داشته باشید که پاسخ تماس willLeaveApplication هرگز به عنوان یک کنترل کننده کلیک تبلیغات در نظر گرفته نشده است، و تکیه بر این تماس برای گزارش کلیک ها معیار دقیقی ایجاد نمی کند. به عنوان مثال، با کلیک بر روی نماد AdChoices که یک مرورگر خارجی را راه‌اندازی می‌کند، پاسخ تماس را فراخوانی می‌کند اما یک کلیک حساب نمی‌شود.

تغییر نام کلاس ها

جدول زیر نام کلاس‌های خاصی را که در نسخه 8 تغییر کرده یا حذف شده‌اند فهرست می‌کند.

  • همه کلاس‌های مربوط به GADUnifiedNativeAd به GADNativeAd تغییر نام داده‌اند.
  • GADRewardBasedVideoAd ، GADNativeExpressAdView ، و GADInstreamAd حذف شده‌اند.
  • همه کلاس‌های دارای پیشوند DFP با پیشوند GAM جایگزین شده‌اند.
کلاس v7.68.0 کلاس v8.0.0
DFPBannerView GAMBannerView
DFPBannerViewOptions GAMBannerViewOptions
DFPIInterstitial GAInterstitialAd
DFPRequest GAMRequest
خطای GADRequest خطای NSE
GADUnifiedNativeAdView GADNativeAdView
GADUnifiedNativeAd GADNativeAd
GADUnifiedNativeAdAssetIdentifiers GADNativeAdAssetIdentifiers
GADUnifiedNativeAdDelegate GADNativeAdDelegate
GADUnifiedNativeAdUnconfirmedClickDelegate GADNativeAdUnconfirmedClickDelegate
GADNativeCustomTemplateAd GADCustomNative Ad
GADNativeCustomTemplateAdLoaderDelegate GADCustomNativeAdLoaderDelegate
GADNativeAdDelegate GADCustomNativeAdDelegate
GADINAppPurchase حذف شده
GADInterstitial GADInterstitialAd
GADNativeExpressAdView حذف شده
GADRewardBasedVideoAd حذف شده
GADInstreamAd حذف شده
GADInstreamAdView حذف شده

روش‌ها حذف/جایگزین شدند

جدول زیر تغییرات خاص نسخه 8 را فهرست می کند. به طور خلاصه:

  • روش‌ها و ویژگی‌های منسوخ شده قبلی حذف شده‌اند.
  • -willLeaveApplication: روش های نمایندگی برای همه فرمت ها حذف شده است.
  • نام کلاس شبکه تبلیغاتی به ویژگی GADResponseInfo منتقل شده است.
  • شناسه دستگاه آزمایشی به ویژگی GADRequestConfiguration منتقل شده است.
کلاس v7.68.0 v7.68.0 API v8.0.0 API یادداشت
GADMobileAds +configureWithApplicationID: -startWithCompletion Handler: شناسه برنامه اکنون در Info.plist تنظیم شده است.
+disableAutomatedInApp PurchaseReporting -disableAutomatedInApp PurchaseReporting
+disableSDKCrashReporting غیرفعال کردن SDKCrashReporting
GADRequest دستگاه های تست GADRequestConfiguration .testdeviceidentifiers ویژگی testDeviceIdentifiers برای همه درخواست‌های تبلیغاتی اعمال می‌شود، در حالی که ویژگی قدیمی testDevices برای هر درخواست تنظیم شده بود.
جنسیت حذف شده
روز تولد حذف شده
+sdkVersion GADMobileAds.sharedInstance .sdkVersion
-setBirthday WithMonth:day:year: حذف شده
-setLocationWithDescription: -setLocationWith Latitude:longitude:accuracy:
-tagForChildDirectedTreatment: [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment]
GADErrorCode kGADEخطا* خطای GADE* پیشوند k از تمام ثابت های کد خطا حذف می شود.
GADBannerView دارای Refreshed خودکار است autoload فعال شد
inAppPurchaseDelegate حذف شده
mediatedAdView حذف شده
adNetworkClassName answerInfo .adNetworkClassName
DFPBannerView -setValidAdSizesWithSizes: -setValidAdSizes:
DFPBannerViewOptions -adSizeDelegate حذف شده
GADBannerViewDelegate -adViewDidReceiveAd: -bannerViewDidReceiveAd:
-adView:didFailToReceive AdWithError: -bannerView:didFailToReceive AdWithError:
-adViewWillPresentScreen: -bannerViewWillPresentScreen:
-adViewWillDismissScreen: -bannerViewWillDismissScreen:
-adViewDidDismissScreen: -bannerViewDidDisissScreen:
-adViewWillLeaveApplication: حذف شده
GADNativeCustomTemplateAd شناسه الگو GADCustomNativeAd.formatID
-performClickOnAssetWithKey: customClickHandler: -performClickOnAssetWithKey:
GADNativeAdImageAd LoaderOptions preferredImageOrientation GADNativeAdMediaAdOptions .mediaAspectRatio
GADInterstitial inAppPurchaseDelegate حذف شده
آماده است حذف شده به جای آن از canPresentFrom RootViewController:error: استفاده کنید.
استفاده شده است حذف شده
-init -initWithAdUnitID:
-setAdUnitID: -initWithAdUnitID:
adNetworkClassName answerInfo .adNetworkClassName
-interstitialWill LeaveApplication: حذف شده
GADUnifiedNativeAd ویدئو کنترلر mediaContent.videoController
adNetworkClassName answerInfo .adNetworkClassName
,

این صفحه انتقال‌های نسخه‌های فعلی و قبلی Google Mobile Ads SDK برای iOS را پوشش می‌دهد. نسخه 11.0.0 انتظار می رود در ژانویه 2024 منتشر شود.

از نسخه SDK نسخه 10 به نسخه 11 مهاجرت کنید

حداقل هدف استقرار

حداقل هدف استقرار به iOS 12 افزایش یافته است.

حداقل نسخه Xcode

حداقل نسخه Xcode پشتیبانی شده به 15.1 افزایش یافته است.

تبلیغات در iOS 12 متوقف می شود

Google Mobile Ads SDK نسخه 11.0.0 تبلیغات را فقط در دستگاه‌های دارای iOS 13 و بالاتر ارائه می‌کند.

وابستگی GoogleAppMeasurement حذف شد

در نسخه 11.0.0، وابستگی به GoogleAppMeasurement حذف شده است. این وابستگی که به تغییر معیارهای کاربر در AdMob کمک می‌کند، در اوایل سال 2024 متوقف می‌شود. برای ادامه جمع‌آوری معیارهای کاربر در AdMob، برنامه AdMob خود را به Firebase پیوند دهید و Google Analytics برای Firebase SDK را در برنامه خود ادغام کنید.

تغییرات در ارائه تبلیغات تمام صفحه

تغییرات زیر بر فرمت های تبلیغاتی مختلف تأثیر می گذارد:

  • برنامه باز شد
  • بینابینی
  • پاداش داده شد
  • بینابینی با پاداش

پارامتر view controller در -canPresentFromRootViewController:error: و -presentFromRootViewController: قابل تهی است. اگر صفر تصویب شود، تبلیغ از بالاترین نمایش کنترلر در سلسله مراتب view controller ارائه می شود.

روش ها حذف شد

روش های زیر حذف می شوند.

v11.0.0 نوع روش یادداشت
GADAppOpenAd load(withAdUnitID adUnitID: String, request: GADRequest?, orientation: UIInterfaceOrientation) به جای آن از load(withAdUnitID adUnitID: String, request: GADRequest?) استفاده کنید.
GADMediationBannerAdEvent Delegate willBackgroundApplication() بدون جایگزینی
GADMediationInterstitialAdEvent Delegate willBackgroundApplication() بدون جایگزینی
GADMediationNativeAdEvent Delegate willBackgroundApplication() بدون جایگزینی
GADMediationRewardedAdEvent Delegate didRewardUser(with reward: GADAdReward) به جای آن didRewardUser() استفاده کنید.
GADMediatedUnifiedNativeAdNotificationSource mediatedNativeAdWillLeaveApplication(_ mediatedNativeAd: GADMediatedUnifiedNativeAd) بدون جایگزینی
پیکربندی GADRequest setSameAppKeyEnabled(_ enabled: Bool) به جای آن از setPublisherFirstPartyIDEnabled(_ enabled: Bool) استفاده کنید.
tagForUnderAge(ofConsent underAgeOfConsent: Bool) به جای آن از ویژگی tagForUnderAgeOfConsent استفاده کنید.
tag(forChildDirectedTreatment childDirectedTreatment: Bool) به جای آن از ویژگی tagForChildDirectedTreatment استفاده کنید.

خواص حذف شد

ویژگی های زیر حذف می شوند.

کلاس v11.0.0 ویژگی یادداشت
GADMediationAdConfiguration hasUserLocation بدون جایگزینی
userLatitude
طول کاربر
userLocationAccuracyInMeters
کودک جهت درمان به جای آن از GADMobileAds.sharedInstance.requestConfiguration.tagForChildDirectedTreatment استفاده کنید.
GADResponseInfo adNetworkClassName به جای آن از adNetworkClassName از loadedAdNetworkResponseInfo استفاده کنید.

GADAdFormatUnknown حذف شد

GADAdFormatUnknown بدون جایگزینی حذف شد.

تغییرات در ورود به سیستم نسخه SDK

نسخه 11.0.0 sdkVersion را حذف می کند. برای ورود به نسخه Google Mobile Ads SDK، به جای آن از versionNumber استفاده کنید.

نسخه 10.0.0

GADMobileAds.sharedInstance().sdkVersion

نسخه 11.0.0

GADGetStringFromVersionNumber(GADMobileAds.sharedInstance().versionNumber)

تغییرات در مدیریت خطای GADAdLoader

با شروع نسخه 11.0.0، GADAdLoader در صورتی که delegate آن با پروتکل نمایندگی انواع تبلیغات درخواستی مطابقت نداشته باشد، درخواست تبلیغاتی نمی کند. پیش از این، پس از درخواست آگهی انجام نشد.

تغییرات در رفتار تست

جدولی را ببینید که شرایط به‌روزرسانی شده را برای زمانی که ویژگی‌های زیر true می‌شوند نشان می‌دهد.

کلاس ویژگی
GADMediationAdConfiguration isTestRequest
GADCustomEventRequest isTesting
نسخه 10.0.0 نسخه 11.0.0
  • دستگاه به صراحت به عنوان یک دستگاه آزمایشی در testDeviceIdentifiers اعلام شده است.
  • دستگاه به صراحت به عنوان یک دستگاه آزمایشی در testDeviceIdentifiers اعلام شده است.
  • دستگاه شبیه ساز است.
  • این دستگاه به صراحت به عنوان یک دستگاه آزمایشی در رابط کاربری AdMob اعلام شده است.

از نسخه 9 به نسخه 10 مهاجرت کنید

تبلیغات در iOS 11 متوقف می شود

Google Mobile Ads SDK نسخه 10.0.0 تبلیغات را فقط در دستگاه‌های دارای iOS 12 و بالاتر ارائه می‌کند.

ارتقاء به Google Mobile Ads SDK نسخه 10.0.0 برنامه شما را در دستگاه‌های iOS 11 و iOS 10 خراب نمی‌کند، با این حال، هیچ تبلیغی در آن دستگاه‌ها نمایش داده نمی‌شود.

ساخت با بیت کد دیگر پشتیبانی نمی شود

اکنون برای ادغام Google Mobile Ads SDK، غیرفعال کردن بیت کد در برنامه های تلفن همراه شما لازم است.

انواع حذف شده است

تایپ کنید یادداشت
GADGender بدون جایگزینی
پروتکل GADMRewardBasedVideoAdNetworkAdapter همه آداپتورهای واسطه‌ای پاداش‌دار فهرست‌شده در Choose Networks استفاده از این پروتکل‌ها را برای بیش از یک سال متوقف کرده‌اند. از GADMediationAdapter برای میانجیگری و رویدادهای سفارشی استفاده کنید.
پروتکل GADMRewardBasedVideoAdNetworkConnector

خواص حذف شد

ویژگی های زیر بدون جایگزینی حذف می شوند.

کلاس v10.0.0 ویژگی
GADMediationAdRequest تولد کاربر
userGender
userHasLocation
userLatitude
طول کاربر
userLocationAccuracyInMeters
userLocationDescription
GADCustomEvent Request userHasLocation
userLatitude
طول کاربر
userLocationAccuracyInMeters
userLocationDescription
،

تبلیغات در iOS 11 متوقف می شود

Google Mobile Ads SDK نسخه 10.0.0 تبلیغات را فقط در دستگاه‌های دارای iOS 12 و بالاتر ارائه می‌کند.

ارتقاء به Google Mobile Ads SDK نسخه 10.0.0 برنامه شما را در دستگاه‌های iOS 11 و iOS 10 خراب نمی‌کند، با این حال، هیچ تبلیغی در آن دستگاه‌ها نمایش داده نمی‌شود.

ساخت با بیت کد دیگر پشتیبانی نمی شود

اکنون برای ادغام Google Mobile Ads SDK، غیرفعال کردن بیت کد در برنامه های تلفن همراه شما لازم است.

انواع حذف شده است

تایپ کنید یادداشت
GADGender بدون جایگزینی
پروتکل GADMRewardBasedVideoAdNetworkAdapter همه آداپتورهای واسطه‌ای پاداش‌دار فهرست‌شده در Choose Networks استفاده از این پروتکل‌ها را برای بیش از یک سال متوقف کرده‌اند. از GADMediationAdapter برای میانجیگری و رویدادهای سفارشی استفاده کنید.
پروتکل GADMRewardBasedVideoAdNetworkConnector

خواص حذف شد

ویژگی های زیر بدون جایگزینی حذف می شوند.

کلاس v10.0.0 ویژگی
GADMediationAdRequest تولد کاربر
userGender
userHasLocation
userLatitude
طول کاربر
userLocationAccuracyInMeters
userLocationDescription
GADCustomEvent Request userHasLocation
userLatitude
طول کاربر
userLocationAccuracyInMeters
userLocationDescription

از نسخه 8 به نسخه 9 مهاجرت کنید

تبلیغات در iOS 10 متوقف می شود

حداقل نسخه iOS که Google Mobile Ads SDK نسخه 9.0.0 پشتیبانی می کند iOS 11 است.

ارتقاء به Google Mobile Ads SDK نسخه 9.0.0 برنامه شما را در دستگاه‌های iOS 10 خراب نمی‌کند، اما هیچ تبلیغی در آن دستگاه‌ها نمایش داده نمی‌شود.

اجرای دقیق تر کنترل های نوار وضعیت

با شروع از نسخه 9.0.0، هنگامی که تبلیغات با فرمت تمام صفحه را ارائه می کنید، برنامه شما باید اطمینان حاصل کند که تبلیغات قادر به کنترل نمایش نوار وضعیت هستند. اگر این کار را انجام ندهید، یک پیغام خطا در گزارش ها مشاهده خواهید کرد.

بسته به طرح‌بندی خاص کنترل‌کننده‌های نمایش در برنامه‌تان، ممکن است نیازی به ایجاد هیچ تغییری برای اطمینان از این نداشته باشید. در نظر بگیرید که آیا باید ویژگی childViewControllerForStatusBarHidden را در rootViewController آگهی خود تنظیم کنید.

تغییر نام adDidPresentFullScreenContent: به adWillPresentFullScreenContent:

هیچ تغییر رفتاری وجود ندارد. روش delegate درست قبل از ارائه آگهی فراخوانی می شود، بنابراین نام روش جدید عملکرد آن را بهتر نشان می دهد.

API تنظیم مکان را در GADRequest حذف کنید

- (void)setLocationWithLatitude:longitude:accuracy: از GADRequest حذف شده است زیرا اطلاعات مکان توسط Google برای هدف‌یابی تبلیغات استفاده نمی‌شود. در صورت لزوم از API های شخص ثالث برای ارائه اطلاعات به شبکه های تبلیغاتی شخص ثالث استفاده کنید.

منسوخ شدن رابط های رویداد سفارشی

رویدادهای سفارشی ناشران را با استفاده از AdMob Mediation قادر می‌سازند تا میانجی‌گری آبشار را برای یک شبکه تبلیغاتی که یکی از شبکه‌های تبلیغاتی پشتیبانی‌شده نیست اضافه کنند.

همه پروتکل های رویداد سفارشی منسوخ شده اند. در عوض، از پروتکل‌های GADMediationAdapter و GADMediationAdEventDelegate موجود برای دستیابی به عملکردهای مشابه استفاده کنید. این تغییر وضوح را بهبود می‌بخشد و شما را قادر می‌سازد رویدادهای سفارشی را برای آگهی‌های دارای پاداش و آگهی‌های بین اسکرولری که قبلاً در دسترس نبودند ایجاد کنید.

API ها

جدول زیر APIهای آداپتور میانجی مربوط به APIهای رویدادهای سفارشی را فهرست می‌کند که باید از نسخه 9.0.0 استفاده شوند.

v8 v9
GADCustomEventBanner
GADCustomEventInterstitial
GADCustomEventNativeAd
GADMediationAdapter GADMediationBannerAd
GADMediationInterstitialAd
GADMediationInterscrollerAd
GADMediationRewardedAd
GADMediationNativeAd
delegate Delegate توسط کنترل کننده تکمیل بار هر تابع بار از کلاس GADMediationAdapter برگردانده می شود.
-init -init
-requestBannerAd:parameter: label:request: -loadBannerForAdConfiguration: completionHandler:
-requestInterstitialAdWith Parameter:label:request: -loadInterstitialFor AdConfiguration: completionHandler:
-requestNativeAdWithParameter: request:adTypes:options: rootViewController: -loadNativeAdFor AdConfiguration: completionHandler:
N/A -loadInterscrollerAdFor AdConfiguration: completionHandler:
N/A -loadRewardedAdFor AdConfiguration: completionHandler:
-presentFromRootViewController: -presentFromViewController:
-handlesUserClicks -handlesUserClicks
-handlesUserImpressions -handlesUserImpressions

روش های تفویض اختیار

جدول زیر روش‌های انتقال رویداد آگهی میانجی‌گری مربوط به روش‌های واگذاری رویداد سفارشی را فهرست می‌کند که باید از نسخه 9.0.0 استفاده شوند.

v8 v9
GADCustomEventBannerDelegate
GADCustomEventInterstitialDelegate
GADCustomEventNativeAdDelegate
GADMediationAdEvent Delegate GADMediationAd
-customEventBanner:didReceiveAd:
-customEventInterstitialDidReceiveAd:
وضعیت بار آگهی در کنترل کننده تکمیل بار هر تابع بار در کلاس GADMediationAdapter گنجانده شده است.
-customEventBanner:didFailAd:
-customEventInterstitial:didFailAd:
-customEventBannerWasClicked:
-customEventInterstitialWasClicked:
-reportClick
-customEventBannerWill PresentModal:
-customEventInterstitialWill PresentModal:
-willPresentFullScreenView
-customEventBannerWill DismissModal:
-customEventInterstitialWill DismissModal:
-willDismissFullScreenView
-customEventBannerDid DismissModal:
-customEventInterstitialDid DismissModal:
-didDismissFullScreenView
-customEventBannerWill LeaveApplication:
-customEventInterstitialWill LeaveApplication:
-willBackgroundApplication
viewControllerFor PresentingModalView -[GADMediationBannerAd view]

سایر روش ها و ثابت های حذف/جایگزین شده

تغییرات در روش، ثابت یا ویژگی
kGAD- ثابت های پیشوند حذف شده. از ثابت های پیشوند GAD- استفاده کنید.
GADAdNetworkResponseInfo credentials حذف شد به جای آن از adUnitMapping استفاده کنید.
GADCustomNativeAd mediaView در GADCustomNativeAd منسوخ شده است. به جای آن mediaContent استفاده کنید.
APIهای خرید درون برنامه ای در GoogleMobileAds APIهای inAppPurchase در GoogleMobileAds حذف شدند.

از نسخه 7 به نسخه 8 مهاجرت کنید

Google Mobile Ads SDK نسخه 8.0.0 چند تغییر عمده و همچنین برخی تغییر نام ها و حذف API ها را معرفی می کند.

به روز رسانی API با فرمت تمام صفحه

با شروع نسخه 8.0.0، تبلیغات بینابینی و دارای پاداش، یک سبک عمومی تبلیغات تمام صفحه را برای ثبات بیشتر به اشتراک می گذارند. این APIهای تبلیغات تمام صفحه جدید دو تفاوت عمده با APIهای تبلیغات تمام صفحه نسخه 7 دارند:

  1. load روش کلاس استاتیک

    روش قبلی برای بارگیری/نمایش آگهی تمام صفحه به شرح زیر است:

    1. یک نمونه شیء تبلیغاتی ایجاد کنید و یک مرجع به آن نگه دارید.
    2. نماینده ای اختصاص دهید که بارگیری و نمایش تماس های برگشتی را انجام دهد.
    3. یک تبلیغ را بارگیری کنید.
    4. بررسی کنید که آیا آگهی با استفاده از isReady بارگیری شده است.
    5. آگهی را نمایش دهید.

    در نسخه 8، رویکرد کمی تغییر می کند. تماس‌های بارگیری دیگر بخشی از یک نماینده نیستند. در عوض، آنها به عنوان یک کنترل کننده تکمیل به روش load منتقل می شوند:

    1. یک روش بار استاتیک در کلاس تبلیغات فراخوانی کنید و یک کنترل کننده تکمیل بار ارائه دهید.
    2. در پاسخ به تماس تکمیل بارگذاری، به آگهی بارگیری شده که برگردانده شده است اشاره کنید.
    3. نماینده ای اختصاص دهید که پاسخگوی تماس های نمایشی را کنترل کند.
    4. آگهی را نمایش دهید.

    رویکرد جدید این مزایا را فراهم می کند:

    • شما هرگز به تبلیغی که بارگذاری نشده است اشاره ای نخواهید داشت.
    • در حین بارگذاری یک شیء تبلیغاتی مجبور نیستید آن را نگه دارید.
  2. رویدادهای تبلیغاتی مداوم

    نوع رویداد API موجود v8 API
    بارگذاری رویدادها GADInterstitialDelegate یا GADRewardedAdDelegate GADInterstitialAdLoadCompletionHandler یا GADRewardedAdLoadCompletionHandler
    رویدادهای ارائه GADFullScreenContentDelegate

    قبلاً، برای گوش دادن به رویدادهای تبلیغاتی، کلاسی را ثبت می‌کردید که پروتکل GADInterstitialDelegate را در ویژگی نماینده یک بینابینی پیاده‌سازی می‌کند، یا کلاسی را ثبت می‌کنید که پروتکل GADRewardedAdDelegate را بسته به قالبی که از آن استفاده می‌کنید، در ویژگی نماینده آگهی پاداش‌دهی شده پیاده‌سازی می‌کند. همین نماینده روش‌هایی داشت که هم به چرخه عمر بارگذاری و هم ارائه آگهی مربوط می‌شد.

    با نسخه 8، رویدادهای بارگذاری و ارائه جداگانه هستند. اکنون می‌توانید یک GADFullScreenContentDelegate را هر زمان که بخواهید قبل از نمایش آگهی ثبت کنید، به‌جای اینکه قبل از بارگیری آگهی، یک نماینده را تعیین کنید. رویدادهای بار آگهی، که مخصوص هر قالب هستند، به یک کنترل کننده تکمیل بار منتقل می شوند که در روش بارگذاری ارسال شده است.

بینابینی

بارگذاری آگهی

قطعه کد زیر به شما نشان می دهد که چگونه یک تبلیغ بینابینی را بارگیری کنید و در صورت موفقیت یا عدم بارگیری آگهی به رویدادها گوش دهید.

v7

سریع

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADInterstitialDelegate {

  var interstitial: GADInterstitial!

  override func viewDidLoad() {
    super.viewDidLoad()
    interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/44118910")
    interstitial.delegate = self
    let request = GADRequest()
    interstitial.load(request)
  }

  /// Tells the delegate an ad request succeeded.
  func interstitialDidReceiveAd(_ ad: GADInterstitial) {
    print("Interstitial ad loaded.")
  }

  /// Tells the delegate an ad request failed.
  func interstitial(_ ad: GADInterstitial, didFailToReceiveAdWithError error: GADRequestError) {
    print("Interstitial ad failed to load with error: \(error.localizedDescription)")
  }
}

هدف-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADInterstitial *interstitial;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  self.interstitial = [[GADInterstitial alloc]
      initWithAdUnitID:@"ca-app-pub-3940256099942544/44118910"];
  self.interstitial.delegate = self;
  GADRequest *request = [GADRequest request];
  [self.interstitial loadRequest:request];
}

/// Tells the delegate an ad request succeeded.
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad {
  NSLog(@"Insterstitial ad loaded.");
}

/// Tells the delegate an ad request failed.
- (void)interstitial:(GADInterstitial *)ad
    didFailToReceiveAdWithError:(GADRequestError *)error {
  NSLog(@"Interstitial ad failed to load with error: %@", [error localizedDescription]);
}

v8

سریع

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADFullScreenContentDelegate {

  var interstitial: GADInterstitialAd?

  override func viewDidLoad() {
    super.viewDidLoad()
    let request = GADRequest()
    GADInterstitialAd.load(withAdUnitID:"ca-app-pub-8123415297019784/4985798738",
                                request: request,
                      completionHandler: { (ad, error) in
                        if let error = error {
                          print("Failed to load interstitial ad with error: \(error.localizedDescription)")
                          return
                        }
                        self.interstitial = ad
                        self.interstitial.fullScreenContentDelegate = self
                      }
    )
  }
}

هدف-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADInterstitialAd *interstitial;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  GADRequest *request = [GADRequest request];
  [GADInterstitialAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/44118910"
                              request:request
                    completionHandler:^(GADInterstitialAd *ad, NSError *error) {
    if (error) {
      NSLog(@"Failed to load interstitial ad with error: %@", [error localizedDescription]);
      return;
    }
    self.interstitial = ad;
    self.interstitial.fullScreenContentDelegate = self;
  }];
}

نمایش تبلیغ

v7

سریع

func showInterstitial() {
  ...
  if interstitial.isReady {
    interstitial.present(fromRootViewController: self)
  } else {
    print("Ad wasn't ready")
  }
}

هدف-C

- (void)showInterstitial: {
  ...
  if (self.interstitial.isReady) {
    [self.interstitial presentFromRootViewController:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

v8

سریع

func showInterstitial() {
  ...
  if let ad = interstitial {
    ad.present(fromRootViewController: self)
  } else {
    print("Ad wasn't ready")
  }
}

هدف-C

- (void)showInterstitial: {
  ...
  if (self.interstitial) {
    [self.interstitial presentFromRootViewController:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

رویدادهای تبلیغاتی ارائه

تکه‌های کد زیر به شما نشان می‌دهند که چگونه می‌توانید با تماس‌های زمانی که آگهی ارائه می‌شود (با موفقیت یا ناموفق) و زمانی که رد می‌شود، تماس بگیرید.

v7

سریع

override func viewDidLoad() {
  super.viewDidLoad()
  interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/44118910")
  interstitial.delegate = self
  ...
}

/// Tells the delegate that an interstitial will be presented.
func interstitialWillPresentScreen(_ ad: GADInterstitial) {
  print("Interstitial ad will be presented.")
}

/// Tells the delegate the interstitial is to be animated off the screen.
func interstitialWillDismissScreen(_ ad: GADInterstitial) {
  print("Interstitial ad will be dismissed.")
}

/// Tells the delegate the interstitial had been animated off the screen.
func interstitialDidDismissScreen(_ ad: GADInterstitial) {
  print("Interstitial ad dismissed.")
}

/// Tells the delegate that a user click will open another app
/// (such as the App Store), backgrounding the current app.
///
/// This is not a reliable callback for an ad click event and is removed in
/// version 8. If you wish to listen to an ad causing a user to leave the app,
/// use applicationWillResignActive: or sceneWillResignActive: instead.
func interstitialWillLeaveApplication(_ ad: GADInterstitial) {
  print("Interstitial ad will leave application.")
}

هدف-C

- (void)viewDidLoad {
  [super viewDidLoad];
  self.interstitial = [[GADInterstitial alloc] initWithAdUnitID:"ca-app-pub-3940256099942544/44118910"];
  self.interstitial.delegate = self;
  ...
}

/// Tells the delegate that an interstitial will be presented.
- (void)interstitialWillPresentScreen:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad will be presented.");
}

/// Tells the delegate the interstitial is to be animated off the screen.
- (void)interstitialWillDismissScreen:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad will be dismissed.");
}

/// Tells the delegate the interstitial had been animated off the screen.
- (void)interstitialDidDismissScreen:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad dismissed.");
}

/// Tells the delegate that a user click will open another app
/// (such as the App Store), backgrounding the current app.
///
/// This is not a reliable callback for an ad click event and is removed in
/// version 8. If you wish to listen to an ad causing a user to leave the app,
/// use applicationWillResignActive: or sceneWillResignActive: instead.
- (void)interstitialWillLeaveApplication:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad will leave application.");
}

v8

سریع

override func viewDidLoad() {
  super.viewDidLoad()
  let request = GADRequest()
  GADInterstitialAd.load(withAdUnitID:"ca-app-pub-8123415297019784/4985798738",
                              request: request,
                    completionHandler: { (ad, error) in
                      if let error = error {
                        print(error.localizedDescription)
                        return
                      }
                      self.interstitial = ad
                      self.interstitial.fullScreenContentDelegate = self
                    }
  )
}

func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Ad did present full screen content.")
}

func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
  print("Ad failed to present full screen content with error \(error.localizedDescription).")
}

func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Ad did dismiss full screen content.")
}

هدف-C

- (void)viewDidLoad {
  [super viewDidLoad];
  GADRequest *request = [GADRequest request];
  [GADInterstitialAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/44118910"
                              request:request
                    completionHandler:^(GADInterstitialAd *ad, NSError *error) {
    if (error) {
      NSLog(@"interstitial:didFailToReceiveAdWithError: %@", [error localizedDescription])
      return;
    }
    self.interstitial = ad;
    self.interstitial.fullScreenContentDelegate = self;
  }];
}

- (void)adDidPresentFullScreenContent:(id)ad {
  NSLog(@"Ad did present full screen content.");
}

- (void)ad:(id)ad didFailToPresentFullScreenContentWithError:(NSError *)error {
  NSLog(@"Ad failed to present full screen content with error %@.", [error localizedDescription]);
}

- (void)adDidDismissFullScreenContent:(id)ad {
  NSLog(@"Ad did dismiss full screen content.");
}

پاداش داده شد

بارگذاری آگهی

v7

سریع

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADRewardedAdDelegate {
  /// The rewarded ad.
  var rewardedAd: GADRewardedAd?

  override func viewDidLoad() {
    super.viewDidLoad()
    rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313")
    rewardedAd.delegate = self
    rewardedAd?.load(GADRequest()) { error in
      if let error = error {
        print("Rewarded ad failed to load with error: \(error.localizedDescription)")
      } else {
        print("Rewarded ad loaded.")
      }
    }
  }
}

هدف-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADRewardedAd *rewardedAd;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  self.rewardedAd = [[GADRewardedAd alloc]
      initWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"];
  self.rewardedAd.delegate = self;
  GADRequest *request = [GADRequest request];
  [self.rewardedAd loadRequest:request completionHandler:^(GADRequestError * _Nullable error) {
    if (error) {
      NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
    } else {
      NSLog(@"Rewarded ad loaded.");
    }
  }];
}

v8

سریع

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADFullScreenContentDelegate {
  /// The rewarded ad.
  var rewardedAd: GADRewardedAd?

  override func viewDidLoad() {
  super.viewDidLoad()
  let request = GADRequest()
  GADRewardedAd.load(withAdUnitID: "ca-app-pub-8123415297019784/9501821136",
                          request: request, completionHandler: { (ad, error) in
                            if let error = error {
                              print("Rewarded ad failed to load with error: \(error.localizedDescription)")
                              return
                            }
                            self.rewardedAd = ad
                            self.rewardedAd?.fullScreenContentDelegate = self
                          }
  )
  }
}

هدف-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADRewardedAd *rewardedAd;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  GADRequest *request = [GADRequest request];
  [GADRewardedAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"
                          request:request
                completionHandler:^(GADRewardedAd *ad, NSError *error) {
    if (error) {
      NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
      return;
    }
    self.rewardedAd = ad;
    NSLog(@"Rewarded ad loaded.");
    self.rewardedAd.fullScreenContentDelegate = self;
}

نمایش تبلیغات و مدیریت پاداش

تبلیغات پاداش از شما می‌خواهد تا زمانی که کاربر پاداشی کسب می‌کند، رویداد را مدیریت کنید. با نسخه 7 API GADRewardedAd ، rewardedAd:userDidEarnReward: به عنوان بخشی از پروتکل GADRewardedAdDelegate پیاده سازی می کنید. برای نسخه 8، شما GADUserDidEarnRewardHandler را برای ارائه آگهی پیاده سازی می کنید.

v7

سریع

func showRewardedAd() {
  ...
  if rewardedAd.isReady {
    rewardedAd.present(fromRootViewController: self delegate:self)
  } else {
    print("Ad wasn't ready")
  }
}

/// Tells the delegate that the user earned a reward.
func rewardedAd(_ rewardedAd: GADRewardedAd, userDidEarnReward: GADAdReward) {
  // TODO: Reward the user.
}

هدف-C

- (void)showRewardedAd: {
  ...
  if (self.rewardedAd.isReady) {
    [self.rewardedAd presentFromRootViewController:self delegate:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

/// Tells the delegate that the user earned a reward.
- (void)rewardedAd:(GADRewardedAd *)rewardedAd userDidEarnReward:(GADAdReward *)reward {
  // TODO: Reward the user.
}

v8

سریع

func showRewardedAd() {
  ...
  if let ad = rewardedAd {
      ad.present(fromRootViewController: self,
               userDidEarnRewardHandler: {
                 let reward = ad.adReward
                 // TODO: Reward the user.
               }
      )
  } else {
    print("Ad wasn't ready")
  }
}

هدف-C

- (void)showRewardedAd: {
  ...
  if (self.rewardedAd) {
    [self.rewardedAd presentFromRootViewController:self
                          userDidEarnRewardHandler:^ {
      GADAdReward *reward = self.rewardedAd.adReward;
      // TODO: Reward the user.
    }];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

رویدادهای تبلیغاتی ارائه

با GADRewardedAd API شما یک GADRewardedAdDelegate را به روشی که تبلیغ را ارائه می دهد، ارسال می کنید. با GADRewardedAd API، یک GADFullscreenContentDelegate به عنوان یک ویژگی روی آگهی قبل از ارائه آگهی تنظیم می کنید.

v7

سریع

func showRewardedAd() {
  ...
  if rewardedAd.isReady {
    rewardedAd.present(fromRootViewController: self delegate:self)
  } else {
    print("Ad wasn't ready")
  }
}

/// Tells the delegate that the rewarded ad was presented.
func rewardedAdDidPresent(_ rewardedAd: GADRewardedAd) {
  print("Rewarded ad presented.")
}
/// Tells the delegate that the rewarded ad was dismissed.
func rewardedAdDidDismiss(_ rewardedAd: GADRewardedAd) {
  print("Rewarded ad dismissed.")
}
/// Tells the delegate that the rewarded ad failed to present.
func rewardedAd(_ rewardedAd: GADRewardedAd, didFailToPresentWithError error: Error) {
  print("Rewarded ad failed to present with error: \(error.localizedDescription).")
}

هدف-C

- (void)showRewardedAd: {
  ...
  if (self.rewardedAd.isReady) {
    [self.rewardedAd presentFromRootViewController:self delegate:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

/// Tells the delegate that the rewarded ad was presented.
- (void)rewardedAdDidPresent:(GADRewardedAd *)rewardedAd {
  NSLog(@"Rewarded ad presented.");
}

/// Tells the delegate that the rewarded ad failed to present.
- (void)rewardedAd:(GADRewardedAd *)rewardedAd didFailToPresentWithError:(NSError *)error {
  NSLog(@"Rewarded ad failed to present with error: %@",
        [error localizedDescription]);
}

/// Tells the delegate that the rewarded ad was dismissed.
- (void)rewardedAdDidDismiss:(GADRewardedAd *)rewardedAd {
  NSLog(@"Rewarded ad dismissed.");
}

v8

سریع

override func viewDidLoad() {
  super.viewDidLoad()
  let request = GADRequest()
  GADRewardedAd.load(withAdUnitID: "ca-app-pub-8123415297019784/9501821136",
                          request: request, completionHandler: { (ad, error) in
                            if let error = error {
                              print(error.localizedDescription)
                              return
                            }
                            self.rewardedAd = ad
                            self.rewardedAd?.fullScreenContentDelegate = self
                          }
  )
}

/// Tells the delegate that the rewarded ad was presented.
func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Rewarded ad presented.")
}
/// Tells the delegate that the rewarded ad was dismissed.
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Rewarded ad dismissed.")
}
/// Tells the delegate that the rewarded ad failed to present.
func ad(_ ad: GADFullScreenPresentingAd,
    didFailToPresentFullScreenContentWithError error: Error) {
  print("Rewarded ad failed to present with error: \(error.localizedDescription).")
}

هدف-C

- (void)viewDidLoad {
  [super viewDidLoad];

  GADRequest *request = [GADRequest request];
  [GADRewardedAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"
                          request:request
                completionHandler:^(GADRewardedAd *ad, NSError *error) {
    if (error) {
      NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
      return;
    }
    self.rewardedAd = ad;
    NSLog(@"Rewarded ad loaded.");
    self.rewardedAd.fullScreenContentDelegate = self;
}

/// Tells the delegate that the rewarded ad was presented.
- (void)adDidPresentFullScreenContent:(id)ad {
  NSLog(@"Rewarded ad presented.");
}

/// Tells the delegate that the rewarded ad failed to present.
- (void)ad:(id)ad
    didFailToPresentFullScreenContentWithError:(NSError *)error {
  NSLog(@"Rewarded ad failed to present with error: %@",
       [error localizedDescription]);
}

/// Tells the delegate that the rewarded ad was dismissed.
- (void)adDidDismissFullScreenContent:(id)ad {
  NSLog(@"Rewarded ad dismissed.");
}

حذف API Legacy GADRewardedBasedVideoAd

API جدیدتر GADRewardedAd برای اولین بار در مارس 2019 معرفی شد و برای بیش از 18 ماه بهترین API پاداش دار بوده است. در مقایسه با API قدیمی GADRewardedBasedVideoAd ، پیشرفت‌های بیشتری داشته است، از جمله توانایی بارگیری بیش از یک آگهی با پاداش در یک زمان.

API قدیمی GADRewardedBasedVideoAd در SDK نسخه 8.0.0 حذف شده است.

منسوخ شدن بنر هوشمند به نفع بنر تطبیقی

تبلیغات بنری هوشمند به نفع تبلیغات بنری تطبیقی ​​منسوخ شده است. بنرهای تطبیقی ​​عملکرد برتر و انعطاف پذیری بیشتری را در تنظیم عرض آگهی ارائه می دهند. اگر ترجیح می دهید به استفاده از بنرهای تمام عرض ادامه دهید، همچنان می توان با استفاده از بنر تطبیقی، همانطور که در قطعه کد زیر نشان داده شده است، این کار را انجام داد:

سریع

class ViewController: UIViewController {

  override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    // Note: The safe area is not known until viewWillAppear.
    let adSize = getFullWidthAdaptiveAdSize()
  }

  func getFullWidthAdaptiveAdSize() -> GADAdSize {
    // Here safe area is taken into account, hence the view frame is used after the
    // view has been laid out.
    let frame = { () -> CGRect in
      if #available(iOS 11.0, *) {
        return view.frame.inset(by: view.safeAreaInsets)
      } else {
        return view.frame
      }
    }()
    return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(frame.size.width)
  }
}

هدف-C

@implementation ViewController

- (void)viewDidAppear:(BOOL)animated {
  [super viewDidAppear:animated];
  // Note: The safe area is not known until viewWillAppear.
  GADAdSize adSize = [self getFullWidthAdaptiveAdSize];
}

- (GADAdSize)getFullWidthAdaptiveAdSize {
  CGRect frame = self.view.frame;
  // Here safe area is taken into account, hence the view frame is used after
  // the view has been laid out.
  if (@available(iOS 11.0, *)) {
    frame = UIEdgeInsetsInsetRect(self.view.frame, self.view.safeAreaInsets);
  }
  return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(frame.size.width);
}

@end

حذف پاسخ تماس برنامه را ترک کنید

willLeaveApplication برای همه قالب‌های تبلیغاتی به نفع روش‌های applicationDidEnterBackground: و sceneDidEnterBackground: حذف شده است. استفاده از API های سطح سیستم عامل هر زمان که کاربران برنامه شما را ترک می کنند، صرف نظر از اینکه به دلیل تعامل تبلیغاتی باشد یا نه، به شما اطلاع می دهد.

توجه داشته باشید که پاسخ تماس willLeaveApplication هرگز به عنوان یک کنترل کننده کلیک تبلیغات در نظر گرفته نشده است، و تکیه بر این تماس برای گزارش کلیک ها معیار دقیقی ایجاد نمی کند. به عنوان مثال، با کلیک بر روی نماد AdChoices که یک مرورگر خارجی را راه‌اندازی می‌کند، پاسخ تماس را فراخوانی می‌کند اما یک کلیک حساب نمی‌شود.

تغییر نام کلاس ها

جدول زیر نام کلاس‌های خاصی را که در نسخه 8 تغییر کرده یا حذف شده‌اند فهرست می‌کند.

  • همه کلاس‌های مربوط به GADUnifiedNativeAd به GADNativeAd تغییر نام داده‌اند.
  • GADRewardBasedVideoAd ، GADNativeExpressAdView ، و GADInstreamAd حذف شده‌اند.
  • همه کلاس‌های دارای پیشوند DFP با پیشوند GAM جایگزین شده‌اند.
کلاس v7.68.0 کلاس v8.0.0
DFPBannerView GAMBannerView
DFPBannerViewOptions GAMBannerViewOptions
DFPIInterstitial GAInterstitialAd
DFPRequest GAMRequest
خطای GADRequest خطای NSE
GADUnifiedNativeAdView GADNativeAdView
GADUnifiedNativeAd GADNativeAd
GADUnifiedNativeAdAssetIdentifiers GADNativeAdAssetIdentifiers
GADUnifiedNativeAdDelegate GADNativeAdDelegate
GADUnifiedNativeAdUnconfirmedClickDelegate GADNativeAdUnconfirmedClickDelegate
GADNativeCustomTemplateAd GADCustomNative Ad
GADNativeCustomTemplateAdLoaderDelegate GADCustomNativeAdLoaderDelegate
GADNativeAdDelegate GADCustomNativeAdDelegate
GADINAppPurchase حذف شده
GADInterstitial GADInterstitialAd
GADNativeExpressAdView حذف شده
GADRewardBasedVideoAd حذف شده
GADInstreamAd حذف شده
GADInstreamAdView حذف شده

روش‌ها حذف/جایگزین شدند

جدول زیر تغییرات خاص نسخه 8 را فهرست می کند. به طور خلاصه:

  • روش‌ها و ویژگی‌های منسوخ شده قبلی حذف شده‌اند.
  • -willLeaveApplication: روش های نمایندگی برای همه فرمت ها حذف شده است.
  • نام کلاس شبکه تبلیغاتی به ویژگی GADResponseInfo منتقل شده است.
  • شناسه دستگاه آزمایشی به ویژگی GADRequestConfiguration منتقل شده است.
کلاس v7.68.0 v7.68.0 API v8.0.0 API یادداشت
GADMobileAds +configureWithApplicationID: -startWithCompletion Handler: شناسه برنامه اکنون در Info.plist تنظیم شده است.
+disableAutomatedInApp PurchaseReporting -disableAutomatedInApp PurchaseReporting
+disableSDKCrashReporting غیرفعال کردن SDKCrashReporting
GADRequest دستگاه های تست GADRequestConfiguration .testdeviceidentifiers ویژگی testDeviceIdentifiers برای همه درخواست‌های تبلیغاتی اعمال می‌شود، در حالی که ویژگی قدیمی testDevices برای هر درخواست تنظیم شده بود.
جنسیت حذف شده
روز تولد حذف شده
+sdkVersion GADMobileAds.sharedInstance .sdkVersion
-setBirthday WithMonth:day:year: حذف شده
-setLocationWithDescription: -setLocationWith Latitude:longitude:accuracy:
-tagForChildDirectedTreatment: [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment]
GADErrorCode kGADEخطا* خطای GADE* پیشوند k از تمام ثابت های کد خطا حذف می شود.
GADBannerView دارای Refreshed خودکار است autoload فعال شد
inAppPurchaseDelegate حذف شده
mediatedAdView حذف شده
adNetworkClassName answerInfo .adNetworkClassName
DFPBannerView -setValidAdSizesWithSizes: -setValidAdSizes:
DFPBannerViewOptions -adSizeDelegate حذف شده
GADBannerViewDelegate -adViewDidReceiveAd: -bannerViewDidReceiveAd:
-adView:didFailToReceive AdWithError: -bannerView:didFailToReceive AdWithError:
-adViewWillPresentScreen: -bannerViewWillPresentScreen:
-adViewWillDismissScreen: -bannerViewWillDismissScreen:
-adViewDidDismissScreen: -bannerViewDidDisissScreen:
-adViewWillLeaveApplication: حذف شده
GADNativeCustomTemplateAd شناسه الگو GADCustomNativeAd.formatID
-performClickOnAssetWithKey: customClickHandler: -performClickOnAssetWithKey:
GADNativeAdImageAd LoaderOptions preferredImageOrientation GADNativeAdMediaAdOptions .mediaAspectRatio
GADInterstitial inAppPurchaseDelegate حذف شده
آماده است حذف شده به جای آن از canPresentFrom RootViewController:error: استفاده کنید.
استفاده شده است حذف شده
-init -initWithAdUnitID:
-setAdUnitID: -initWithAdUnitID:
adNetworkClassName answerInfo .adNetworkClassName
-interstitialWill LeaveApplication: حذف شده
GADUnifiedNativeAd ویدئو کنترلر mediaContent.videoController
adNetworkClassName answerInfo .adNetworkClassName