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

appodeal_flutter 封面
套件詳情v1.1.2

appodeal_flutter

一個用於顯示 Appodeal 廣告的 Flutter 外掛;它支援同意對話框來追蹤使用者。

AndroidiOS
近 30 天下載
126
喜歡數
74
Pub 分數
150

安裝套件

flutter pub add appodeal_flutter

套件介紹

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

Appodeal Flutter 是一個插件,可將 Appodeal 廣告網路整合至 Android 與 iOS 的 Flutter 應用程式中。它支援顯示多種廣告格式,例如橫幅、全螢幕廣告與獎勵影片。該套件內建合規管理機制,以符合 GDPR 與 CCPA 等隱私法規,確保使用者追蹤能被負責任地處理。開發者可透過簡單的 API 輕鬆初始化與管理廣告。它簡化廣告收益化流程,同時維持與全球資料保護標準的合規性。

適用情境

  • 透過應用內廣告實現移動應用變現
  • 跨平台合規廣告投放整合
  • 顯示獎勵視頻廣告以提高使用者參與度
  • 在應用介面之間顯示插頁廣告
  • 管理使用者追蹤同意
  • 在一個解決方案中支援多種廣告格式

主要特色

  • 符合GDPR和CCPA的同意對話框
  • 支援橫幅廣告、插頁廣告和獎勵廣告
  • 輕鬆初始化和整合
  • 跨平台支援(Android 與 iOS)
  • 內建使用者同意管理
  • 廣告控制的簡單API

適合對象

  • 尋求廣告變現的Flutter開發者
  • 面向全球受眾且有隱私合規需求的應用程式
  • 需要多種廣告格式的專案
  • 使用 Appodeal 作為主要廣告網絡的開發者
  • 需要自動化同意處理的應用程式

使用建議

  • 需要 Appodeal 帳戶和廣告單元設定
  • 需要在 AndroidManifest.xml 和 Info.plist 中進行正確配置
  • 取決於 Appodeal SDK 版本相容性
  • 同意對話框必須根據地區正確顯示
  • 可能需要額外測試以符合要求
  • 與原生 SDK 相比,自訂功能有限

原始 README

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

appodeal_flutter

GitHub Actions Pub Version MIT License

A Flutter plugin to display ads from Appodeal. It currently supports Banner, MREC, Interstitial, Reward and Non-Skippable ads.

⚠ Package Archived ⚠ - Please use the official Appodeal package from now on

This project was created by me when there was no official support for Appodeal on Flutter. But now that the Appodeal team created their own official package I don't see a reason to keep maintaining this one.

I thank everybody that downloaded, contributed with PRs an supported this package.

📽 Demo

Demo

⚙️ Installation

  1. Add the dependency to the pubspec.yaml file in your project:
dependencies:
  appodeal_flutter: # use the latest version
  1. Install the plugin by running the command below in the terminal, in your project's root directory:
$ flutter pub get
  1. Follow the Appodeal installation instructions available for iOS and Android. However, ignore the steps to include the Appodeal SDK dependencies in Gradle (Android) and Cocoapods (iOS) since these steps will be done by this package.
Extra steps for Android only
  1. The Appodeal framework includes mutiple libraries from different ad providers, so it's very likely that the inclusion of this plugin in your project will make it exceed to 64K limit method count of Android. To solve this problem you need to enable multidex in your project; follow the instructions here to learn how to do that.

  2. Your Android project must use Gradle 4.0.1 or greater. If you are using an older version, please upgrade it by editing the file android/build.gradle.

Extra step for iOS 14+ only
  1. Follow the instructions available here to learn how to implement the permission request to track users, but ignore the part to include some code in the AppDelegate file. This code is already included in this plugin and it will be executed when you call the function Appodeal.requestIOSTrackingAuthorization(), before the initialization of Appodeal (see below).
If you don't use AdMob

