搜尋套件、儲存庫與 APP 分類

套件詳情v3.0.0

admob_flutter

使用原生平台視圖顯示橫幅廣告的 Admob 插件。

AndroidiOS
近 30 天下載
741
喜歡數
470
Pub 分數
125

安裝套件

flutter pub add admob_flutter

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

admob_flutter 是一個 Flutter 插件,可使用原生平台視圖將 Google AdMob 橫幅廣告整合到移動應用程式中。它提供了一種簡單的方法,可在 Android 和 iOS 平台上顯示可賺取收益的橫幅廣告。該插件利用原生 AdMob SDK 以實現最佳效能和相容性,確保在 Flutter 應用中順暢呈現廣告。該插件專為希望以最少設定透過應用內廣告創收的開發者設計。該套件支援動態廣告載入與響應式橫幅尺寸,提升跨裝置的使用者體驗。

適用情境

  • 透過橫幅廣告 monetizing 移動應用
  • 將 Google AdMob 集成到 Flutter 專案中
  • 在 Android 和 iOS 上顯示響應式橫幅廣告
  • 無需原生程式碼即可新增應用內廣告
  • 啟用即時廣告更新和刷新

主要特色

  • 原生平台視圖整合
  • 對 Android 和 iOS 的支援
  • 響應式橫幅尺寸
  • 與 Firebase 的輕鬆整合
  • 即時廣告加載和重新整理
  • 最小的樣板程式碼

適合對象

  • 尋求廣告變現的Flutter開發者
  • 面向 Android 和 iOS 使用者的應用程式
  • 使用 Firebase 進行分析的專案
  • 希望簡單整合 AdMob 的開發者
  • 旨在透過橫幅廣告實現收入的移動應用

使用建議

  • 需要設定 Google AdMob 帳戶
  • 依賴原生 SDK 才能實現完整功能
  • 廣告內容受 Google 政策約束
  • 如果過度使用,可能會影響應用效能
  • 頻繁顯示廣告可能會影響使用者體驗

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Looking for Maintainers.

Unfortunately I haven't been able to keep up with demand for features and improvments. If you are interested in helping maintain this repo please create an issue requesting maintainer status. Or consider using the new google_mobile_ads by Google.

admob_flutter

Build Status version version GitHub stars GitHub forks GitHub issues

Demo

A Flutter plugin that uses native platform views to show Admob banner ads!

This plugin also has support for Interstitial and Reward ads.

Installation

  • Add this to your package's pubspec.yaml file:
dependencies:
  admob_flutter: "<LATEST_VERSION>"

  • Install it - You can install packages from the command line:
flutter pub get

Android Specific Setup

Update your AndroidManifest.xml

Add your AdMob App ID to your app's AndroidManifest.xml file by adding the <meta-data> tag shown below. You can find your App ID in the AdMob UI. For android:value insert your own AdMob App ID in quotes, as shown below.

You can use these test App ID's from Admob for development:

Android: ca-app-pub-3940256099942544~3347511713
iOS: ca-app-pub-3940256099942544~1458002511
<manifest>
  <application>
    <meta-data
      android:name="com.google.android.gms.ads.APPLICATION_ID"
      android:value="ca-app-pub-3940256099942544~3347511713"/>
  </application>
</manifest>

iOS Specific Setup

Update your Info.plist per Firebase instructions.

<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>

and add

<key>io.flutter.embedded_views_preview</key>
<true/>

Starting from Beta 6, you also need to display the App Tracking Transparency authorization request for accessing the IDFA, so you have to update your Info.plist to add the NSUserTrackingUsageDescription key with a custom message describing your usage. Below is an example description text:

<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>

See Prepare for iOS 14+ for more information. You also need to update your ios/Podfile by adding platform :ios, '9.0' at the very top of your file.

Initialize the plugin

First thing to do before attempting to show any ads is to initialize the plugin. You can do this in the earliest starting point of your app, your main function:

import 'package:admob_flutter/admob_flutter.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  // Initialize without device test ids.
  Admob.initialize();
  // Or add a list of test ids.
  // Admob.initialize(testDeviceIds: ['YOUR DEVICE ID']);
}

If you're using iOS, you may also need to request the tracking authorization in order to display personalized ads:

// Run this before displaying any ad.
await Admob.requestTrackingAuthorization();
Supported Platforms
  • 0.3.0 >= iOS
  • 0.2.0 >= AndroidX
Supported Admob features
  • Banner Ads
  • Interstitial Ads
  • Reward Ads
  • Native Ads (Coming soon)
Check out the repository Wiki for more info!

FAQ

  • Why doesn't the Admob Banner class have a dispose method?
    • TL;DR - It's called automatically for you. Longer reason see 94
  • failed to load ad : 3
    • TL;DR - Things are working correctly, Admob didn't give you an ad. If the app id + ad unit is new, give it 24/48 hours. See:161 stackoverflow
    • See all Admob codes
  • Ads are not loading
    • TL;DR - Make sure you have the correct combination of id's per platform. See:161
  • Objective-C based project cannot build
    • TL;DR - You have to enable swift support for your flutter project. See: stackoverflow and 123
  • How do I manage consentement for users in the European Economic Area?
    • Pass nonPersonalizedAds: true to the classes constructor (AdmobBanner, AdmobInterstitial and AdmobReward) in order to not display personalized ads for users who don't give their consent. A way to ask users for their consent is to use the plugin admob_consent. Please note that the new recommended is to use the brand new UMP SDK (Android, iOS).

Recipes

Pull Requests

I welcome and encourage all pull requests. Here are some basic rules to follow to ensure timely addition of your request:

  1. Match the document style as closely as possible.
  2. Please keep PR titles easy to read and descriptive of changes, this will make them easier to review/merge.
  3. Pull requests must be made against master branch for this repository.
  4. Check for existing issues first, before filing an issue.
  5. Check the project board, before filing an issue.
  6. Read the FAQ, before filing an issue.
  7. Have fun!

所屬分類

原始碼儲存庫

使用此套件的專案