NativeAdController.fromKey constructor
NativeAdController.fromKey({
- required String configKey,
Implementation
factory NativeAdController.fromKey({required String configKey}) {
try {
final data = FirebaseRemoteConfig.instance.getString(configKey);
final json = jsonDecode(data);
final config = NativeConfig.fromJson(json);
return NativeAdController(
adUnitId: config.adUnitId,
adHeight: config.height,
type: config.type,
onAdOpened: (ad) {
FirebaseAnalytics.instance.logEvent(
name: 'ad_clicked',
parameters: {
// 'ad': ad.responseInfo?.loadedAdapterResponseInfo?.description
},
);
},
);
} catch (e, st) {
log('', name: 'AppBannerAd.fromKey', error: e, stackTrace: st);
return NativeAdController(adUnitId: '');
}
}