-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[google_adsense] Add optional init parameters. #8297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
3a8dca6
2aab6ad
7f3c70a
eeaca6d
bc47c6a
bb061e0
e511512
757f146
848bbf6
a11eeac
8913fe2
b09b784
af01f25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| /// Configuration for various settings for game ads. | ||
| /// | ||
| /// These are set as `data`-attributes in the AdSense script tag. | ||
| class AdSenseCodeParameters { | ||
| /// Builds an AdSense code parameters object. | ||
| /// | ||
| /// The following parameters are available: | ||
| /// | ||
| /// * [adHost]: If you share your revenue with a host platform, use this parameter | ||
| /// to specify the host platform. | ||
| /// * [admobInterstitialSlot]: If your game runs in a mobile app, use this parameter | ||
| /// to request interstitial ads. | ||
| /// * [admobRewardedSlot]: If your game runs in a mobile app, use this parameter | ||
| /// to request rewarded ads. | ||
| /// * [adChannel]: You may include a | ||
| /// [custom channel ID](https://support.google.com/adsense/answer/10078316) | ||
| /// for tracking the performance of your ads. | ||
| /// * [adbreakTest]: Set this parameter to `'on'` to enable testing mode. This | ||
| /// lets you test your placements using fake ads. | ||
| /// * [tagForChildDirectedTreatment]: Use this parameter if you want to tag your | ||
| /// ad requests for treatment as child directed. For more information, refer to: | ||
| /// [Tag a site or ad request for child-directed treatment](https://support.google.com/adsense/answer/3248194). | ||
| /// * [tagForUnderAgeOfConsent]: Use this parameter if you want to tag your | ||
| /// European Economic Area (EEA), Switzerland, and UK ad requests for restricted | ||
| /// data processing treatment. For more information, refer to: | ||
| /// [Tag an ad request for EEA and UK users under the age of consent (TFUA)](https://support.google.com/adsense/answer/9009582). | ||
| /// * [adFrequencyHint]: The minimum average time interval between ads expressed | ||
| /// in seconds. If this value is `'120s'` then ads will not be shown more | ||
| /// frequently than once every two minutes on average. Note that this is a hint | ||
| /// that could be ignored or overridden by a server control in future. | ||
| /// | ||
| /// For more information about these parameters, check | ||
| /// [AdSense code parameter descriptions](https://support.google.com/adsense/answer/9955214#adsense_code_parameter_descriptions). | ||
| AdSenseCodeParameters({ | ||
| String? adHost, | ||
| String? admobInterstitialSlot, | ||
| String? admobRewardedSlot, | ||
| String? adChannel, | ||
| String? adbreakTest, | ||
| String? tagForChildDirectedTreatment, | ||
| String? tagForUnderAgeOfConsent, | ||
| String? adFrequencyHint, | ||
| }) : _adSenseCodeParameters = <String, String>{ | ||
| if (adHost != null) 'adHost': adHost, | ||
| if (admobInterstitialSlot != null) | ||
| 'admobInterstitialSlot': admobInterstitialSlot, | ||
| if (admobRewardedSlot != null) 'admobRewardedSlot': admobRewardedSlot, | ||
| if (adChannel != null) 'adChannel': adChannel, | ||
| if (adbreakTest != null) 'adbreakTest': adbreakTest, | ||
| if (tagForChildDirectedTreatment != null) | ||
| 'tagForChildDirectedTreatment': tagForChildDirectedTreatment, | ||
| if (tagForUnderAgeOfConsent != null) | ||
| 'tagForUnderAgeOfConsent': tagForUnderAgeOfConsent, | ||
| if (adFrequencyHint != null) 'adFrequencyHint': adFrequencyHint, | ||
| }; | ||
|
|
||
| final Map<String, String> _adSenseCodeParameters; | ||
|
|
||
| /// `Map` representation of this configuration object. | ||
| Map<String, String> get toMap => _adSenseCodeParameters; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:async'; | ||
| import 'dart:js_interop'; | ||
|
|
||
| import 'package:flutter/widgets.dart' show visibleForTesting; | ||
|
|
@@ -119,7 +120,11 @@ extension type AdBreakPlacement._(JSObject _) implements JSObject { | |
| beforeReward: beforeReward != null | ||
| ? (JSFunction fn) { | ||
| beforeReward(() { | ||
| fn.callAsFunction(); | ||
| // Delay the call to `fn` so tap users don't trigger a click on | ||
| // the ad onTapUp. | ||
| Timer(const Duration(milliseconds: 100), () { | ||
| fn.callAsFunction(); | ||
| }); | ||
|
||
| }); | ||
| }.toJS | ||
| : null, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.