This plugin comes with all possible ad networks supported by Appodeal enabled by default. I made this decision to give more flexibility to the developers using this project, but this comes with a drawback: if you don't intend to use Google AdMob in your app, then you are still forced to add a fake application ID in your project otherwise AdMob will make the app crash if it doesn't find an ID 😬

To add this fake AdMob ID (again, only if you don't intend to use AdMob, otherwise you should use your real AdMob identifier) you must:

Android

Edit the file android/app/src/main/AndroidManifest.xml and add this into the <application> tag:

<application ...>
    ...
    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="ca-app-pub-0000000000000000~0000000000" />
    ...
</application>
iOS

Edit the file ios/Runner/Info.plist and add this into the <dict> tag:

<dict>
    ...
    <key>GADApplicationIdentifier</key>
    <string>ca-app-pub-0000000000000000~0000000000</string>
    ...
</dict>

📱 Usage

Import the plugin as early as possible somewhere in your project (ideally in the file main.dart), then initialize the plugin by calling the functions Appodeal.setAppKeys() and Appodeal.initialize():

Initialization

First you need to set the app keys:

// Set the Appodeal app keys
Appodeal.setAppKeys(
  androidAppKey: '<your-appodeal-android-key>',
  iosAppKey: '<your-appodeal-ios-key>',
);

Where androidAppKey and iosAppKey are the keys associated with your app in your Appodeal account. At least one of these keys must be set before the initialization (either Android or iOS), otherwise you will get an error.

Afterwards you can initialize Appodeal with the function:

// Initialize Appodeal
await Appodeal.initialize(
  hasConsent: true,
  adTypes: [AdType.banner, AdType.mrec, AdType.interstitial, AdType.reward, AdType.nonSkippable],
  testMode: true,
  verbose: true,
);

// At this point you are ready to display ads
  • hasConsent (mandatory) you must set either true or false, depending if the user granted access to be tracked in order to received better ads. See section about collecting user consent for more information.

  • adTypes (optional) you must set a list (of type AdType) with all the ad types that you would like to display in your app. If this parameter is undefined or an empty list then no ads will be loaded.

  • testMode (optional) you must set either true or false (default) depending if you are running the ads during development/test or production.

  • verbose (optional) you must set either true or false (default) if you want Appodeal's verbose logs to be visible amongst the Flutter logs.

👮🏾‍♂️ Consent to track the user

Before you initialize the plugin and start displaying ads, you might need to collect the user's consent to be tracked online, depending on his location or the operating system that he is using.

For iOS 14+ only

Since iOS 14+ you are required to request a specific permission before you can have access to Apple's IDFA (a sort of proprietary cookie used by Apple to track users among multiple advertisers... ah Apple, always Apple 🙄). To request this permission call the function Appodeal.requestIOSTrackingAuthorization():

// iOS 14+: request permission to track users
// on iOS <= 13 and Android this function does nothing; it just returns true
await Appodeal.requestIOSTrackingAuthorization();

For iOS versions before 14 and for Android devices this function won't do anything, so it's safe to call it on any device OS or version.

For users protected by GDPR/CCPA privacy laws

Depending on the location of your users, they might be protected by the privacy laws GDPR or CCPA. These laws require, among other things, that app developers must collect user consent before the advertisers can track them online. You can check if the user is protected by any privacy laws, by calling the function Appodeal.shouldShowConsent():

bool shouldShow = await Appodeal.shouldShowConsent();
if (shouldShow) { /* Request user consent */ }

Keep in mind that the function above will also return false if the user previously accepted or declined the request to be tracked online. So it's important to always call this function in advance to avoid annoying the user with permission requests that he already answered.

After you determine if you need to request user consent, you have two options to collect this consent:

  1. You can design the UI with all the legal information and multiple options to let the user decline, accept or partially accept the options to be tracked. After you collect this information yourself, you then need to pass the value true or false to the parameter hasConsent during the Appodeal initialization.

or:

  1. You can use the UI provided by the Consent Manager framework. With this option you can't customize the UI used to collect the user consent, however it does the heavy lifting for you of creating and displaying a window with all the legal wording, permission options and everything that is necessary to get the user's permission to be tracked. If you decide to go with option # 2 then you must call two functions:

    2.1. Call the function Appodeal.requestConsentAuthorization() to display a window requesting the user consent to be tracked:

    await Appodeal.requestConsentAuthorization();
    

    2.2. After the user grants or decline consent, you can call the function Appodeal.fetchConsentInfo() to fetch the consent info:

    var consent = await Appodeal.fetchConsentInfo();
    var hasConsent = consent.status == ConsentStatus.personalized || consent.status == ConsentStatus.partlyPersonalized;
    await Appodeal.initialize(hasConsent: hasConsent, ...)
    

💵 Showing ads

After you collect all the permissions and the plugin properly initialized, you are ready to display the ads:

Banner & MREC

To display a banner or MREC ad in your app, just include the widgets AppodealBanner() or AppodealMrec() somewhere in your widget tree. For example:

...
// Add a banner ad
Center(
  child: AppodealBanner()
),
// or a MREC ad
Center(
  child: AppodealMrec()
),
...
Interstitial, Reward & Non-Skippable

To show an interstitial, reward or non-skippable ad, call the function Appodeal.show() passing the type of ad that you would like to show as a paremeter (mandatory) and the placement name (optional):

Appodeal.show(AdType.interstitial, placementName: "placement-name");  // Show an interstitial ad
Appodeal.show(AdType.reward, placementName: "placement-name");        // Show a reward ad
Appodeal.show(AdType.nonSkippable);                                   // Show a non-skippable ad without placement name

♻️ Callbacks

You can define callbacks to your ads and track when an event occurs; it can be done by calling the callback functions below:

  • Appodeal.setBannerCallback((event) {})
  • Appodeal.setMrecCallback((event) {})
  • Appodeal.setInterstitialCallback((event) {})
  • Appodeal.setRewardCallback((event) {})
  • Appodeal.setNonSkippableCallback((event) {})

Every callback carries the parameter event of type String and you can use it to determine what event has been triggered. For example, if I wanted to know when the user watched a reward ad until the end, I could use the following callback code:

Appodeal.setRewardCallback((event) {
  if (event == 'onRewardedVideoFinished') {
    print('The user watched the reward ad until the end');
  }
})

and if later I don't want to track reward events anymore, I just need to pass the value null to the same callback function:

Appodeal.setRewardCallback(null);

The full list of events that you can track is below:

Banner

onBannerLoaded, onBannerFailedToLoad, onBannerShown, onBannerClicked, onBannerExpired.

MREC

onMrecLoaded, onMrecFailedToLoad, onMrecShown, onMrecClicked, onMrecExpired.

Interstitial

onInterstitialLoaded, onInterstitialFailedToLoad, onInterstitialShown, onInterstitialShowFailed, onInterstitialClicked, onInterstitialClosed, onInterstitialExpired.

Reward

onRewardedVideoLoaded, onRewardedVideoFailedToLoad, onRewardedVideoShown, onRewardedVideoShowFailed, onRewardedVideoFinished, onRewardedVideoClosed, onRewardedVideoExpired, onRewardedVideoClicked.

Non-Skippable

onNonSkippableVideoLoaded, onNonSkippableVideoFailedToLoad, onNonSkippableVideoShown, onNonSkippableVideoShowFailed, onNonSkippableVideoFinished, onNonSkippableVideoClosed, onNonSkippableVideoExpired.

🙏🏾 Donations

If you like this project then please consider becoming a sponsor. Your contribution will help me dedicate more time working on bugs and new features for this and other projects.

📝 License

appodeal_flutter is released under the MIT License. See LICENSE for details.

👨🏾‍💻 Author

Vinicius Egidio (vinicius.io)

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。