SDK راه حل های مدیریت رضایت Google، SDK راه حل های مدیریت رضایت Google

راهنمای توسعه دهندگان Google را برای SDK ها بررسی کنید:


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

هنگامی که SDK مربوطه را پیاده‌سازی کردید، حالت رضایت Google را در حریم خصوصی و پیام‌رسانی فعال کردید و تشخیص دادید که حالت رضایت اولیه را اجرا می‌کنید، این دستورالعمل‌ها را دنبال کنید.

برای پیاده سازی حالت اولیه:

  1. به طور موقت مجموعه Analytics ( اندروید ، iOS ) را غیرفعال کنید.
  2. وقتی آماده رفع انسداد عملکرد Google Analytics هستید، مجموعه Analytics ( اندروید ، iOS ) را دوباره فعال کنید.

برای مرحله 2، با یک متخصص حقوقی مشورت کنید تا معیارهای خود را برای فعال کردن مجدد عملکرد Analytics تعیین کنید.

برای مثال، می‌توانید پس از انتخاب رضایت کاربر، با فعال کردن مجدد عملکرد Google Analytics در پاسخ به تماس loadAndShowConsentFormIfRequired (مرجع API: Android ، iOS )، عملکرد Google Analytics را دوباره فعال کنید.

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

  • رقم اول مقدار هدف ad_storage را نشان می دهد
  • رقم دوم مقدار هدف ad_user_data را نشان می دهد
  • رقم سوم مقدار هدف ad_personalization را نشان می دهد
  • رقم چهارم مقدار هدف analytics_storage را نشان می دهد

جدول زیر مقادیر ممکن برای هر رقم را توضیح می دهد:

ارزش معنی
0 هنوز هیچ ارزشی در دسترس نیست.
1 کاربر این هدف را GRANTED .
2 کاربر این هدف DENIED .
3 حالت رضایت برای این کاربر اعمال نمی شود.
4 حالت رضایت برای این منظور پیکربندی نشده است.

مثال زیر UMP_consentModeValues ​​را تجزیه می کند، Google Analytics را در صورتی که همه اهداف GRANTED باشند یا اعمال نمی شوند، فعال می کند، و در غیر این صورت مجموعه Analytics را غیرفعال می کند:

جاوا

// Helper function that sets Analytics collection based on the value of the
// UMP_consentModeValues local storage key.
private void maybeReEnableAnalyticsCollection() {
  String consentModeValues = sharedPreferences.getString("UMP_consentModeValues", null);
  if (shouldReEnableAnalyticsCollection(consentModeValues)) {
    firebaseAnalytics.setAnalyticsCollectionEnabled(true);
  } else {
    firebaseAnalytics.setAnalyticsCollectionEnabled(false);
  }
}

// Helper function to determine whether Analytics collection should be enabled. Returns true
// if all consent mode values are either granted, not applicable, or not configured.
private boolean shouldReEnableAnalyticsCollection(String consentModeValues) {
  if (consentModeValues.isEmpty()) {
    return false;
  }
  for (int i = 0; i < consentModeValues.length(); i++) {
    char consentModeValue = consentModeValues.charAt(i);
    switch (consentModeValue) {
      case '0':
        // Consent mode data not ready yet.
        return false;
      case 1:
        // Consent mode is granted for this purpose.
        break;
      case '2':
        // Consent is denied for this consent mode purpose.
        return false;
      case '3':
        // Consent does not apply for this purpose at this time.
        break;
      case '4':
        // Consent mode is not configured for this purpose.
        break;
      default:
    // Unexpected value encountered.
        return false;
    }
  }
  // If all checks pass, re-enable Analytics collection.
  return true;
}

کاتلین

// Helper function that may re-enable Analytics collection based on the value of the
// UMP_consentModeValues local storage key.
private fun maybeReEnableAnalyticsCollection() {
    val consentModeValues = sharedPreferences.getString("UMP_consentModeValues", null)
    if (shouldReEnableAnalyticsCollection(consentModeValues)) {
        firebaseAnalytics.setAnalyticsCollectionEnabled(true)
    }
}

