Rewarded interstitial is a type of incentivized ad format that lets you offer rewards for ads that appear automatically during natural app transitions. Unlike rewarded ads, users aren't required to opt-in to view a rewarded interstitial. This guide shows how to integrate rewarded interstitial ads from Ad Manager into a Flutter app.
পূর্বশর্ত
চালিয়ে যাওয়ার আগে, নিম্নলিখিতগুলি করুন:
- ফ্লাটার প্লাগইন ১.১.০ বা তার উচ্চতর সংস্করণ ইনস্টল করুন।
- Google Mobile Ads Flutter Plugin সেট আপ করুন । আপনার ফ্লাটার অ্যাপে অবশ্যই Google Mobile Ads Flutter Plugin ইম্পোর্ট করা থাকতে হবে।
সর্বদা টেস্ট অ্যাড দিয়ে পরীক্ষা করুন
আপনার অ্যাপ তৈরি ও পরীক্ষা করার সময়, লাইভ বা প্রোডাকশন অ্যাডের পরিবর্তে টেস্ট অ্যাড ব্যবহার করুন। এটি করতে ব্যর্থ হলে আপনার অ্যাকাউন্ট সাসপেন্ড হতে পারে।
টেস্ট অ্যাড লোড করার সবচেয়ে সহজ উপায় হলো রিওয়ার্ডেড ইন্টারস্টিশিয়াল অ্যাডের জন্য আমাদের নির্দিষ্ট টেস্ট অ্যাড ইউনিট আইডি ব্যবহার করা:
-
/21775744923/example/rewarded-interstitial
টেস্ট অ্যাড ইউনিটগুলো প্রতিটি অনুরোধের জন্য টেস্ট বিজ্ঞাপন দেখানোর জন্য কনফিগার করা আছে, এবং কোডিং, টেস্টিং ও ডিবাগিং করার সময় আপনি আপনার নিজের অ্যাপে এগুলো ব্যবহার করতে পারেন। শুধু খেয়াল রাখবেন, আপনার অ্যাপটি পাবলিশ করার আগে যেন আপনি এগুলোকে আপনার নিজের অ্যাড ইউনিট আইডি দিয়ে প্রতিস্থাপন করেন।
একটি বিজ্ঞাপন লোড করুন
নিম্নলিখিত উদাহরণটি একটি পুরস্কারযুক্ত ইন্টারস্টিশিয়াল বিজ্ঞাপন লোড করে:
_adUnitId জায়গায় আপনার নিজের বিজ্ঞাপন ইউনিটের আইডি বসান।
পুরস্কৃত মধ্যবর্তী বিজ্ঞাপন ইভেন্ট
Through the use of FullScreenContentCallback , you can listen for lifecycle events, such as when the ad is shown or dismissed. Set RewardedInterstitialAd.fullScreenContentCallback before showing the ad to receive notifications for these events. This example implements each method and logs a message to the console:
ad.fullScreenContentCallback = FullScreenContentCallback(
onAdShowedFullScreenContent: (ad) {
// Called when the ad showed the full screen content.
debugPrint('Ad showed full screen content.');
},
onAdFailedToShowFullScreenContent: (ad, err) {
// Called when the ad failed to show full screen content.
debugPrint('Ad failed to show full screen content with error: $err');
// Dispose the ad here to free resources.
ad.dispose();
},
onAdDismissedFullScreenContent: (ad) {
// Called when the ad dismissed full screen content.
debugPrint('Ad was dismissed.');
// Dispose the ad here to free resources.
ad.dispose();
},
onAdImpression: (ad) {
// Called when an impression occurs on the ad.
debugPrint('Ad recorded an impression.');
},
onAdClicked: (ad) {
// Called when a click is recorded for an ad.
debugPrint('Ad was clicked.');
},
);
বিজ্ঞাপন প্রদর্শন করুন
একটি RewardedInterstitialAd অ্যাপের সমস্ত কন্টেন্টের উপরে একটি ওভারলে হিসেবে প্রদর্শিত হয় এবং এটি স্থিরভাবে স্থাপন করা থাকে; তাই, এটিকে ফ্লাটার উইজেট ট্রি-তে যোগ করা যায় না। show() কল করার মাধ্যমে আপনি বিজ্ঞাপনটি কখন দেখাবেন তা বেছে নিতে পারেন। RewardedInterstitialAd.show() একটি OnUserEarnedRewardCallback গ্রহণ করে, যা ব্যবহারকারী কোনো পুরস্কার অর্জন করলে চালু হয়। এটি অবশ্যই প্রয়োগ করুন এবং বিজ্ঞাপন দেখার জন্য ব্যবহারকারীকে পুরস্কৃত করুন।
_rewardedInterstitialAd?.show(
onUserEarnedReward: (AdWithoutView ad, RewardItem rewardItem) {
debugPrint('Reward amount: ${rewardItem.amount}');
},
);
Once show() is called, an Ad displayed this way can't be removed programmatically and requires user input. A RewardedInterstitialAd can only be shown once. Subsequent calls to show will trigger onAdFailedToShowFullScreenContent .
যখন কোনো বিজ্ঞাপনের আর প্রয়োজন হয় না, তখন সেটিকে ডিসপোজ করতে হবে। কখন dispose() কল করতে হবে তার সর্বোত্তম পদ্ধতি হলো FullScreenContentCallback.onAdDismissedFullScreenContent এবং FullScreenContentCallback.onAdFailedToShowFullScreenContent কলব্যাকগুলিতে এটি করা।
[ঐচ্ছিক] সার্ভার-সাইড ভেরিফিকেশন (SSV) কলব্যাকগুলি যাচাই করুন
Apps that require extra data in server-side verification callbacks should use the custom data feature of rewarded ads. Any string value set on a rewarded ad object is passed to the custom_data query parameter of the SSV callback. If no custom data value is set, the custom_data query parameter value won't be present in the SSV callback.
নিম্নলিখিত কোড নমুনাটি দেখায় যে কীভাবে রিওয়ার্ডেড ইন্টারস্টিশিয়াল বিজ্ঞাপন লোড হওয়ার পরে SSV বিকল্পগুলি সেট করতে হয়:
SAMPLE_CUSTOM_DATA_STRING আপনার নিজস্ব ডেটা দিয়ে প্রতিস্থাপন করুন।