SDK Documentation
HomeBlogSign up
English
English
  • 🏠Homepage
  • 🧪Test Ad Units
  • Privacy
    • ✅Google Data Safety
  • Android SDK
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Native (Google)
      • Targeting
      • Revenue reporting
    • 🙎User consent
    • 🔓Privacy
    • 🛠️ProGuard
  • iOS SDK
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Native (Google)
      • Revenue reporting
    • 🙍User consent
    • 🔓Privacy
  • Unity SDK
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Targeting
      • Revenue reporting
    • 🙎User consent
    • 🔓Privacy
  • Flutter SDK
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Native (Google)
      • Targeting
      • Revenue reporting
    • 🙎User consent
    • 🔓Privacy
  • React Native
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Targeting
      • Revenue reporting
    • 🙎User consent
    • 🔓Privacy
  • Web SDK
    • ⌨️SDK integration
Con tecnología de GitBook
En esta página
  • Integration
  • Specify options
  1. Android SDK
  2. SDK integration

Native (Google)

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:

class MainActivity : Activity() {

    private var googleNativeAd: GoogleNativeAd? = null
    
    override fun onCreate(savedInstanceState: Bundle?) {
        ...
        googleNativeAd = GoogleNativeAd(
                         this, "Wortise Ad Unit ID", nativeListener).also {
            it.load()
        }
    }
    
    override fun onDestroy() {
        ...
        googleNativeAd?.destroy();
    }
    
    private val nativeListener = object : GoogleNativeAd.Listener() {
            
        override fun onNativeClicked(ad: GoogleNativeAd) {
            // Invoked when the ad has been clicked
        }
        
        override fun onNativeFailedToLoad(ad: GoogleNativeAd, error: AdError) {
            // Invoked when the ad could not be loaded
            // (because of an error or no fill)
        }
        
        override fun onNativeImpression(ad: GoogleNativeAd) {
            // Invoked when the ad has generated an impression
        }
        
        override fun onNativeLoaded(ad: GoogleNativeAd, nativeAd: NativeAd) {
            // Invoked when the ad has been loaded
        }
        
        override fun onNativeRevenuePaid(ad: GoogleNativeAd,
                                         data: RevenueData) {
            // Invoked when the ad has generated revenue
        }
    }
}
public class MainActivity extends Activity {

    private GoogleNativeAd mGoogleNativeAd;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        ...
        mGoogleNativeAd = new GoogleNativeAd(
                this, "Wortise Ad Unit ID", mNativeListener);
        mGoogleNativeAd.load();
    }
    
    @Override
    public void onDestroy() {
        ...
        mGoogleNativeAd.destroy();
    }
    
    private GoogleNativeAd.Listener mNativeListener 
            = new GoogleNativeAd.Listener() {
            
        @Override
        public void onNativeClicked(@NonNull GoogleNativeAd ad) {
            // Invoked when ad has been clicked
        }
        
        @Override
        public void onNativeFailedToLoad(@NonNull GoogleNativeAd ad,
                                         @NonNull AdError error) {
            // Invoked when the ad could not be loaded
            // (because of an error or no fill)
        }
        
        @Override
        public void onNativeImpression(@NonNull GoogleNativeAd ad) {
            // Invoked when the ad has generated an impression
        }
        
        @Override
        public void onNativeLoaded(@NonNull GoogleNativeAd ad,
                                   @NonNull NativeAd nativeAd) {
            // Invoked when the ad has been loaded
        }
        
        @Override
        public void onNativeRevenuePaid(@NonNull GoogleNativeAd ad,
                                        @NonNull RevenueData data) {
            // Invoked when the ad has generated revenue
        }
    }
}

Specify options

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.

Below you can check a brief usage example:

var adOptions = NativeAdOptions.Builder()
    // Options are set here
    .build();

googleNativeAd.withNativeAdOptions(adOptions)
NativeAdOptions adOptions = new NativeAdOptions.Builder()
    // Options are set here
    .build();

mGoogleNativeAd.withNativeAdOptions(adOptions);
AnteriorRewardedSiguienteTargeting

Última actualización hace 3 días

Once the native ad has been successfully loaded, obtaining as result a NativeAd instance, it is needed to complete the integration by following Google's documentation on this matter:

⌨️
https://developers.google.com/ad-manager/mobile-ads-sdk/android/native/advanced?hl=en#display_a_nativead