|
| 1 | +// Copyright 2013 The Flutter Authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style license that can be |
| 3 | +// found in the LICENSE file. |
| 4 | + |
| 5 | +/// Configuration for various settings for game ads. |
| 6 | +/// |
| 7 | +/// These are set as `data`-attributes in the AdSense script tag. |
| 8 | +class AdSenseCodeParameters { |
| 9 | + /// Builds an AdSense code parameters object. |
| 10 | + /// |
| 11 | + /// The following parameters are available: |
| 12 | + /// |
| 13 | + /// * [adHost]: If you share your revenue with a host platform, use this parameter |
| 14 | + /// to specify the host platform. |
| 15 | + /// * [admobInterstitialSlot]: If your game runs in a mobile app, use this parameter |
| 16 | + /// to request interstitial ads. |
| 17 | + /// * [admobRewardedSlot]: If your game runs in a mobile app, use this parameter |
| 18 | + /// to request rewarded ads. |
| 19 | + /// * [adChannel]: You may include a |
| 20 | + /// [custom channel ID](https://support.google.com/adsense/answer/10078316) |
| 21 | + /// for tracking the performance of your ads. |
| 22 | + /// * [adbreakTest]: Set this parameter to `'on'` to enable testing mode. This |
| 23 | + /// lets you test your placements using fake ads. |
| 24 | + /// * [tagForChildDirectedTreatment]: Use this parameter if you want to tag your |
| 25 | + /// ad requests for treatment as child directed. For more information, refer to: |
| 26 | + /// [Tag a site or ad request for child-directed treatment](https://support.google.com/adsense/answer/3248194). |
| 27 | + /// * [tagForUnderAgeOfConsent]: Use this parameter if you want to tag your |
| 28 | + /// European Economic Area (EEA), Switzerland, and UK ad requests for restricted |
| 29 | + /// data processing treatment. For more information, refer to: |
| 30 | + /// [Tag an ad request for EEA and UK users under the age of consent (TFUA)](https://support.google.com/adsense/answer/9009582). |
| 31 | + /// * [adFrequencyHint]: The minimum average time interval between ads expressed |
| 32 | + /// in seconds. If this value is `'120s'` then ads will not be shown more |
| 33 | + /// frequently than once every two minutes on average. Note that this is a hint |
| 34 | + /// that could be ignored or overridden by a server control in future. |
| 35 | + /// |
| 36 | + /// For more information about these parameters, check |
| 37 | + /// [AdSense code parameter descriptions](https://support.google.com/adsense/answer/9955214#adsense_code_parameter_descriptions). |
| 38 | + AdSenseCodeParameters({ |
| 39 | + String? adHost, |
| 40 | + String? admobInterstitialSlot, |
| 41 | + String? admobRewardedSlot, |
| 42 | + String? adChannel, |
| 43 | + String? adbreakTest, |
| 44 | + String? tagForChildDirectedTreatment, |
| 45 | + String? tagForUnderAgeOfConsent, |
| 46 | + String? adFrequencyHint, |
| 47 | + }) : _adSenseCodeParameters = <String, String>{ |
| 48 | + if (adHost != null) 'adHost': adHost, |
| 49 | + if (admobInterstitialSlot != null) |
| 50 | + 'admobInterstitialSlot': admobInterstitialSlot, |
| 51 | + if (admobRewardedSlot != null) 'admobRewardedSlot': admobRewardedSlot, |
| 52 | + if (adChannel != null) 'adChannel': adChannel, |
| 53 | + if (adbreakTest != null) 'adbreakTest': adbreakTest, |
| 54 | + if (tagForChildDirectedTreatment != null) |
| 55 | + 'tagForChildDirectedTreatment': tagForChildDirectedTreatment, |
| 56 | + if (tagForUnderAgeOfConsent != null) |
| 57 | + 'tagForUnderAgeOfConsent': tagForUnderAgeOfConsent, |
| 58 | + if (adFrequencyHint != null) 'adFrequencyHint': adFrequencyHint, |
| 59 | + }; |
| 60 | + |
| 61 | + final Map<String, String> _adSenseCodeParameters; |
| 62 | + |
| 63 | + /// `Map` representation of this configuration object. |
| 64 | + Map<String, String> get toMap => _adSenseCodeParameters; |
| 65 | +} |
0 commit comments