website/docs/controls/ads/index.md
import TabItem from '@theme/TabItem'; import Tabs from '@theme/Tabs'; import {CodeExample, Image} from '@site/src/components/crocodocs';
Displaying Google Ads in Flet apps.
It is powered by the google_mobile_ads Flutter package.
| Platform | Windows | macOS | Linux | iOS | Android | Web |
|---|---|---|---|---|---|---|
| Supported | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
To use ads controls add flet-ads package to your project dependencies:
requirements.txt or pyproject.toml.
</TabItem>
The below sections show the required configurations for each platform.
A valid AdMob app ID is required to be specified, otherwise the app might crash on launch or behave unexpectedly.
<Tabs groupId="flet-build--pyproject-toml"> <TabItem value="flet-build" label="flet build"> ```bash flet build apk \ --android-meta-data com.google.android.gms.ads.APPLICATION_ID="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" ``` </TabItem> <TabItem value="pyproject-toml" label="pyproject.toml"> ```toml [tool.flet.android.meta_data] "com.google.android.gms.ads.APPLICATION_ID" = "ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" ``` </TabItem> </Tabs> See also:A valid AdMob app ID is required to be specified, otherwise the app might crash on launch or behave unexpectedly.
<Tabs groupId="flet-build--pyproject-toml"> <TabItem value="flet-build" label="flet build"> ```bash flet build ipa \ --info-plist GADApplicationIdentifier="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" ``` </TabItem> <TabItem value="pyproject-toml" label="pyproject.toml"> ```toml [tool.flet.ios.info] GADApplicationIdentifier = "ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" ``` </TabItem> </Tabs> See also:AdMob provides app and ad unit IDs for testing purposes.
"ca-app-pub-3940256099942544~3347511713"BannerAd.unit_id
"ca-app-pub-3940256099942544/9214589741""ca-app-pub-3940256099942544/2435281174"InterstitialAd.unit_id
"ca-app-pub-3940256099942544/1033173712""ca-app-pub-3940256099942544/4411468910"They are not meant to be used in production.
<CodeExample path={frontMatter.examples + '/example_1/main.py'} language="python" />
<Image src={frontMatter.example_images + '/example_1.gif'} width="55%" />