במסגרת מדיניות Google בנושא הסכמת משתמשים באיחוד האירופי, עליכם להציג גילוי נאות בנושאים מסוימים למשתמשים שנמצאים באזור הכלכלי האירופי (EEA) לצד בריטניה, ולקבל את הסכמתם לשימוש בקובצי cookie או באחסון מקומי אחר, היכן שהדבר נדרש על פי חוק, ולהשתמש במידע אישי (כגון AdID) כדי להציג מודעות. המדיניות הזו משקפת את הדרישות שמפורטות בהנחיה בנושא פרטיות ותקשורת אלקטרונית ובתקנה הכללית להגנה על מידע (GDPR) של האיחוד האירופי.
כדי לעזור לבעלי תוכן דיגיטלי למלא את חובותיהם במסגרת המדיניות הזו, Google מציעה למשתמשים את ה-User Messaging Platform (UMP). UMP SDK עודכן כדי לתמוך בתקנים האחרונים של IAB. עכשיו אפשר לנהל בנוחות את כל ההגדרות האלה AdMob בפרטיות ובהעברת הודעות.
דרישות מוקדמות
- ממלאים את המדריך לתחילת העבודה.
- מגדירים את ההודעות בכרטיסייה פרטיות והודעות בחשבוןAdMob . לפרטים נוספים, אפשר לקרוא את המאמר מידע על 'פרטיות והודעות',
- אם עובדים על דרישות שקשורות ל-GDPR, אפשר לקרוא את המאמר איך דרישות IAB משפיעות על הודעות בנושא הסכמה באיחוד האירופי.
סוגים של הודעות משתמש
רשימה של כל סוגי ההודעות הנתמכות סוגי הודעות למשתמשים תוכלו למצוא הוראות ספציפיות להטמעה של כל אחד מסוגי ההודעות בסרגל הניווט הימני.
ייבוא ה-SDK
CocoaPods (מועדף)
ה-UMP SDK נכלל בתור תלות ב-Google Mobile Ads SDK Pod שמתחיל ב-Google Mobile Ads SDK 7.64.0.
הדרך הקלה ביותר לייבא את ה-SDK לפרויקט iOS היא באמצעות CocoaPods. פותחים את ה-Podfile של הפרויקט ומוסיפים את השורה הזו ליעד של האפליקציה:
pod 'Google-Mobile-Ads-SDK'
לאחר מכן, מריצים את הפקודה הבאה:
pod install --repo-update
אם אתם משתמשים חדשים ב-CocoaPods, קראו את המאמר איך משתמשים ב-CocoaPods כדי להבין איך ליצור Podfiles ולהשתמש בו.
הורדה ידנית
הדרך השנייה לייבא את ה-SDK היא לעשות זאת באופן ידני.
לאחר מכן גוררים את המסגרת לפרויקט Xcode, ומקפידים לבחור באפשרות העתקת פריטים במקרה הצורך.
לאחר מכן, תוכלו לכלול את המסגרת בכל קובץ שתרצו באמצעות:
Swift
import UserMessagingPlatform
Objective-C
#include <UserMessagingPlatform/UserMessagingPlatform.h>
עדכון Info.plist
איתור מזהה האפליקציה ומוסיפים את הפריט לInfo.plist
:
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy</string>
איך קובעים אם צריך להציג הודעה?
יש לבקש עדכון של פרטי ההסכמה למשתמש בכל השקה של אפליקציה, באמצעות requestConsentInfoUpdateWithParameters:completionHandler:
לפני טעינת הטופס.
הפרטים האלה יכולים לקבוע אם המשתמש צריך להביע את הסכמתו אם הוא לא עשה זאת כבר או אם תוקף ההסכמה שלו פג.
הנה דוגמה לבדיקת הסטטוס בהפעלה של האפליקציה:
Swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Create a UMPRequestParameters object. let parameters = UMPRequestParameters() // Set tag for under age of consent. Here false means users are not under age. parameters.tagForUnderAgeOfConsent = false // Request an update to the consent information. UMPConsentInformation.sharedInstance.requestConsentInfoUpdate( with: parameters, completionHandler: { error in if error != nil { // Handle the error. } else { // The consent information state was updated. // You are now ready to check if a form is // available. } }) }
Objective-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Create a UMPRequestParameters object. UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init]; // Set tag for under age of consent. Here NO means users are not under age. parameters.tagForUnderAgeOfConsent = NO; // Request an update to the consent information. [UMPConsentInformation.sharedInstance requestConsentInfoUpdateWithParameters:parameters completionHandler:^(NSError *_Nullable error) { if (error) { // Handle the error. } else { // The consent information state was updated. // You are now ready to check if a form is // available. } }]; }
טעינת טופס, אם הוא זמין
לפני הצגת טופס, עליך לבדוק אם יש טופס זמין. טפסים לא זמינים יכולים להיות שהמשתמש הפעיל מעקב מוגבל אחר מודעות, או אם תייגתם אותם כמתחת לגיל ההסכמה.
כדי לבדוק את הזמינות של טופס, השתמשוthe formStatus
property on the UMPConsentInformation
instance בגרסאות הקודמות.
לאחר מכן מוסיפים שיטת wrapper לטעינת הטופס:
Swift
// Request an update to the consent information. UMPConsentInformation.sharedInstance.requestConsentInfoUpdate( withParameters: parameters, completionHandler: { [self] error in // The consent information has updated. if error != nil { // Handle the error. } else { // The consent information state was updated. // You are now ready to see if a form is available. let formStatus = UMPConsentInformation.sharedInstance.formStatus if formStatus == UMPFormStatus.available { loadForm() } } }) ... func loadForm() { }
Objective-C
// Request an update to the consent information. [UMPConsentInformation.sharedInstance requestConsentInfoUpdateWithParameters:parameters completionHandler:^(NSError* _Nullable error) { // The consent information has updated. if (error) { // Handle the error. } else { // The consent information state was updated. // You are now ready to see if a form is available. UMPFormStatus formStatus = UMPConsentInformation.sharedInstance .formStatus; if (formStatus == UMPFormStatusAvailable) { [self loadForm]; } } }]; ... - (void) loadForm { }
כדי לטעון את הטופס, יש להשתמש בפונקציה the static loadWithCompletionHandler:
method on the UMPConsentForm
class.
Swift
func loadForm() { // Loads a consent form. Must be called on the main thread. UMPConsentForm.load( withCompletionHandler: { form, loadError in if loadError != nil { // Handle the error } else { // Present the form } }) }
Objective-C
- (void)loadForm { [UMPConsentForm loadWithCompletionHandler:^(UMPConsentForm *form, NSError *loadError) { if (loadError) { // Handle the error } else { // Present the form } }]; }
להציג את הטופס במידת הצורך
אחרי שהגדרתם את הזמינות ונטענו את הטופס, השתמשו בשיטהpresentFromViewController:completionHandler:
בUMPConsentForm
כדי להציג את הטופס.
משתמשים בUMPConsentInformation
אובייקט הקודם כדי לבדוק את השיטהconsent status ומעדכנים את השיטה:loadForm
Swift
func loadForm() { UMPConsentForm.load(withCompletionHandler: { form, loadError in if loadError != nil { // Handle the error. } else { // Present the form. You can also hold on to the reference to present // later. if UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatus.required { form?.present( from: self, completionHandler: { dismissError in if UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatus.obtained { // App can start requesting ads. } // Handle dismissal by reloading form. loadForm(); }) } else { // Keep the form available for changes to user consent. } } }) }
Objective-C
- (void)loadForm { [UMPConsentForm loadWithCompletionHandler:^(UMPConsentForm *form, NSError *loadError) { if (loadError) { // Handle the error. } else { // Present the form. You can also hold on to the reference to present // later. if (UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatusRequired) { [form presentFromViewController:self completionHandler:^(NSError *_Nullable dismissError) { if (UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatusObtained) { // App can start requesting ads. } // Handle dismissal by reloading form. [self loadForm]; }]; } else { // Keep the form available for changes to user consent. } } }]; }
אם אתם צריכים לבצע פעולה כלשהי אחרי שהמשתמש כבר בחר או סגר את הטופס, תוכלו ליישם את הלוגיקה הזו ב-handler להשלמה או ב-callback של הטופס.
בדיקה
אילוץ מיקום גיאוגרפי
ה-UMP SDK מספק דרך לבדיקת ההתנהגות של האפליקציה כאילו שהמכשיר נמצא באזור הכלכלי האירופי או בבריטניה באמצעות the debugGeography
property of type UMPDebugGeography
on UMPDebugSettings
.
עליכם לספק את המזהה המגובב של מכשיר הבדיקה בהגדרות של ניפוי הבאגים של האפליקציה כדי להשתמש בפונקציונליות של ניפוי הבאגים. אם תתקשרו אלrequestConsentInfoUpdateWithParameters:completionHandler:
בלי להגדיר את הערך הזה, כשתפעילו את האפליקציה היא מתעדת את הגיבוב (hash) הנדרש.
Swift
let parameters = UMPRequestParameters() let debugSettings = UMPDebugSettings() debugSettings.testDeviceIdentifiers = ["TEST-DEVICE-HASHED-ID"] debugSettings.geography = UMPDebugGeography.EEA parameters.debugSettings = debugSettings UMPConsentInformation.sharedInstance.requestConsentInfoUpdate( with: parameters, completionHandler: { error in ... })
Objective-C
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init]; UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init]; debugSettings.testDeviceIdentifiers = @[ @"TEST-DEVICE-HASHED-ID" ]; debugSettings.geography = UMPDebugGeographyEEA; parameters.debugSettings = debugSettings; [UMPConsentInformation.sharedInstance requestConsentInfoUpdateWithParameters:parameters completionHandler:^(NSError *_Nullable error){ ... }];
באמצעות UMPDebugGeography
, יש לכם אפשרות לאלץ את האזור הגיאוגרפי לאחת מהאפשרויות הבאות:
ניפוי באגים | תיאור |
---|---|
UMPDebugGeographyDisabled |
מיקום גיאוגרפי של ניפוי באגים הושבת. |
UMPDebugGeographyEEA |
המיקום הגיאוגרפי מופיע כמו באזור הכלכלי האירופי (EEA) במכשירי ניפוי באגים. |
UMPDebugGeographyNotEEA |
המיקום הגיאוגרפי של מכשירים ניפוי באגים מופיע בתור EEA. |
לתשומת ליבכם: ההגדרות של ניפוי הבאגים פועלות רק במכשירי בדיקה. אין צורך להוסיף אמולטורים לרשימת מזהי המכשירים, כי הם כבר כוללים בדיקות כברירת מחדל.
איפוס מצב ההסכמה
כשבודקים את האפליקציה באמצעות UMP SDK, כדאי לאפס את המצב של ה-SDK כדי לדמות את חוויית ההתקנה הראשונה של משתמש.
ערכת ה-SDK מספקת את השיטה reset
כדי לעשות זאת.
Swift
UMPConsentInformation.sharedInstance.reset()
Objective-C
[UMPConsentInformation.sharedInstance reset];
עליכם להתקשר גם אל reset
אם תחליטו להסיר את ה-UMP SDK מהפרויקט.