fetchBannerAdsWithAu method
Future<Map<String, dynamic> ?>
fetchBannerAdsWithAu({
- required String cliUbid,
- required String pageType,
- required String adUnit,
- List<
TargetingParams> ? targetingParams,
override
Fetches banner ads with ad unit.
Parameters:
cliUbid: Unique client identifier.pageType: Name of the page where ads will be displayed.adUnit: Identifier of the ad unit.targetingParams: Map of targeting options (optional).extra_params: Additional optional parameters (optional).
Returns:
A Future that resolves to a Map<String, dynamic> containing ad data or null if no ad is available.
Example Usage:
var adData = await AdRenderer.fetchBannerAdsWithAU(
cliUbid: "your_user_id",
pageType: "your_page_type",
adUnit: "your_ad_unit",
);
if (adData != null) {
BannerAdPlatformView(adDict: adData);
}
Implementation
@override
Future<Map<String, dynamic>?> fetchBannerAdsWithAu({
required String cliUbid,
required String pageType,
required String adUnit,
List<TargetingParams>? targetingParams,
}) async {
try {
final result = await MethodHandler.invokeNativeMethod(
'fetchBannerAdsWithAu',
arguments: {
"cliUbid": cliUbid,
"pageType": pageType,
"adUnit": adUnit,
"targetingParams": convertTargetingParamsToMapList(targetingParams)
},
);
return _normalizeAdData(result, 'fetchBannerAdsWithAu')
?.cast<String, dynamic>();
} on OsmosException {
rethrow; // Re-throw OsmosException to maintain error context
} catch (e) {
throw OsmosException(
errorCode: OsmosErrorCodes.bannerAdError,
details: 'Failed to fetch banner ad: ${e.toString()}',
nativeError: e,
);
}
}