initialize method
void
initialize({})
Implementation
void initialize({
String? androidRewardedAdID,
String? androidInitAdID,
String? androidBannerAdID,
String? androidNativeAdID,
String? androidAppOpenAdID,
String? iosRewardedAdID,
String? iosInitAdID,
String? iosBannerAdID,
String? iosNativeAdID,
String? iosAppOpenAdID,
List<String>? testDevices,
}) {
try {
_adIds = {
// Setting rewarded ad ID based on the platform (Android or iOS).
'rewarded': Platform.isAndroid ? androidRewardedAdID : iosRewardedAdID,
// Setting initialization ad ID based on the platform (Android or iOS).
'init': Platform.isAndroid ? androidInitAdID : iosInitAdID,
// Setting banner ad ID based on the platform (Android or iOS).
'banner': Platform.isAndroid ? androidBannerAdID : iosBannerAdID,
// Setting native ad ID based on the platform (Android or iOS).
'native': Platform.isAndroid ? androidNativeAdID : iosNativeAdID,
// Setting app open ad ID based on the platform (Android or iOS).
'appOpen': Platform.isAndroid ? androidAppOpenAdID : iosAppOpenAdID,
};
/// Add the listener for internet connection
AdmobEasy.instance.initConnectivity();
/// Initializing Mobile Ads and updating request configuration with test IDs with UMP.
AdmobUmp.instance.initializeUMP(testDevices);
} catch (e) {
// Throwing an exception if an error occurs during initialization.
throw Exception("Error initializing Admob: $e");
}
}