// Helper function to determine whether Analytics collection should be re-enabled. Returns true
// if all consent mode values are either granted, not applicable, or not configured.
private fun shouldReEnableAnalyticsCollection(consentModeValues: String?): Boolean {
    if (consentModeValues.isNullOrEmpty()) {
        return false
    }
    for (consentModeValue in consentModeValues) {
        when (consentModeValue) {
            '0' -> {
                // Consent mode data not ready yet.
                return false
            }
            '1' -> {
                // Consent mode is granted for this purpose.
            }
            '2' -> {
                // Consent is denied for this consent mode purpose.
                return false
            }
            '3' -> {
                // Consent does not apply for this purpose at this time.
            }
            '4' -> {
                // Consent mode is not configured for this purpose.
            }
            else -> {
                // Unexpected value encountered.
                return false
            }
        }
    }
    // If all checks pass, can re-enable Analytics collection.
    return true
}

سویفت

// Helper function that may re-enable Analytics collection based on the value of the
// UMP_consentModeValues local storage key.
private func maybeReEnableAnalyticsCollection() {
  let consentModeValues = userDefaults.string(forKey: "UMP_consentModeValues")
  if shouldReEnableAnalyticsCollection(consentModeValues) {
      Analytics.setAnalyticsCollectionEnabled(true)
  }
}

// Helper function to determine whether Analytics collection should be re-enabled. Returns true
// if all consent mode values are either granted, not applicable, or not configured.   
private func shouldReEnableAnalyticsCollection(_ consentModeValues: String?) -> Bool {
  guard let consentModeValues = consentModeValues, !consentModeValues.isEmpty else {
    return false
}

for consentModeValue in consentModeValues {
  switch consentModeValue {
    case "0":
      // Consent mode data not ready yet.
      return false
    case "1":
      // Consent mode is granted for this purpose.
      break
    case "2":
      // Consent is denied for this consent mode purpose.
      return false
    case "3":
      // Consent does not apply for this purpose at this time.
      break
    case "4":
      // Consent mode is not configured for this purpose.
      break
    default:
      // Unexpected value encountered.
      return false
    }
  }
  // If all checks pass, can re-enable Analytics collection.
  return true
}

هدف-C

// Helper function that may re-enable Analytics collection based on the value of the
// UMP_consentModeValues local storage key.
- (void)maybeReEnableAnalyticsCollection {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *consentModeValues = [defaults stringForKey:@"UMP_consentModeValues"];
    if ([self shouldReEnableAnalyticsCollection:consentModeValues]) {
        [FIRAnalytics setAnalyticsCollectionEnabled:YES];
    }
  }

// Helper function to determine whether Analytics collection should be re-enabled. Returns true
// if all consent mode values are either granted, not applicable, or not configured.
- (BOOL)shouldReEnableAnalyticsCollection:(NSString *)consentModeValues {
    if (!consentModeValues || [consentModeValues length] == 0) {
        return NO;
    }

    for (NSUInteger i = 0; i < [consentModeValues length]; i++) {
      unichar consentModeValue = [consentModeValues characterAtIndex:i];
      switch (consentModeValue) {
          case '0':
              // Consent mode data not ready yet.
              return NO;
          case '1':
              // Consent mode is granted for this purpose.
                break;
          case '2':
              // Consent is denied for this consent mode purpose.
              return NO;
          case '3':
              // Consent does not apply for this purpose at this time.
              break;
          case '4':
              // Consent mode is not configured for this purpose.
              break;
          default:
              // Unexpected value encountered.
              return NO;
          }
      }
      // If all checks pass, can re-enable Analytics collection.
      return YES;
  }

زمانی که maybeReEnableAnalyticsCollection تماس بگیرید:

  • اطلاعات رضایت به روز می شود
  • رضایت جمع آوری شده است.