You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[google_adsense] Tighten exports and docs. (#8233)
* **Breaking changes**: Reshuffles API exports:
* Removes the `adUnit` method, and instead exports the `AdUnitWidget` directly.
* Renames `experimental/google_adsense` to `experimental/ad_unit_widget.dart`.
* Removes the `AdStatus` and `AdUnitParams` exports.
* Removes the "stub" files, so this package is now web-only and must be used
through a conditional import.
* Tweaks several documentation pages to remove references to internal APIs.
* Splits tests to reflect the new code structure.
## Issue
* Continuation of: #6871
* Part of: flutter/flutter#40376
Copy file name to clipboardExpand all lines: packages/google_adsense/README.md
+63-33Lines changed: 63 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -10,30 +10,42 @@ Please express interest joining Early Access program using [this form](https://d
10
10
## Usage
11
11
12
12
### Setup your AdSense account
13
-
1.[Make sure your site's pages are ready for AdSense](https://support.google.com/adsense/answer/7299563?hl=en&sjid=5790642343077592212-EU&visit_id=638657100661171978-1373860041&ref_topic=1319756&rd=1)
14
-
2.[Create your AdSense account](https://support.google.com/adsense/answer/10162?hl=en&sjid=5790642343077592212-EU&visit_id=638657100661171978-1373860041&ref_topic=1250103&rd=1)
13
+
1.[Make sure your site's pages are ready for AdSense](https://support.google.com/adsense/answer/7299563)
14
+
2.[Create your AdSense account](https://support.google.com/adsense/answer/10162)
15
15
16
16
### Initialize AdSense
17
-
To start displaying ads, initialize the AdSense with your [client/publisher ID](https://support.google.com/adsense/answer/105516?hl=en&sjid=5790642343077592212-EU) (only use numbers).
17
+
To start displaying ads, initialize AdSense with your [Publisher ID](https://support.google.com/adsense/answer/105516) (only use numbers).
'0123456789012345'); // TODO: Replace with your Publisher ID (pub-0123456789012345) - https://support.google.com/adsense/answer/105516?hl=en&sjid=5790642343077592212-EU
25
29
runApp(const MyApp());
26
30
}
27
-
28
31
```
29
32
30
-
### Enable Auto Ads
31
-
In order to start displaying [Auto ads](https://support.google.com/adsense/answer/9261805?hl=en) make sure to configure this feature in your AdSense Console. If you want to display ad units within your app content, continue to the next step
33
+
### Displaying Auto Ads
34
+
In order to start displaying [Auto ads](https://support.google.com/adsense/answer/9261805):
35
+
36
+
1. Configure this feature in your AdSense Console.
32
37
33
-
### Display ad unit Widget
38
+
Auto ads should start showing just with the call to `initialize`, when available.
34
39
35
-
1. Create [ad units](https://support.google.com/adsense/answer/9183549?hl=en&ref_topic=9183242&sjid=5790642343077592212-EU) in your AdSense account
36
-
2. Use relevant `AdUnitConfiguration` constructor as per table below
40
+
If you want to display ad units within your app content, continue to the next step
41
+
42
+
### Display ad units (`AdUnitWidget`)
43
+
44
+
To display an Ad unit in your Flutter application:
45
+
46
+
1. Create [ad units](https://support.google.com/adsense/answer/9183549) in your AdSense account.
47
+
This will provide an HTML snippet, which you need to translate to Dart.
48
+
2. Pick the `AdUnitConfiguration` for your ad type:
37
49
38
50
| Ad Unit Type |`AdUnitConfiguration` constructor method |
'0123456789012345'); // TODO: Replace with your Publisher ID (pub-0123456789012345) - https://support.google.com/adsense/answer/105516?hl=en&sjid=5790642343077592212-EU
83
+
// Call `initialize` with your Publisher ID (pub-0123456789012345)
adSlot: '1234567890', // TODO: Replace with your Ad Unit ID
73
-
adFormat: AdFormat
74
-
.AUTO, // Remove AdFormat to make ads limited by height
75
-
))
93
+
AdUnitWidget(
94
+
configuration: AdUnitConfiguration.displayAdUnit(
95
+
// TODO: Replace with your Ad Unit ID
96
+
adSlot: '1234567890',
97
+
// Remove AdFormat to make ads limited by height
98
+
adFormat: AdFormat.AUTO,
99
+
),
100
+
),
76
101
```
77
102
78
-
#### Customize ad unit Widget
103
+
#### `AdUnitWidget` customizations
104
+
79
105
To [modify your responsive ad code](https://support.google.com/adsense/answer/9183363?hl=en&ref_topic=9183242&sjid=11551379421978541034-EU):
80
106
1. Make sure to follow [AdSense policies](https://support.google.com/adsense/answer/1346295?hl=en&sjid=18331098933308334645-EU&visit_id=638689380593964621-4184295127&ref_topic=1271508&rd=1)
81
107
2. Use Flutter instruments for [adaptive and responsive design](https://docs.flutter.dev/ui/adaptive-responsive)
// 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
+
// TO run the test:
6
+
// 1. Run chrome driver with --port=4444
7
+
// 2. Run the test from example folder with: flutter drive -d web-server --web-port 7357 --browser-name chrome --driver test_driver/integration_test.dart --target integration_test/ad_widget_test.dart
0 commit comments