בדף הזה מוסבר איך לעבור לגרסאות הנוכחיות והקודמות של Google Mobile Ads SDK ל-iOS. אנחנו מתכננים להשיק את גרסה 13.0.0 בפברואר 2026.
מעבר מגרסה 12 לגרסה 13
הגדלת יעד הפריסה המינימלי
יעד הפריסה המינימלי עלה ל-iOS 13.
שינויים בממשקי ה-API של גודל מודעות הבאנר המותאמות והמעוגנות
בגרסה 13.0.0, ממשקי ה-API הקיימים לגודל של מודעות באנר מותאמות ומעוגנות הוצאו משימוש, ונוספו ממשקי API לגודל של מודעות באנר מותאמות ומעוגנות גדולות. Google Mobile Ads SDK יכולה להציג מודעות וידאו במודעות באנר באמצעות ממשקי ה-API החדשים של גודל מודעות באנר מותאמות ומעוגנות גדולות.
בטבלה הבאה מפורטים ממשקי ה-API להגדרת גודל שהוצאו משימוש והתחליפים שלהם:
| v12 (הוצאה משימוש) | גרסה 13 (החלפה) |
|---|---|
GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLargeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLargeLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLargePortraitAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
המשך התמיכה בבו-זמניות ב-Swift 6
בגרסה 13.0.0 ממשיכה התמיכה ב-Swift 6 strict concurrency.
הוספנו אכיפה מחמירה יותר של סוגי נתונים במערך neighboringContentURLStrings
החל מגרסה 13.0.0, Google Mobile Ads SDK מעלה חריגה אם מזוהה אובייקט שהוא לא מסוג String במערך neighboringContentURLStrings.
מעבר מגרסה 11 לגרסה 12
שדרוג ל-Xcode 16.0
הגרסה המינימלית הנתמכת של Xcode עלתה ל-16.0.
תמיכה במתן שמות ב-Swift
גרסה 12.0.0 כוללת שינויים שנועדו להתאים למוסכמות למתן שמות בהנחיות לעיצוב API של Swift. השינויים האלה משפיעים רק על Swift. לא בוצעו שינויים בשמות של ממשקי ה-API של Objective-C.
שינויים בקידומת של הכיתה
השינויים הבאים בוצעו בתחיליות של המחלקות:
- הסרנו את הקידומת
GADמהשמות של כל הסוגים. - הקידומת
GAMשונתה ל-AdManager. - הקידומת
GADMשונתה ל-Mediation.
פתרון שגיאות
הדרך הטובה ביותר לפתור שגיאות שנובעות מהשינויים האלה היא לבצע תיקון באמצעות Fix-It.
פתרון התנגשויות בשמות
כדי לפתור התנגשויות בשמות, צריך להשתמש במרחב השמות שסופק על ידי המודול. לדוגמה, GADRequest נקרא עכשיו Request. בדוגמה הבאה, מרחב השמות Google Mobile Ads SDK כולל את המחלקה Request:
import GoogleMobileAds
...
var request: GoogleMobileAds.Request?
רשימה מפורטת של השינויים ב-Swift
בטבלאות הבאות מפורטים השינויים שבוצעו בממשקי ה-API של Swift:
| גרסה 11 | גרסה 12 |
|---|---|
GADAdapterInitializationState |
AdapterInitializationState |
GADAdChoicesPosition |
AdChoicesPosition |
GADAdChoicesView |
AdChoicesView |
GADAdFormat |
AdFormat |
GADAdLoader |
AdLoader |
GADAdLoaderAdType |
AdLoaderAdType |
GADAdLoaderDelegate |
AdLoaderDelegate |
GADAdMetadataDelegate |
AdMetadataDelegate |
GADAdMetadataProvider |
AdMetadataProvider |
GADAdNetworkExtras |
AdNetworkExtras |
GADAdNetworkResponseInfo |
AdNetworkResponseInfo |
GADAdReward |
AdReward |
GADAdSize |
AdSize |
GADAdSizeDelegate |
AdSizeDelegate |
GADAdValue |
AdValue |
GADAdValuePrecision |
AdValuePrecision |
GADAppEventDelegate |
AppEventDelegate |
GADAppOpenAd |
AppOpenAd |
GADAppOpenSignalRequest |
AppOpenSignalRequest |
GADAudioVideoManager |
AudioVideoManager |
GADAudioVideoManagerDelegate |
AudioVideoManagerDelegate |
GADBannerSignalRequest |
BannerSignalRequest |
GADBannerView |
BannerView |
GADBannerViewDelegate |
BannerViewDelegate |
GADCustomEventExtras |
CustomEventExtras |
GADCustomEventRequest |
CustomEventRequest |
GADCustomNativeAd |
CustomNativeAd |
GADCustomNativeAdLoaderDelegate |
CustomNativeAdLoaderDelegate |
GADCustomNativeAdDelegate |
CustomNativeAdDelegate |
GADDebugOptionsViewControllerDelegate |
DebugOptionsViewControllerDelegate |
GADDebugOptionsViewController |
DebugOptionsViewController |
GADDisplayAdMeasurement |
DisplayAdMeasurement |
GADExtras |
Extras |
GADFullScreenPresentingAd |
FullScreenPresentingAd |
GADFullScreenContentDelegate |
FullScreenContentDelegate |
GADAdapterStatus |
AdapterStatus |
GADInitializationStatus |
InitializationStatus |
GADInterstitialAd |
InterstitialAd |
GADInterstitialSignalRequest |
InterstitialSignalRequest |
GADMediaAspectRatio |
MediaAspectRatio |
GADMediaContent |
MediaContent |
GADMediaView |
MediaView |
GADMobileAds |
MobileAds |
GADMultipleAdsAdLoaderOptions |
MultipleAdsAdLoaderOptions |
GADMuteThisAdReason |
MuteThisAdReason |
GADNativeAd |
NativeAd |
GADNativeAdLoaderDelegate |
NativeAdLoaderDelegate |
GADNativeAdView |
NativeAdView |
GADNativeAdCustomClickGestureOptions |
NativeAdCustomClickGestureOptions |
GADNativeAdDelegate |
NativeAdDelegate |
GADNativeAdImage |
NativeAdImage |
GADNativeAdImageAdLoaderOptions |
NativeAdImageAdLoaderOptions |
GADNativeAdInlineBehavior |
NativeAdInlineBehavior |
GADNativeAdInlineBehaviorOptions |
NativeAdInlineBehaviorOptions |
GADNativeAdMediaAdLoaderOptions |
NativeAdMediaAdLoaderOptions |
GADNativeAdUnconfirmedClickDelegate |
NativeAdUnconfirmedClickDelegate |
GADNativeAdViewAdOptions |
NativeAdViewAdOptions |
GADNativeMuteThisAdLoaderOptions |
NativeMuteThisAdLoaderOptions |
GADNativeSignalRequest |
NativeSignalRequest |
GADPresentationError |
PresentationError |
GADPublisherPrivacyPersonalizationState |
PublisherPrivacyPersonalizationState |
GADQueryInfo |
QueryInfo |
GADRequest |
Request |
GADRequestError |
RequestError |
GADRequestConfiguration |
RequestConfiguration |
GADResponseInfo |
ResponseInfo |
GADRewardedAd |
RewardedAd |
GADRewardedSignalRequest |
RewardedSignalRequest |
GADRewardedInterstitialAd |
RewardedInterstitialAd |
GADRewardedInterstitialSignalRequest |
RewardedInterstitialSignalRequest |
GADSearchBannerView |
SearchBannerView |
GADServerSideVerificationOptions |
ServerSideVerificationOptions |
GADSignal |
Signal |
GADSignalRequest |
SignalRequest |
GADVersionNumber |
VersionNumber |
GADVideoController |
VideoController |
GADVideoControllerDelegate |
VideoControllerDelegate |
| Ad Manager | |
GAMBannerAdLoaderDelegate |
AdManagerBannerAdLoaderDelegate |
GAMBannerView |
AdManagerBannerView |
GAMBannerViewOptions |
AdManagerBannerViewOptions |
GAMInterstitialAd |
AdManagerInterstitialAd |
GAMRequest |
AdManagerRequest |
| גישור | |
GADMAdNetworkAdapter |
MediationAdNetworkAdapter |
GADMAdNetworkConnector |
MediationAdNetworkConnector |
GADMBannerAnimationType |
MediationBannerAnimationType |
GADMediatedUnifiedNativeAd |
MediationUnifiedNativeAd |
GADMediatedUnifiedNativeAdNotificationSource |
MediationUnifiedNativeAdNotificationSource |
GADMediationAd |
MediationAd |
GADMediationAdConfiguration |
MediationAdConfiguration |
GADMediationAdEventDelegate |
MediationAdEventDelegate |
GADMediationAdRequest |
MediationAdRequest |
GADMediationAdapter |
MediationAdapter |
GADMediationAppOpenAd |
MediationAppOpenAd |
GADMediationAppOpenAdEventDelegate |
MediationAppOpenAdEventDelegate |
GADMediationBannerAd |
MediationBannerAd |
GADMediationBannerAdConfiguration |
MediationBannerAdConfiguration |
GADMediationBannerAdEventDelegate |
MediationBannerAdEventDelegate |
GADMediationCredentials |
MediationCredentials |
GADMediationInterstitialAd |
MediationInterstitialAd |
GADMediationInterstitialAdConfiguration |
MediationInterstitialAdConfiguration |
GADMediationInterstitialAdEventDelegate |
MediationInterstitialAdEventDelegate |
GADMediationNativeAd |
MediationNativeAd |
GADMediationNativeAdConfiguration |
MediationNativeAdConfiguration |
GADMediationNativeAdEventDelegate |
MediationNativeAdEventDelegate |
GADMediationRewardedAd |
MediationRewardedAd |
GADMediationRewardedAdConfiguration |
MediationRewardedAdConfiguration |
GADMediationRewardedAdEventDelegate |
MediationRewardedAdEventDelegate |
GADMediationServerConfiguration |
MediationServerConfiguration |
| בידינג בזמן אמת | |
GADRTBAdapter |
RTBAdapter |
GADRTBMediationSignalsConfiguration |
RTBMediationSignalsConfiguration |
GADRTBRequestParameters |
RTBRequestParameters |
קבועים
| גרסה 11 | גרסה 12 |
|---|---|
GADAdLoaderAdType.gamBanner |
AdLoaderAdType.adManagerBanner |
GADAdSizeBanner |
AdSizeBanner |
GADAdSizeFluid |
AdSizeFluid |
GADAdSizeFullBanner |
AdSizeFullBanner |
GADAdSizeInvalid |
AdSizeInvalid |
GADAdSizeLargeBanner |
AdSizeLargeBanner |
GADAdSizeLeaderboard |
AdSizeLeaderboard |
GADAdSizeMediumRectangle |
AdSizeMediumRectangle |
GADAdSizeSkyscraper |
AdSizeSkyscraper |
GoogleMobileAdsVersionString |
GoogleMobileAdsVersion |
מאפיינים
| סוג | גרסה 11 | גרסה 12 |
|---|---|---|
| GADAdLoader | loading |
isLoading |
| GADAudioVideoManager | audioSessionApplicationManaged |
isAudioSessionApplicationManaged |
| GADBannerView | autoloadEnabled |
isAutoloadEnabled |
| GADMobileAds | sharedInstance |
shared |
applicationMuted |
isApplicationMuted |
|
| GADMuteThisAdReason | reasonDescription |
reason |
| GADNativeAd | customMuteThisAdAvailable |
isCustomMuteThisAdAvailable |
| GADNativeAdCustomClickGestureOptions | tapsAllowed |
areTapsAllowed |
| GADNativeAdImageAdLoaderOptions | imageLoadingDisabled |
isImageLoadingDisabled |
| GADNativeMuteThisAdLoaderOptions | customMuteThisAdRequested |
isCustomMuteThisAdRequested |
| GADNativeSignalRequest | imageLoadingDisabled |
isImageLoadingDisabled |
customMuteThisAdRequested |
isCustomMuteThisAdRequested |
|
| GADRequest | neighboringContentURLStrings |
neighboringContentURLs |
| GADResponseInfo | extrasDictionary |
extras |
| GADServerSideVerificationOptions | customRewardString |
customRewardText |
| GADSignal | signalString |
signal |
| GADSignalRequest | neighboringContentURLStrings |
neighboringContentURLs |
| GADVideoController | customControlsRequested |
areCustomControlsRequested |
clickToExpandEnabled |
isClickToExpandEnabled |
|
| GADVideoOptions | startMuted |
shouldStartMuted |
customControlsRequested |
areCustomControlsRequested |
|
clickToExpandRequested |
isClickToExpandRequested |
פונקציות
| סוג | גרסה 11 | גרסה 12 |
|---|---|---|
| GADAdSize | GADPortraitInlineAdaptiveBannerAdSizeWithWidth(_:) |
portraitInlineAdaptiveBanner(width:) |
GADLandscapeInlineAdaptiveBannerAdSizeWithWidth(_:) |
landscapeInlineAdaptiveBanner(width:) |
|
GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(_:) |
currentOrientationInlineAdaptiveBanner(width:) |
|
GADInlineAdaptiveBannerAdSizeWithWidthAndMaxHeight(_:, _:) |
inlineAdaptiveBanner(width:maxHeight:) |
|
GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(_:) |
portraitAnchoredAdaptiveBanner(width:) |
|
GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(_:) |
landscapeAnchoredAdaptiveBanner(width:) |
|
GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(_:) |
currentOrientationAnchoredAdaptiveBanner(width:) |
|
GADAdSizeFromCGSize(_:) |
adSizeFor(cgSize:) |
|
GADAdSizeFullWidthPortraitWithHeight(_:) |
fullWidthPortrait(height:) |
|
GADAdSizeFullWidthLandscapeWithHeight(_:) |
fullWidthLandscape(height:) |
|
GADAdSizeEqualToSize(_:, _:) |
isAdSizeEqualToSize(size1:size2:) |
|
IsGADAdSizeValid(_:) |
isAdSizeValid(size:) |
|
GADAdSizeIsFluid(_:) |
isAdSizeFluid(size:) |
|
CGSizeFromGADAdSize(_:) |
cgSize(for:) |
|
NSStringFromGADAdSize(_:) |
string(for:) |
|
NSValueFromGADAdSize(_:) |
nsValue(for:) |
|
GADAdSizeFromNSValue(_:) |
adSizeFor(nsValue:) |
|
GADClosestValidSizeForAdSizes(_:_:) |
closestValidSizeForAdSizes(original:possibleAdSizes:) |
|
| GADAppEventDelegate | adView(_:didReceiveAppEvent:withInfo:) |
adView(_:didReceiveAppEvent:with:) |
interstitialAd(_:didReceiveAppEvent:withInfo:) |
adView(_:didReceiveAppEvent:with:) |
|
| GADAppOpenAd | load(withAdResponseString:) |
load(with:) |
load(withAdUnitID:request:completionHandler:) |
load(with:request:completionHandler:) |
|
canPresent(fromRootViewController:) |
canPresent(from:) |
|
present(fromRootViewController:) |
present(from:) |
|
| GADBannerView | load(withAdResponseString:) |
load(with:) |
| GADInterstitial | load(withAdResponseString:) |
load(with:) |
load(withAdUnitID:request:completionHandler:) |
load(with:request:completionHandler:) |
|
canPresent(fromRootViewController:) |
canPresent(from:) |
|
present(fromRootViewController:) |
present(from:) |
|
| GADRewardedAd | load(withAdResponseString:) |
load(with:) |
load(withAdUnitID:request:completionHandler:) |
load(with:request:completionHandler:) |
|
canPresent(fromRootViewController:) |
canPresent(from:) |
|
present(fromRootViewController:userDidEarnRewardHandler:) |
present(from:userDidEarnRewardHandler:) |
|
| GADRewardedInterstitialAd | load(withAdResponseString:) |
load(with:) |
load(withAdUnitID:request:completionHandler:) |
load(with:request:completionHandler:) |
|
canPresent(fromRootViewController:) |
canPresent(from:) |
|
present(fromRootViewController:userDidEarnRewardHandler:) |
present(from:userDidEarnRewardHandler:) |
|
| GADVersionNumber | GADGetStringFromVersionNumber(_ version: GADVersionNumber) |
string(for:) |
| גישור | ||
| GADMAdNetworkAdapter | getBannerWith(_:) |
getBanner(with:) |
presentInterstitial(fromRootViewController:) |
presentInterstitial(from:) |
|
getNativeAd(withAdTypes:options:) |
getNativeAd(with:options:) |
|
| GADMediatedUnifiedNativeAd | didRecordClickOnAsset(withName:view:viewController:) |
didRecordClickOnAsset(with:view:viewController:) |
| GADMediationAdapter | setUpWith(_:completionHandler:) |
setUp(with:completionHandler:) |
| GADMediationAdSize | present(fromRootViewController:) |
present(from:) |
| GADMediationAppOpenAd | present(fromRootViewController:) |
present(from:) |
| GADMediationInterstitialAd | present(fromRootViewController:) |
present(from:) |
| GADMediationRewardedAd | present(fromRootViewController:) |
present(from:) |
| GAMInterstitialAd | load(withAdManagerAdUnitID:request:completionHandler:) |
load(with:request:completionHandler:) |
הגדרת פרמטרים של טירגוט בהתאמה אישית
כדי להגדיר טירגוט בהתאמה אישית בבקשה להצגת מודעה, משתמשים ב-customTargeting.
שינויים ב-API שקשורים לשליטה במצב ההשתקה של הסרטון
המאפיין isMuted וה-method setMute: ב-GADVideoController הוחלפו במאפיין muted.
שינויים במודעות מותאמות שמוצגות בתוך האפליקציה
כדי לנצל את השטח בצורה אופטימלית, מודעות מותאמות להצגה בתוך האפליקציה לא תופסות מקום בפריים בהתחלה. כשמפעילים את CGSizeFromGADAdSize(_:) עם גודל מודעה מותאם, עכשיו מוחזר גובה של 0 עד ש-Google Mobile Ads SDK מחזירה מודעה.
מודעות לרשת החיפוש בהתאמה אישית שהוסרו
המחלקות הבאות הוסרו ללא תחליף:
GADDynamicHeightSearchBannerViewGADDynamicHeightSearchRequestGADSearchBannerView
שינויים בקודי השגיאה
קודי השגיאה הבאים השתנו:
| מחלקה | הערות |
|---|---|
GADErrorMediationNoFill |
עכשיו השגיאות מוחזרות בתור GADErrorNoFill. |
GADErrorReceivedInvalidResponse |
הוחלף ב-GADErrorReceivedInvalidAdString. |
הוסר GADSimulatorID
בוצעה הסרה של GADSimulatorID. סימולטורים כבר נמצאים במצב בדיקה כברירת מחדל.
שינויים בטירגוט בהתאמה אישית
המילון customTargeting ב-GADRequest משתמש עכשיו ב-Any במקום ב-String כסוג הערך. כך אפשר להעביר ערכים מספריים ל-API.
שינויים בפרמטרים של תוספות
- העברת מפתחות אל
additionalParametersלא מחילה יותר טירגוט מותאם אישית על בקשות להצגת מודעות ב-Ad Manager. איך מפעילים טירגוט בהתאמה אישית
- אין יותר תמיכה בהעברת המפתח
max_ad_content_ratingאלadditionalParameters. כדי להגדיר סיווג מקסימלי לתוכן מודעה, עיינו במאמר בנושא סינון תוכן של מודעות.
מעבר מגרסה 10 לגרסה 11
יעד פריסה מינימלי
יעד הפריסה המינימלי הוגדל ל-iOS 12.
גרסת Xcode מינימלית
הגרסה המינימלית הנתמכת של Xcode עודכנה ל-15.1.
הצגת המודעות תופסק ב-iOS 12
גרסה 11.0.0 של Google Mobile Ads SDK מציגה מודעות רק במכשירים עם iOS מגרסה 13 ואילך.
הוסרה התלות ב-GoogleAppMeasurement
בגרסה 11.0.0, התלות ב-GoogleAppMeasurement הוסרה. התלות הזו, שהפעילה את המתג של מדדי המשתמשים ב-AdMob, תבוטל בתחילת שנת 2024. כדי להמשיך לאסוף מדדי משתמשים ב-AdMob, צריך לקשר את האפליקציה ב-AdMob ל-Firebase ולשלב את ה-SDK של Google Analytics for Firebase באפליקציה.
שינויים באופן ההצגה של מודעות במסך מלא
השינויים הבאים משפיעים על הפורמטים השונים של המודעות:
- מודעה בפתיחת אפליקציה
- מעברון
- ההטבה הופעלה
- מודעת מעברון מתגמלת
הפרמטר של בקר התצוגה ב--canPresentFromRootViewController:error: וב--presentFromRootViewController: יכול להיות ריק. אם מועבר הערך nil, המודעה מוצגת מבקר התצוגה העליון בהיררכיית בקרי התצוגה.
השיטות הוסרו
השיטות הבאות הוסרו.
| סוג v11.0.0 | שיטה | הערות |
|---|---|---|
| GADAppOpenAd | load(withAdUnitID adUnitID: String, request: GADRequest?, orientation: UIInterfaceOrientation) |
במקום זאת, אתם צריכים להשתמש ב-load(withAdUnitID adUnitID: String, request: GADRequest?). |
| GADMediationBannerAdEventDelegate | willBackgroundApplication() |
אין תחליף. |
| GADMediationInterstitialAdEventDelegate | willBackgroundApplication() |
אין תחליף. |
| GADMediationNativeAdEventDelegate | willBackgroundApplication() |
אין תחליף. |
| GADMediationRewardedAdEventDelegate | didRewardUser(with reward: GADAdReward) |
במקום זאת, אתם צריכים להשתמש ב-didRewardUser(). |
| GADMediatedUnifiedNativeAdNotificationSource | mediatedNativeAdWillLeaveApplication(_ mediatedNativeAd: GADMediatedUnifiedNativeAd) |
אין תחליף. |
| GADRequestConfiguration | setSameAppKeyEnabled(_ enabled: Bool) |
במקום זאת, אתם צריכים להשתמש ב-setPublisherFirstPartyIDEnabled(_ enabled: Bool). |
tagForUnderAge(ofConsent underAgeOfConsent: Bool) |
במקומו צריך להשתמש במאפיין tagForUnderAgeOfConsent. |
|
tag(forChildDirectedTreatment childDirectedTreatment: Bool) |
במקומו צריך להשתמש במאפיין tagForChildDirectedTreatment. |
הנכסים הוסרו
המאפיינים הבאים יוסרו.
| כיתה בגרסה 11.0.0 | נכס | הערות |
|---|---|---|
| GADMediationAdConfiguration | hasUserLocation | אין תחליף. |
| userLatitude | ||
| userLongitude | ||
| userLocationAccuracyInMeters | ||
| childDirectedTreatment | במקום זאת, אתם צריכים להשתמש ב-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 |
| v10.0.0 | v11.0.0 |
|
|
מעבר מגרסה 9 לגרסה 10
הצגת המודעות תופסק ב-iOS 11
גרסה 10.0.0 של Google Mobile Ads SDK מציגה מודעות רק במכשירים עם iOS מגרסה 12 ואילך.
שדרוג לגרסה 10.0.0 של Google Mobile Ads SDK לא ישבית את האפליקציה במכשירי iOS 11 ו-iOS 10, אבל לא יוצגו מודעות במכשירים האלה.
דרישה לגבי מזהה האפליקציה ב-Ad Manager
עכשיו חובה להזין את מזהה האפליקציה ב-Ad Manager בקובץ Info.plist בכל האפליקציות ב-Ad Manager, בפורמט ca-app-pub-################~##########. פרטים נוספים זמינים במאמר עדכון הקובץ Info.plist.
דרישה של GoogleAppMeasurement.xcframework
עכשיו צריך להוסיף את GoogleAppMeasurement.xcframework לכל האפליקציות ב-Ad Manager. אם מתקינים את Google Mobile Ads SDK דרך Cocoapods או Swift Package Manager, לא צריך לבצע פעולות נוספות. אם אתם מתקינים את ה-frameworks באופן ידני, תוכלו לקרוא פרטים נוספים בקטע הורדה ידנית.
אין יותר תמיכה בבנייה באמצעות ביטקוד
כדי לשלב את Google Mobile Ads SDK, צריך להשבית את הביטקוד באפליקציות לנייד.
סוגים שהוסרו
| סוג | הערות |
|---|---|
| GADGender | אין תחליף. |
| GADMRewardBasedVideoAdNetworkAdapterProtocol | כל המתאמים של תהליך בחירת הרשת (Mediation) למודעות מתגמלות שמופיעים בקטע בחירת רשתות הפסיקו להשתמש בפרוטוקולים האלה לפני יותר משנה. משתמשים ב- GADMediationAdapter לתהליך בחירת הרשת (Mediation) ולאירועים בהתאמה אישית. |
| GADMRewardBasedVideoAdNetworkConnectorProtocol |
הנכסים הוסרו
המאפיינים הבאים הוסרו בלי תחליף.
| כיתה v10.0.0 | נכס |
|---|---|
| GADMediationAdRequest | userBirthday |
| userGender | |
| userHasLocation | |
| userLatitude | |
| userLongitude | |
| userLocationAccuracyInMeters | |
| userLocationDescription | |
| GADCustomEventRequest | userHasLocation |
| userLatitude | |
| userLongitude | |
| userLocationAccuracyInMeters | |
| userLocationDescription |
מעבר מגרסה 8 לגרסה 9
הצגת המודעות הופסקה ב-iOS 10
גרסת iOS המינימלית שנתמכת בגרסה 9.0.0 של Google Mobile Ads SDK היא iOS 11.
שדרוג לגרסה 9.0.0 של Google Mobile Ads SDK לא ישבית את האפליקציה במכשירי iOS 10, אבל לא יוצגו מודעות במכשירים האלה.
אכיפה מחמירה יותר של אמצעי הבקרה בשורת הסטטוס
החל מגרסה 9.0.0, כשמציגים מודעות בפורמט של מסך מלא, האפליקציה צריכה לוודא שהמודעות יכולות לשלוט בהצגה של שורת הסטטוס. אם לא תעשו את זה, תופיע הודעת שגיאה ביומנים.
בהתאם לפריסה הספציפית של בקרי התצוגה באפליקציה, יכול להיות שלא תצטרכו לבצע שינויים כדי להבטיח זאת. חשוב לבדוק אם צריך להגדיר את המאפיין childViewControllerForStatusBarHidden ב-rootViewController של המודעה.
משנים את adDidPresentFullScreenContent: ל-adWillPresentFullScreenContent:
אין שינוי בהתנהגות. השיטה של הנציג מופעלת ממש לפני שהמודעה מוצגת, כך שהשם החדש של השיטה משקף טוב יותר את הפונקציונליות שלה.
הסרת ה-API להגדרת המיקום ב-GADRequest
האפשרות - (void)setLocationWithLatitude:longitude:accuracy: נמחקה מהקטע GADRequest כי Google לא משתמשת בנתוני מיקום כדי לטרגט מודעות. אם צריך, אפשר להשתמש בממשקי API של צד שלישי כדי לספק את המידע לרשתות מודעות של צד שלישי.
הוצאה משימוש של ממשקי אירועים בהתאמה אישית
אירועים בהתאמה אישית מאפשרים לבעלי אפליקציות שמשתמשים בתהליך בחירת הרשת ב-Ad Manager להוסיף רשימת רשתות בתהליך בחירת רשת עבור רשת מודעות שלא נכללת ברשתות המודעות הנתמכות.
כל הפרוטוקולים של האירועים בהתאמה אישית הוצאו משימוש. במקום זאת, השתמשו בפרוטוקולים הקיימים GADMediationAdapter ו-GADMediationAdEventDelegate כדי להשיג את אותן פונקציות. השינוי הזה משפר את הבהירות ומאפשר לכם ליצור אירועים מותאמים אישית למודעות מתגמלות ולמודעות Interscroller, שלא היו זמינים בעבר.
ממשקי API
בטבלה הבאה מפורטים ממשקי ה-API של מתאם לבחירת רשת (Mediation) שתואמים לממשקי ה-API של אירועים בהתאמה אישית, שבהם צריך להשתמש החל מגרסה 9.0.0.
| v8 | v9 | |
|---|---|---|
| GADCustomEventBanner GADCustomEventInterstitial GADCustomEventNativeAd |
GADMediationAdapter | GADMediationBannerAd GADMediationInterstitialAd GADMediationInterscrollerAd GADMediationRewardedAd GADMediationNativeAd |
delegate
|
הנציג מוחזר על ידי ה-handler של השלמת הטעינה של כל פונקציית טעינה
של המחלקה GADMediationAdapter
|
|
-init |
-init |
|
-requestBannerAd:parameter: |
-loadBannerForAdConfiguration: |
|
-requestInterstitialAdWith |
-loadInterstitialFor |
|
-requestNativeAdWithParameter:
|
-loadNativeAdFor |
|
| לא רלוונטי | -loadInterscrollerAdFor |
|
| לא רלוונטי | -loadRewardedAdFor |
|
-presentFromRootViewController:
|
-presentFromViewController: |
|
-handlesUserClicks |
-handlesUserClicks |
|
-handlesUserImpressions |
-handlesUserImpressions |
|
שיטות של נציגים
בטבלה הבאה מפורטות השיטות של נציג אירועי המודעות בתהליך בחירת הרשת, שמתאימות לשיטות של נציג האירועים בהתאמה אישית שצריך להשתמש בהן החל מגרסה 9.0.0.
| v8 | v9 | |
|---|---|---|
| GADCustomEventBannerDelegate GADCustomEventInterstitialDelegate GADCustomEventNativeAdDelegate |
GADMediationAdEventDelegate | GADMediationAd |
-customEventBanner:didReceiveAd:-customEventInterstitialDidReceiveAd:
|
סטטוס טעינת המודעה נכלל ב-load completion handler של כל פונקציית טעינה במחלקה GADMediationAdapter
|
|
-customEventBanner:didFailAd:-customEventInterstitial:didFailAd:
|
||
-customEventBannerWasClicked:-customEventInterstitialWasClicked:
|
-reportClick |
|
-customEventBannerWill-customEventInterstitialWill
|
-willPresentFullScreenView |
|
-customEventBannerWill-customEventInterstitialWill
|
-willDismissFullScreenView |
|
-customEventBannerDid-customEventInterstitialDid
|
-didDismissFullScreenView |
|
-customEventBannerWill-customEventInterstitialWill
|
-willBackgroundApplication |
|
viewControllerFor |
-[GADMediationBannerAd view] |
|
שיטות וקבועים אחרים שהוסרו או הוחלפו
| שינויים ב-method, בקבוע או במאפיין | |
|---|---|
kGAD- קבועים עם תחילית
|
הנושא הוסר. משתמשים בקבועים עם הקידומת GAD-.
|
GADAdNetworkResponseInfo
|
credentials הוסרו. במקום זאת, אתם צריכים להשתמש ב-adUnitMapping.
|
GAMRequest
|
השדה kGAMSimulatorID ב-GAMRequest הוצא משימוש.
במקום זאת, צריך להשתמש ב-GADSimulatorID ב-GADRequestConfiguration.
|
GADCustomNativeAd
|
השדה mediaView ב-GADCustomNativeAd הוצא משימוש.
במקום זאת, אתם צריכים להשתמש ב-mediaContent.
|
ממשקי API לרכישות באפליקציה ב-GoogleMobileAds |
inAppPurchase ממשקי API ב-GoogleMobileAds הוסרו.
|
מעבר מגרסה 7 לגרסה 8
בגרסה 8.0.0 של Google Mobile Ads SDK יש כמה שינויים משמעותיים, וגם שינויי שמות והסרות של ממשקי API.
עדכונים ב-API של פורמט מסך מלא
החל מגרסה 8.0.0, מודעות מעברון ומודעות מתגמלות חולקות סגנון כללי של מודעות במסך מלא כדי לשמור על עקביות. יש שני הבדלים עיקריים בין ממשקי ה-API החדשים של המודעות במסך מלא לבין ממשקי ה-API של המודעות במסך מלא בגרסה 7:
שיטת מחלקה סטטית
load.הגישה הקודמת לטעינה או להצגה של מודעה במסך מלא היא:
- יוצרים מופע של אובייקט מודעה ושומרים הפניה אליו.
- מקצים נציג שמטפל בקריאות חוזרות (callbacks) של טעינה והצגה.
- טוענים מודעה.
- בודקים אם המודעה נטענה באמצעות
isReady. - הצגת המודעה.
בגרסה 8, הגישה משתנה קצת. קריאות חוזרות (callbacks) לטעינה כבר לא חלק מ-delegate. במקום זאת, הם מועברים ל-method
loadכ-completion handler:- מפעילים שיטת טעינה סטטית במחלקת המודעות ומספקים handler של השלמת טעינה.
- בקריאה החוזרת (callback) של השלמת הטעינה, שומרים הפניה למודעה שנטענה ומוחזרת.
- מקצים נציג שמטפל בקריאות חוזרות (callbacks) של הצגת מודעות.
- הצגת המודעה.
הגישה החדשה מספקת את היתרונות הבאים:
- לא תהיה לכם הפניה למודעה שלא נטענה.
- לא צריך להחזיק אובייקט של מודעה בזמן שהיא נטענת.
אירועי מודעות עקביים.
סוג אירוע API קיים v8 API אירועי טעינה GADInterstitialDelegateאוGADRewardedAdDelegate GAMInterstitialAdLoadCompletionHandlerאוGADRewardedAdLoadCompletionHandlerאירועי מצגות GADFullScreenContentDelegateבעבר, כדי להאזין לאירועים של מודעות, הייתם צריכים לרשום מחלקה שמטמיעה את הפרוטוקול
GADInterstitialDelegateלמאפיין הנציג של מודעת מעברון, או לרשום מחלקה שמטמיעה את הפרוטוקולGADRewardedAdDelegateלמאפיין הנציג של מודעה מתגמלת, בהתאם לפורמט שבו אתם משתמשים. ל-delegate הזה היו שיטות שקשורות גם למחזור החיים של הטעינה וגם למחזור החיים של ההצגה של המודעה.בגרסה 8, אירועי הטעינה וההצגה נפרדים. עכשיו אפשר לרשום
GADFullScreenContentDelegateבכל שלב לפני הצגת המודעה, במקום להגדיר נציג אחד לפני טעינת המודעה. אירועי טעינת מודעות, שהם ספציפיים לכל פורמט, עוברים ל-handler יחיד של השלמת טעינה שמועבר בשיטת הטעינה.
מעברון
טעינת המודעה
קטעי הקוד הבאים מראים איך לטעון מודעת מעברון ולהאזין לאירועים כשהמודעה נטענת או לא נטענת.
v7
Swift
import GoogleMobileAds import UIKit class ViewController: UIViewController, GADInterstitialDelegate { var interstitial: DFPInterstitial! override func viewDidLoad() { super.viewDidLoad() interstitial = DFPInterstitial(adUnitID: "/21775744923/example/interstitial") interstitial.delegate = self let request = GAMRequest() interstitial.load(request) } /// Tells the delegate an ad request succeeded. func interstitialDidReceiveAd(_ ad: DFPInterstitial) { print("Interstitial ad loaded.") } /// Tells the delegate an ad request failed. func interstitial(_ ad: DFPInterstitial, didFailToReceiveAdWithError error: GADRequestError) { print("Interstitial ad failed to load with error: \(error.localizedDescription)") } }
Objective-C
@import GoogleMobileAds; @import UIKit; @interface ViewController ()@property(nonatomic, strong) DFPInterstitial *interstitial; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.interstitial = [[DFPInterstitial alloc] initWithAdUnitID:@"/21775744923/example/interstitial"]; self.interstitial.delegate = self; GAMRequest *request = [GAMRequest request]; [self.interstitial loadRequest:request]; } /// Tells the delegate an ad request succeeded. - (void)interstitialDidReceiveAd:(DFPInterstitial *)ad { NSLog(@"Insterstitial ad loaded."); } /// Tells the delegate an ad request failed. - (void)interstitial:(DFPInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error { NSLog(@"Interstitial ad failed to load with error: %@", [error localizedDescription]); }
v8
Swift
import GoogleMobileAds import UIKit class ViewController: UIViewController, GADFullScreenContentDelegate { var interstitial: GAMInterstitialAd? override func viewDidLoad() { super.viewDidLoad() let request = GAMRequest() GAMInterstitialAd.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 } ) } }
Objective-C
@import GoogleMobileAds; @import UIKit; @interface ViewController ()@property(nonatomic, strong) GAMInterstitialAd *interstitial; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; GAMRequest *request = [GAMRequest request]; [GAMInterstitialAd loadWithAdUnitID:@"/21775744923/example/interstitial" request:request completionHandler:^(GAMInterstitialAd *ad, NSError *error) { if (error) { NSLog(@"Failed to load interstitial ad with error: %@", [error localizedDescription]); return; } self.interstitial = ad; self.interstitial.fullScreenContentDelegate = self; }]; }
מודעה ברשת המדיה
v7
Swift
func showInterstitial() { ... if interstitial.isReady { interstitial.present(fromRootViewController: self) } else { print("Ad wasn't ready") } }
Objective-C
- (void)showInterstitial: { ... if (self.interstitial.isReady) { [self.interstitial presentFromRootViewController:self]; } else { NSLog(@"Ad wasn't ready"); } }
v8
Swift
func showInterstitial() { ... if let ad = interstitial { ad.present(fromRootViewController: self) } else { print("Ad wasn't ready") } }
Objective-C
- (void)showInterstitial: { ... if (self.interstitial) { [self.interstitial presentFromRootViewController:self]; } else { NSLog(@"Ad wasn't ready"); } }
אירועי מודעות במצגות
קטעי הקוד הבאים מראים איך לטפל בקריאות חוזרות (callbacks) כשהמודעה מוצגת (בהצלחה או לא) וכשהיא נסגרת.
v7
Swift
override func viewDidLoad() { super.viewDidLoad() interstitial = DFPInterstitial(adUnitID: "/21775744923/example/interstitial") interstitial.delegate = self ... } /// Tells the delegate that an interstitial will be presented. func interstitialWillPresentScreen(_ ad: DFPInterstitial) { print("Interstitial ad will be presented.") } /// Tells the delegate the interstitial is to be animated off the screen. func interstitialWillDismissScreen(_ ad: DFPInterstitial) { print("Interstitial ad will be dismissed.") } /// Tells the delegate the interstitial had been animated off the screen. func interstitialDidDismissScreen(_ ad: DFPInterstitial) { 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: DFPInterstitial) { print("Interstitial ad will leave application.") }
Objective-C
- (void)viewDidLoad { [super viewDidLoad]; self.interstitial = [[DFPInterstitial alloc] initWithAdUnitID:"/21775744923/example/interstitial"]; self.interstitial.delegate = self; ... } /// Tells the delegate that an interstitial will be presented. - (void)interstitialWillPresentScreen:(DFPInterstitial *)ad { NSLog(@"Interstitial ad will be presented."); } /// Tells the delegate the interstitial is to be animated off the screen. - (void)interstitialWillDismissScreen:(DFPInterstitial *)ad { NSLog(@"Interstitial ad will be dismissed."); } /// Tells the delegate the interstitial had been animated off the screen. - (void)interstitialDidDismissScreen:(DFPInterstitial *)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:(DFPInterstitial *)ad { NSLog(@"Interstitial ad will leave application."); }
v8
Swift
override func viewDidLoad() { super.viewDidLoad() let request = GAMRequest() GAMInterstitialAd.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.") }
Objective-C
- (void)viewDidLoad { [super viewDidLoad]; GAMRequest *request = [GAMRequest request]; [GAMInterstitialAd loadWithAdUnitID:@"/21775744923/example/interstitial" request:request completionHandler:^(GAMInterstitialAd *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
Swift
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(GAMRequest()) { error in if let error = error { print("Rewarded ad failed to load with error: \(error.localizedDescription)") } else { print("Rewarded ad loaded.") } } } }
Objective-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; GAMRequest *request = [GAMRequest 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
Swift
import GoogleMobileAds import UIKit class ViewController: UIViewController, GADFullScreenContentDelegate { /// The rewarded ad. var rewardedAd: GADRewardedAd? override func viewDidLoad() { super.viewDidLoad() let request = GAMRequest() 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 } ) } }
Objective-C
@import GoogleMobileAds; @import UIKit; @interface ViewController ()@property(nonatomic, strong) GADRewardedAd *rewardedAd; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; GAMRequest *request = [GAMRequest 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 של GADRewardedAd API, אתם מטמיעים את rewardedAd:userDidEarnReward: כחלק מהפרוטוקול של GADRewardedAdDelegate.
בגרסה 8, מטמיעים את GADUserDidEarnRewardHandler כדי להציג את המודעה.
v7
Swift
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. }
Objective-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
Swift
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") } }
Objective-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"); } }
אירועי מודעות במצגות
ב-API של GADRewardedAd, מעבירים GADRewardedAdDelegate ל-method שמציגה את המודעה. ב-API של GADRewardedAd, מגדירים GADFullscreenContentDelegate כמאפיין במודעה לפני שמציגים אותה.
v7
Swift
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).") }
Objective-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
Swift
override func viewDidLoad() { super.viewDidLoad() let request = GAMRequest() 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).") }
Objective-C
- (void)viewDidLoad { [super viewDidLoad]; GAMRequest *request = [GAMRequest 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 הקודם GADRewardedBasedVideoAd
GADRewardedAd API החדש יותר הוצג לראשונה במרץ 2019, והוא ה-API המועדף למודעות מתגמלות כבר יותר מ-18 חודשים. הוא כולל יותר שיפורים בהשוואה ל-API הקודם של GADRewardedBasedVideoAd, כולל היכולת לטעון יותר ממודעה מתגמלת אחת בכל פעם.
ה-API הקודם של GADRewardedBasedVideoAd הוסר בגרסה 8.0.0 של ה-SDK.
הוצאה משימוש של מודעות באנר חכמות לטובת מודעות באנר מותאמות
מודעות באנר חכמות הוצאו משימוש, ובמקומן אנחנו ממליצים להשתמש במודעות באנר מותאמות. מודעות באנר מותאמות מספקות ביצועים טובים יותר וגמישות רבה יותר בהגדרת רוחב המודעה. אם אתם מעדיפים להמשיך להשתמש במודעות באנר ברוחב מלא, אתם עדיין יכולים לעשות זאת באמצעות מודעות באנר מותאמות, כמו שמוצג בקטע הקוד הבא:
Swift
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) } }
Objective-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
הסרת קריאה חוזרת (callback) של אפליקציה כשיוצאים ממנה
הקריאה החוזרת (callback) של willLeaveApplication לכל הפורמטים של המודעות הוסרה, ובמקומה נוספו השיטות applicationDidEnterBackground: ו-sceneDidEnterBackground:. שימוש בממשקי API ברמת מערכת ההפעלה מאפשר לכם לקבל התראה בכל פעם שמשתמשים יוצאים מהאפליקציה, גם אם זה לא קשור לאינטראקציה עם מודעה.
חשוב לציין שהקריאה החוזרת (callback) של willLeaveApplication אף פעם לא נועדה לשמש כ-handler של קליקים על מודעות, והסתמכות על הקריאה החוזרת הזו לדיווח על קליקים לא הניבה מדד מדויק. לדוגמה, קליק על הסמל של AdChoices שהפעיל דפדפן חיצוני הפעיל את הקריאה החוזרת (callback), אבל לא נספר כקליק.
שינוי שמות של כיתות
בטבלה הבאה מפורטים שמות ספציפיים של מחלקות שהשתנו או הוסרו בגרסה 8. לסיכום:
- כל הכיתות שקשורות ל-
GADUnifiedNativeAdשונו ל-GADNativeAd. -
GADRewardBasedVideoAd,GADNativeExpressAdViewו-GADInstreamAdהוסרו. - כל המחלקות עם הקידומת
DFPהוחלפו בקידומתGAM.
| v7.68.0 Class | מחלקה בגרסה 8.0.0 |
|---|---|
| DFPBannerView | GAMBannerView |
| DFPBannerViewOptions | GAMBannerViewOptions |
| DFPInterstitial | GAMInterstitialAd |
| DFPRequest | GAMRequest |
| GADRequestError | NSError |
| GADUnifiedNativeAdView | GADNativeAdView |
| GADUnifiedNativeAd | GADNativeAd |
| GADUnifiedNativeAdAssetIdentifiers | GADNativeAdAssetIdentifiers |
| GADUnifiedNativeAdDelegate | GADNativeAdDelegate |
| GADUnifiedNativeAdUnconfirmedClickDelegate | GADNativeAdUnconfirmedClickDelegate |
| GADNativeCustomTemplateAd | GADCustomNativeAd |
| GADNativeCustomTemplateAdLoaderDelegate | GADCustomNativeAdLoaderDelegate |
| GADNativeAdDelegate | GADCustomNativeAdDelegate |
| GADInAppPurchase | הוסר |
| GADInterstitial | GADInterstitialAd |
| GADNativeExpressAdView | הוסר |
| GADRewardBasedVideoAd | הוסר |
| GADInstreamAd | הוסר |
| GADInstreamAdView | הוסר |
אמצעי התשלום שהוסרו או הוחלפו
בטבלה הבאה מפורטים השינויים הספציפיים בגרסה 8. לסיכום:
- הוסרו מאפיינים ו-methods שהוצאו משימוש בעבר.
- השיטות של
-willLeaveApplication:delegate הוסרו מכל הפורמטים. - שם הסיווג של רשת המודעות הועבר למאפיין
GADResponseInfo. - מזהה מכשיר הבדיקה הועבר למאפיין
GADRequestConfiguration.
| v7.68.0 Class | גרסה 7.68.0 של ה-API | v8.0.0 API | הערות |
|---|---|---|---|
| GADMobileAds | +configureWithApplicationID: | -startWithCompletionHandler: | מזהה האפליקציה מוגדר עכשיו ב-Info.plist. |
| +disableAutomatedInApp |
-disableAutomatedInApp |
||
| +disableSDKCrashReporting | -disableSDKCrashReporting | ||
| GADRequest | testDevices | GADRequestConfiguration |
המאפיין testDeviceIdentifiers חל על כל הבקשות להצגת מודעות, ואילו המאפיין הישן testDevices הוגדר לכל בקשה בנפרד. |
| gender | הוסר | ||
| יום הולדת | הוסר | ||
| +sdkVersion | GADMobileAds.sharedInstance |
||
| -setBirthday |
הוסר | ||
| -setLocationWithDescription: | -setLocationWith |
||
| -tagForChildDirectedTreatment: | [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment] | ||
| GADErrorCode | kGADError* | GADError* | הקידומת k הוסרה מכל קבועי קודי השגיאה.
|
| GADBannerView | hasAutoRefreshed | autoloadEnabled | |
| inAppPurchaseDelegate | הוסר | ||
| mediatedAdView | הוסר | ||
| adNetworkClassName | responseInfo |
||
| DFPBannerView | -setValidAdSizesWithSizes: | -setValidAdSizes: | |
| DFPBannerViewOptions | -adSizeDelegate | הוסר | |
| GADBannerViewDelegate | -adViewDidReceiveAd: | -bannerViewDidReceiveAd: | |
| -adView:didFailToReceive |
-bannerView:didFailToReceive |
||
| -adViewWillPresentScreen: | -bannerViewWillPresentScreen: | ||
| -adViewWillDismissScreen: | -bannerViewWillDismissScreen: | ||
| -adViewDidDismissScreen: | -bannerViewDidDismissScreen: | ||
| -adViewWillLeaveApplication: | הוסר | ||
| GADNativeCustomTemplateAd | templateID | GADCustomNativeAd.formatID | |
| -performClickOnAssetWithKey: |
-performClickOnAssetWithKey: | ||
| GADNativeAdImageAd |
preferredImageOrientation | GADNativeAdMediaAdOptions |
|
| GADInterstitial | inAppPurchaseDelegate | הוסר | |
| isReady | הוסר | במקום זאת, צריך להשתמש ב-canPresentFrom |
|
| hasBeenUsed | הוסר | ||
| -init | -initWithAdUnitID: | ||
| -setAdUnitID: | -initWithAdUnitID: | ||
| adNetworkClassName | responseInfo |
||
| -interstitialWill |
הוסר | ||
| GADUnifiedNativeAd | videoController | mediaContent.videoController | |
| adNetworkClassName | responseInfo |