パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.11.1

flutter_google_ad_manager

Google Ad Manager(DoubleClick for Publishers)用のFlutterプラグイン。

30日間ダウンロード
60
いいね数
20
Pub ポイント
40

パッケージをインストール

flutter pub add flutter_google_ad_manager

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Flutterプラグインで、Google Ad Manager(旧称:DoubleClick for Publishers)との統合を可能にし、開発者がFlutterアプリ内に広告を表示できるようにします。ネイティブ広告SDKへのブリッジを提供し、バナー広告、インテルスティシャル広告、報酬付き動画広告をサポートしています。シンプルなAPIにより広告の実装を容易にしつつ、複数プラットフォームでの互換性も維持しています。Googleエコシステムを通じたプログラム型広告による収益化を目指すアプリ向けに設計されています。

用途

  • ディスプレイ広告によるモバイルアプリの収益化
  • ユーザー参加度向上のための報酬付き動画広告の実装
  • アプリのレイアウトにバナー広告を表示する
  • アプリの画面の間にインテリスティシャル広告を統合する
  • Google Ad Manager を使用したターゲット広告の配信
  • プログラムド・バイディングを通じた広告収益の有効化

主な機能

  • バナー、インテーショナル、報酬付き動画広告をサポート
  • Google Ad Manager との簡単な統合
  • クロスプラットフォーム広告配信
  • リアルタイム広告の取得とレンダリング
  • パフォーマンスのトラッキング用の広告イベントコールバック
  • Google AdMob ポリシーに準拠

適している対象

  • 広告ベースの収益化を求めるアプリ
  • 広告在庫に Google Ad Manager を使用する開発者
  • グローバルなオーディエンスをターゲットにするFlutterアプリ
  • 複数の広告ネットワークを管理するパブリッシャー
  • 高い広告埋め込み率を必要とするアプリ
  • 信頼性のある広告パフォーマンス追跡が必要なプロジェクト

注意事項

  • Google Ad Manager アカウントの設定が必要です
  • パブリッシャーダッシュボードからの適切な広告ユニットIDが必要です
  • GDPRなどのプライバシー規制に準拠する必要がある場合があります
  • パフォーマンスはネットワーク接続に依存します
  • 広告コンテンツはGoogleの広告ポリシーに従わなければなりません
  • iOSおよびAndroidマニフェストファイルの追加構成が必要です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

flutter_google_ad_manager

Flutter plugin for Google Ad Manager(DoubleClick for Publishers).

Getting Started

ios

Add io.flutter.embedded_views_preview in info.plist

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

Follow any additional instructions found here

Google Ad Manager Getting Started Guide

Android

Add com.google.android.gms.ads.AD_MANAGER_APP in AndroidManifest.xml

<manifest>
    <application>
        <meta-data
            android:name="com.google.android.gms.ads.AD_MANAGER_APP"
            android:value="true"/>
    </application>
</manifest>

Follow any additional instructions found here

Google Ad Manager Getting Started Guide

Banner Ads

Just write the DFPBanner widget in your favorite place.

DFPBanner(
  isDevelop: true,
  testDevices: MyTestDevices(),
  adUnitId: '/XXXXXXXXX/XXXXXXXXX',
  adSize: DFPAdSize.BANNER,
  onAdLoaded: () {
    print('Banner onAdLoaded');
  },
  onAdFailedToLoad: (errorCode) {
    print('Banner onAdFailedToLoad: errorCode:$errorCode');
  },
  onAdOpened: () {
    print('Banner onAdOpened');
  },
  onAdClosed: () {
    print('Banner onAdClosed');
  },
  onAdLeftApplication: () {
    print('Banner onAdLeftApplication');
  },
),

Manual Ad Refresh

You can manually refresh the banner ads on user interaction, use the onAdViewCreated callback to save an instance of the DFPBannerViewController and then call the reload() method to refresh the ad.

DFPBannerViewController _bannerViewController;

_reload() {
  _bannerViewController?.reload();
}

DFPBanner(
  isDevelop: true,
  testDevices: MyTestDevices(),
  adUnitId: '/XXXXXXXXX/XXXXXXXXX',
  adSize: DFPAdSize.BANNER,
  onAdViewCreated: (controller) {
    _bannerViewController = controller;
  },
  onAdLoaded: () {
    print('Banner onAdLoaded');
  },
  onAdFailedToLoad: (errorCode) {
    print('Banner onAdFailedToLoad: errorCode:$errorCode');
  },
  onAdOpened: () {
    print('Banner onAdOpened');
  },
  onAdClosed: () {
    print('Banner onAdClosed');
  },
  onAdLeftApplication: () {
    print('Banner onAdLeftApplication');
  },
),

About testDevices

If you set isDevelop to true, the test adUnitId will be used.
( If set false, the described adUnitId is used.)
Google Ad Manger needs to register testDevices in case of actual devices.

