Native Ads
Fuse App SDK supports native ads and provides a built-in default layout for them. You can override the default native ad layout by registering a custom ad handler.
A custom ad handler lets you create your own UI for native ads, with full control over the layout, colours and fonts.
Keep in mind that native ads have optional elements, so your custom layout should adapt to handle optional elements (more information).
Google supports two different native ad formats - native and custom native. Make sure you register your custom ad handler for the correct native ad format.
When registering a custom ad handler, the Fuse App SDK will provide you with a zone code and native ad object. You are then responsible for returning a custom view with the rendered native ad.
Android:
FuseSDK.addNativeAdHandler { context, code, ad ->
when (code) {
"<zone_code>" -> MyNativeAdView(context, ad)
else -> null
}
}
FuseSDK.addCustomNativeAdHandler { context, code, ad ->
when (code) {
"<zone_code>" -> MyCustomAdView(context, ad)
else -> null
}
}
iOS:
FuseSDK.shared.addNativeAdHandler { code, ad in
if code == "<zone_code>" {
return MyNativeAdView(nativeAd: ad)
} else {
return nil
}
}
FuseSDK.shared.addCustomNativeAdHandler { code, ad in
if code == "<zone_code>" {
return MyCustomAdView(customNativeAd: ad)
} else {
return nil
}
}