Adding the Yandex Mobile Ads Flutter plugin
This is an archived version of the documentation. Actual documentation for all platforms can be found here.
- About the plugin
- Adding the plugin to your project
- Configuring for specific platforms
- Initializing the library
About the plugin
Flutter is a popular technology for creating mobile apps. Developers use it to write single code that can be run on different operating systems, including Android and iOS.
Now, it will be easier for you to monetize Android and iOS apps created with Flutter. All our partners in the Yandex Advertising Network can now use the plugin to enable Yandex-based monetization in their apps.
This plugin supports loading and display of the following ad types:
- Requirements
-
- Flutter 2.5.0 or higher.
Android 4.1 or higher.
Video ads are selected for devices with Android 5.0 or higher.
iOS 12.0 or higher.
Check the additional steps to ensure that iOS 14 (or higher) works properly.
Latest Xcode version with enabled command-line tools.
Registering an account in the Yandex Advertising Network.
Adding the plugin to your project
Install the Yandex Mobile Ads Flutter plugin in your project. From the root of the project, call the command:
flutter pub add yandex_mobileads
Once the plugin is added, you'll see the following line with a dependency in the pubspec.yaml
file:
dependencies:
yandex_mobileads: ^X.X.X
X.X.X
: The plugin's current version number.
Configuring for specific platforms
In the
app/build.gradle
file of your app's Android module, add:dependencies { // ... implementation 'com.yandex.android:mobileads-mediation:5.10.0.0' }
In the
build.gradle
file of your app's Android module, add:// IronSource maven { url 'https://android-sdk.is.com/' } // Pangle maven { url 'https://artifact.bytedance.com/repository/pangle' } // Tapjoy maven { url "https://sdk.tapjoy.com/" } // Mintegral maven { url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea" }
The new permission
com.google.android.gms.permission.AD_ID
is already added in the Yandex Mobile Ads SDK. It enables you to use AD_ID to select relevant ads. You can delete the permission if necessary.Learn more about the permission and ad IDThe ad ID is a unique identifier provided by Google Play services for displaying ads to users who opt in to personalized ads. Users can opt out of ad personalization or reset their ID in the settings. In this case, advertising networks won't be able to use the ID to select relevant ads for the user.
How to delete the permission
If some policies (such as Google Play's Families Policy) do not allow the use of ad IDs, you can delete the permission from the AndroidManifest.xml file.
<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>
In
Podlist
of your app's iOS module, add:pod 'YandexMobileAdsMediation', '5.9.0'
Mobile Ads SDK supports tracking of app installations using the SKAdNetwork framework. Installation tracking works for any device, even if no access to IDFA was granted.
To enable this functionality, add the IDs of the supported ad networks to the Info.plist file of your app's iOS module.
<key>SKAdNetworkItems</key> <array> <dict> <!-- Yandex Ads --> <key>SKAdNetworkIdentifier</key> <string>zq492l623r.skadnetwork</string> </dict> <dict> <!-- AdMob --> <key>SKAdNetworkIdentifier</key> <string>cstr6suwn9.skadnetwork</string> </dict> <dict> <!-- MyTarget --> <key>SKAdNetworkIdentifier</key> <string>n9x2a789qt.skadnetwork</string> </dict> <dict> <!-- MyTarget --> <key>SKAdNetworkIdentifier</key> <string>r26jy69rpl.skadnetwork</string> </dict> <dict> <!-- Start.io --> <key>SKAdNetworkIdentifier</key> <string>5l3tpt7t6e.skadnetwork</string> </dict> <dict> <!-- UnityAds --> <key>SKAdNetworkIdentifier</key> <string>4dzt52r2t5.skadnetwork</string> </dict> <dict> <!-- IronSource --> <key>SKAdNetworkIdentifier</key> <string>su67r6k2v3.skadnetwork</string> </dict> <dict> <!-- Applovin --> <key>SKAdNetworkIdentifier</key> <string>ludvb6z3bs.skadnetwork</string> </dict> <dict> <!-- Mintegral --> <key>SKAdNetworkIdentifier</key> <string>KBD757YWX3.skadnetwork</string> </dict> </array>
For more information, see Configuring a Source App in the Apple documentation.
Initializing the library
In the initState of your app's widget, add the line: MobileAds.initialize();
.