Integrating Google Mobile Ads Flutter Plugin into a Flutter app is the first step toward displaying ads and earning revenue. After you've integrated Google Mobile Ads Flutter Plugin , implement one or more of the supported ad formats.
پیشنیازها
- فلاتر ۳.۳۸.۱ یا بالاتر
- اندروید
- آخرین نسخه اندروید استودیو
- آیاواس
- آخرین نسخه Xcode با ابزارهای خط فرمان فعال
Google Mobile Ads Flutter Plugin وارد کنید
- Google Mobile Ads Flutter Plugin در پروژه فلاتر خود بگنجانید.
تنظیمات خاص پلتفرم
اندروید
بهروزرسانی AndroidManifest.xml
شناسه برنامه AdMob باید در AndroidManifest.xml درج شود. عدم انجام این کار منجر به خرابی در هنگام اجرای برنامه میشود.
Add the AdMob app ID, as identified in the AdMob web interface , to the app's android/app/src/main/AndroidManifest.xml file by adding a <meta-data> tag with the name com.google.android.gms.ads.APPLICATION_ID . For android:value , insert your own app ID in quotes as shown:
<manifest>
<application>
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
<application>
<manifest>
هنگام مقداردهی اولیه افزونه در کد Dart خود، از همان value استفاده کنید.
برای اطلاعات بیشتر در مورد پیکربندی AndroidManifest.xml و تنظیم شناسه برنامه، به راهنمای اندروید مراجعه کنید.
آیاواس
بهروزرسانی اطلاعات.plist
در فایل ios/Runner/Info.plist برنامه خود، یک کلید GADApplicationIdentifier با مقدار رشتهای از شناسه برنامه AdMob خود، همانطور که در رابط وب AdMob مشخص شده است ، اضافه کنید:
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-################~##########</string>
شما باید هنگام مقداردهی اولیه افزونه در کد Dart خود، همان مقدار را ارسال کنید.
برای اطلاعات بیشتر در مورد پیکربندی Info.plist و تنظیم شناسه برنامه، به راهنمای iOS مراجعه کنید.
Google Mobile Ads Flutter Plugin راهاندازی کنید
Before loading ads, have your app initialize Google Mobile Ads Flutter Plugin by calling MobileAds.instance.initialize() which initializes Google Mobile Ads Flutter Plugin and returns a Future that finishes once initialization is complete, or after a 30-second timeout. Call initialize() as early as possible.
// Initialize the Mobile Ads SDK.
MobileAds.instance.initialize();
انتخاب قالب تبلیغ
After Google Mobile Ads Flutter Plugin is imported, you're ready to implement an ad. AdMob offers a number of different ad formats, so you can choose the one that best fits your app's user experience.
بنر
Rectangular ads that appear at the top or bottom of the device screen. Banner ads stay on screen while users are interacting with the app, and can refresh automatically after a certain period of time. If you're new to mobile advertising, they're a great place to start.
بینابینی
Full-screen ads that cover the interface of an app until closed by the user. They're best used at natural pauses in the flow of an app's execution, such as in between levels of a game or just after completing a task.
یک تبلیغ بینابینی پیادهسازی کنید
بومی
تبلیغات قابل تنظیم که با ظاهر و حس برنامه شما مطابقت دارند. شما تصمیم میگیرید که چگونه و کجا قرار گیرند، بنابراین طرحبندی با طراحی برنامه شما سازگارتر است.
یک تبلیغ بومی (Native) پیادهسازی کنید
پاداش داده شده
تبلیغاتی که به کاربران در ازای تماشای ویدیوهای کوتاه و تعامل با تبلیغات و نظرسنجیهای قابل پخش پاداش میدهند. برای کسب درآمد از کاربرانی که از بازیهای رایگان استفاده میکنند، مناسب است.
یک تبلیغ جایزهدار (Rewarded Ad) پیادهسازی کنید