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

unity_ads_plugin のカバー
パッケージ詳細v0.5.0

unity_ads_plugin

Flutterアプリケーション向けのUnity Adsプラグイン。このプラグインは、UnityバナーリンクとUnity動画広告を表示できます。

AndroidiOS
30日間ダウンロード
5820
いいね数
176
Pub ポイント
160

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

flutter pub add unity_ads_plugin

パッケージ概要

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

unity_ads_plugin は、Flutter アプリケーションが Unity 広告を統合できるようにし、Android および iOS でのバナー広告と動画広告形式をサポートしています。アプリ内に広告を読み込み表示するための簡単なインターフェースを提供し、開発者が Unity の広告プラットフォームを通じてプロジェクトを収益化できるようにします。このプラグインは、Flutter のネイティブ統合機能とシームレスに連携するように設計されており、高度なプラットフォーム固有の知識なしにスムーズな広告レンダリングを実現できます。最小限のセットアップで信頼性の高いアプリ内広告ソリューションが必要なアプリに最適です。

用途

  • モバイルゲームの収益化
  • アプリにバナー広告を表示する
  • リワード付き動画広告の実行
  • Unityの広告ネットワークの統合
  • アプリ内広告によるアプリ収益の向上

主な機能

  • Unityバナー広告をサポート
  • Unity ビデオ広告をサポート
  • クロスプラットフォーム(Android および iOS)
  • Flutter とのシンプルな統合
  • リアルタイム広告の読み込みと表示

適している対象

  • Unity Ads を使用する Flutter 開発者
  • 収益化を求めるモバイルゲーム開発者
  • 報酬付き動画広告が必要なアプリ
  • Android および iOS をターゲットとする開発者
  • 軽量広告統合を必要とするプロジェクト

注意事項

  • Unity Ads アカウントのセットアップが必要です
  • Unity Ads SDKのバージョンに依存しています
  • Android で追加の権限が必要になる場合があります
  • 広告の利用可能状況は地域および在庫に依存します
  • 広告の読み込み遅延によるパフォーマンスへの影響

元の README

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

Unity Ads Plugin

Pub License Pub likes Monthly downloads Pub points Flutter platform

Buy Me A Coffee PayPal

📢 Follow for updates: t.me/pavelzaichyk_dev

A Flutter plugin for integrating Unity Ads into your mobile applications. Easily display Unity Banner Ads and Unity Video Ads (Rewarded & Interstitial) with simple Dart APIs.


Features

  • Display Unity Banner, Rewarded, and Interstitial Video Ads
  • Simple initialization and ad loading
  • Server-to-server reward callback support
  • Privacy consent management
  • Firebase Test Lab support (Android)
  • Null safety

Table of Contents


Installation

Add the plugin to your pubspec.yaml:

dependencies:
  unity_ads_plugin: ^<latest_version>

Then run:

flutter pub get

Usage Example

Here is a minimal example of using the plugin:

import 'package:unity_ads_plugin/unity_ads_plugin.dart';

void main() {
  UnityAds.init(
    gameId: 'YOUR_GAME_ID',
    testMode: true,
    onComplete: () => print('Unity Ads Initialized'),
    onFailed: (error, message) => print('Unity Ads Initialization Failed: $error $message'),
  );
}

For more detailed usage, see the Getting Started section.


Getting Started

1. Initialization
UnityAds.init(
  gameId: 'PROJECT_GAME_ID',
  onComplete: () => print('Initialization Complete'),
  onFailed: (error, message) => print('Initialization Failed: $error $message'),
);

Set your Game ID. For testing purposes, set testMode to true.

UnityAds.isInitialized() can be used to check if the SDK has initialized successfully.


Android only: To change ad behavior in Firebase Test Lab, use the firebaseTestLabMode parameter. Possible values:

Mode Description
disableAds Ads are not displayed in Firebase Test Lab (default)
showAdsInTestMode Ads are displayed in test mode.
showAds Real ads are displayed if testMode is false.
2. Show Rewarded/Interstitial Video Ad

Rewarded Video Ad Interstitial Video Ad

Load a video ad before showing it.

UnityAds.load(
  placementId: 'PLACEMENT_ID',
  onComplete: (placementId) => print('Load Complete $placementId'),
  onFailed: (placementId, error, message) => print('Load Failed $placementId: $error $message'),
);

Show a loaded ad.

UnityAds.showVideoAd(
  placementId: 'PLACEMENT_ID',
  onStart: (placementId) => print('Video Ad $placementId started'),
  onClick: (placementId) => print('Video Ad $placementId click'),
  onSkipped: (placementId) => print('Video Ad $placementId skipped'),
  onComplete: (placementId) => print('Video Ad $placementId completed'),
  onFailed: (placementId, error, message) => print('Video Ad $placementId failed: $error $message'),
);
Server-to-server Redeem Callbacks

UnityAds.showVideoAd has a serverId parameter. To use server-to-server callbacks, set this parameter. Read more at docs.unity.com.

3. Show Banner Ad

Banner Ad

Place the UnityBannerAd widget in your app.

UnityBannerAd(
  placementId: 'PLACEMENT_ID',
  onLoad: (placementId) => print('Banner loaded: $placementId'),
  onClick: (placementId) => print('Banner clicked: $placementId'),
  onShown: (placementId) => print('Banner shown: $placementId'),
  onFailed: (placementId, error, message) => print('Banner Ad $placementId failed: $error $message'),
)
Privacy Consent

Read more about privacy consent in the Unity Ads documentation.

Use the following code to pass the appropriate consent flags to the Unity Ads SDK:

UnityAds.setPrivacyConsent(<Privacy Consent type>, true)

Troubleshooting

Android: the ad shows up as a separate app in Recent Apps

Symptom. While a fullscreen ad is playing, Recent Apps shows two cards for your app — your app and the ad. Users can swipe the ad away before it completes, so the impression is lost.

Fix. Remove one line from your app's android/app/src/main/AndroidManifest.xml:

<activity
    android:name=".MainActivity"
    android:taskAffinity=""     <!-- remove this line -->
    ...>

Flutter's template adds that blank affinity; Unity's ad screen keeps the default one. Android puts screens with different affinities in different tasks — hence the second card. Removing it puts the ad back in your app's task.

Trade-off. The attribute guards against task hijacking (flutter#144018), which Android patches at the OS level from API 30. On minSdk 30+ removing it costs nothing; below that, users on Android 7–10 lose partial protection — raising minSdk to 30 fixes both concerns at once.

Adding excludeFromRecents to Unity's ad activity does not work as an alternative. See issue #70.


Donate

If you find this package helpful and would like to support its continued development, please consider making a donation. Your contributions are greatly appreciated and motivate the further enhancement of this and other plugins.

Donate Buy Me A Coffee PayPal

Your support helps maintain and improve this package, ensuring it remains up-to-date and useful for the community.

Thank you for your generosity!

カテゴリー

ソースリポジトリ

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