The native ads are a kind of ad that can be shown using the same visual style like the rest of the app, which allows a natural and non-intrusive integration with the user interface.
Currently, Wortise provides the possibility of use the native ads from Google's ad platform ("Native Advanced"), in a simple and direct way.
Integration
To request a native ad, it is needed to make an integration by code just as shown in the example below:
publicclassMainActivityextendsActivity {privateGoogleNativeAd mGoogleNativeAd; @OverridepublicvoidonCreate(Bundle savedInstanceState) {... mGoogleNativeAd =newGoogleNativeAd(this,"Wortise Ad Unit ID", mNativeListener);mGoogleNativeAd.load(); } @OverridepublicvoidonDestroy() {...mGoogleNativeAd.destroy(); }privateGoogleNativeAd.Listener mNativeListener =new GoogleNativeAd.Listener() { @OverridepublicvoidonNativeClicked(@NonNullGoogleNativeAd ad) {// Invoked when ad has been clicked } @OverridepublicvoidonNativeFailedToLoad(@NonNullGoogleNativeAd ad, @NonNullAdError error) {// Invoked when the ad could not be loaded// (because of an error or no fill) } @OverridepublicvoidonNativeImpression(@NonNullGoogleNativeAd ad) {// Invoked when the ad has generated an impression } @OverridepublicvoidonNativeLoaded(@NonNullGoogleNativeAd ad, @NonNullNativeAd nativeAd) {// Invoked when the ad has been loaded } }}
classMainActivity : Activity() {privatevar googleNativeAd: GoogleNativeAd? =nulloverridefunonCreate(savedInstanceState: Bundle?) {... googleNativeAd =GoogleNativeAd(this, "Wortise Ad Unit ID", nativeListener).also { it.load() } }overridefunonDestroy() {... googleNativeAd?.destroy(); }privateval nativeListener =object : GoogleNativeAd.Listener() {overridefunonNativeClicked(ad: GoogleNativeAd) {// Invoked when the ad has been clicked }overridefunonNativeFailedToLoad(ad: GoogleNativeAd, error: AdError) {// Invoked when the ad could not be loaded// (because of an error or no fill) }overridefunonNativeImpression(ad: GoogleNativeAd) {// Invoked when the ad has generated an impression }overridefunonNativeLoaded(ad: GoogleNativeAd, nativeAd: NativeAd) {// Invoked when the ad has been loaded } }}
The GoogleNativeAd class includes a method called withNativeAdOptions which allows to specify custom options by using the NativeAdOptions class from Google. This method must be called before loading the ad.