loadNativeAd method
Future<OcmNativeAd>
loadNativeAd({
- required String prebidConfigId,
- String? gamAdUnitId,
- String? gamNativeFormatId,
- OcmNativeLoadMode mode = OcmNativeLoadMode.gam,
- OcmNativeListener? listener,
override
Implementation
@override
Future<OcmNativeAd> loadNativeAd({
required String prebidConfigId,
String? gamAdUnitId,
String? gamNativeFormatId,
OcmNativeLoadMode mode = OcmNativeLoadMode.gam,
OcmNativeListener? listener,
}) async {
final adId = 'native-${DateTime.now().microsecondsSinceEpoch}';
if (listener != null) {
_nativeListeners[adId] = listener;
}
try {
final map = await methodChannel.invokeMapMethod<Object?, Object?>(
'native.load',
<String, Object?>{
'adId': adId,
'prebidConfigId': prebidConfigId,
'gamAdUnitId': gamAdUnitId,
'gamNativeFormatId': gamNativeFormatId,
'mode': mode.name,
},
);
return OcmNativeAd.fromMap(map ?? <Object?, Object?>{});
} finally {
_nativeListeners.remove(adId);
}
}