With this plug-in, you can create the following class and set it to testDevices of DFPBanner.

class MyTestDevices extends TestDevices {
  static MyTestDevices _instance;

  factory MyTestDevices() {
    if (_instance == null) _instance = new MyTestDevices._internal();
    return _instance;
  }

  MyTestDevices._internal();

  @override
  List<String> get values => List()..add("XXXXXXXX"); // Set here.
}
DFPBanner(
  testDevices: MyTestDevices(),
)

About adSize

DFPAdSize is available. This is the same size as that of android.

  • BANNER
  • FULL_BANNER
  • LARGE_BANNER
  • LEADERBOARD
  • MEDIUM_RECTANGLE
  • SMART_BANNER (Only Portrait)

Other custom is also available.

const DFPAdSize.custom({double width, double height}).

Note: In case of Android, DFPAdSize.custom() will be toInt () instead of double because AdSize class constructor of Google Ad Manager SDK is only int.

About EventListener

The following event listeners are available:

  • onAdLoaded
  • onAdFailedToLoad
  • onAdOpened
  • onAdClosed
  • onAdLeftApplication

Interstitial Ads

Firstly load it and call the show method at the desired timing.

DFPInterstitialAd _interstitialAd;

@override
void initState() {
  super.initState();

  _interstitialAd = DFPInterstitialAd(
    isDevelop: true,
    adUnitId: "XXXXXXXX",
    onAdLoaded: () {
      print('interstitialAd onAdLoaded');
    },
    onAdFailedToLoad: (errorCode) {
      print('interstitialAd onAdFailedToLoad: errorCode:$errorCode');
    },
    onAdOpened: () {
      print('interstitialAd onAdOpened');
    },
    onAdClosed: () {
      print('interstitialAd onAdClosed');
      interstitialAd.load();
    },
    onAdLeftApplication: () {
      print('interstitialAd onAdLeftApplication');
    },
  );
  _interstitialAd.load();
}

@override
void dispose() {
  _interstitialAd.dispose();
  super.dispose();
}
await interstitialAd.show();

About isDevelop

If you set isDevelop to true, the test adUnitId will be used.
( If set false, the described adUnitId is used.)

About EventListener

The following event listeners are available:

  • onAdLoaded
  • onAdFailedToLoad
  • onAdOpened
  • onAdClosed
  • onAdLeftApplication

Rewarded Ads

firstly load it and call the show method at the desired timing.

DFPRewardedAd _rewardedAd;
LifecycleEventHandler _lifecycle;

@override
void initState() {
  super.initState();
  _rewardedAd = DFPRewardedAd(
    isDevelop: true,
    adUnitId: "XXXXXXX",
    onAdLoaded: () {
      print('rewardedAd onAdLoaded');
    },
    onAdFailedToLoad: (errorCode) {
      print('rewardedAd onAdFailedToLoad: errorCode:$errorCode');
    },
    onAdOpened: () {
      print('rewardedAd onAdOpened');
    },
    onAdClosed: () {
      print('rewardedAd onAdClosed');
      _rewardedAd.load();
    },
    onAdLeftApplication: () {
      print('rewardedAd onAdLeftApplication');
    },
    onRewarded: (String type, int amount) {
      print('rewardedAd onRewarded: type:$type amount:$amount');
    },
    onVideoStarted: () {
      print('rewardedAd onVideoStarted');
    },
    onVideoCompleted: () {
      print('rewardedAd onVideoCompleted');
    },
  );
  _rewardedAd.load();
  _lifecycle = LifecycleEventHandler(_rewardedAd);
  WidgetsBinding.instance.addObserver(_lifecycle);
}

@override
void dispose() {
  WidgetsBinding.instance.removeObserver(_lifecycle);
  _rewardedAd.dispose();
  super.dispose();
}
await _rewardedAd.show();

It is necessary to call it when resumed and paused, respectively. For that, please implement WidgetsBindingObserver.

class LifecycleEventHandler extends WidgetsBindingObserver {
  final DFPRewardedAd rewardedAd;

  LifecycleEventHandler(this.rewardedAd);

  @override
  didChangeAppLifecycleState(AppLifecycleState state) async {
    switch (state) {
      case AppLifecycleState.inactive:
        break;
      case AppLifecycleState.paused:
        await rewardedAd.pause();
        break;
      case AppLifecycleState.suspending:
        break;
      case AppLifecycleState.resumed:
        await rewardedAd.resume();
        break;
    }
  }
}

About isDevelop

If you set isDevelop to true, the test adUnitId will be used.
( If set false, the described adUnitId is used.)

About EventListener

The following event listeners are available:

  • onAdLoaded
  • onAdFailedToLoad
  • onAdOpened
  • onAdClosed
  • onAdLeftApplication
  • onRewarded
  • onVideoStarted
  • onVideoCompleted

Native Ads

Not implemented.
I am glad if someone will give me a pull request.

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。