Get Started with Avocarrot

Overview

Examples

Android

Overview

Getting Started

- Integrating Ads

Stream

Native Assets

Banner

Interstitial

Video

- Others

Troubleshooting

- Adapters

Admob Android Adapter

Mopub Android Adapter

iOS

Overview

Getting Started

- Integrating Ads

Stream

Native Assets

Banner

Interstitial

Video

- Others

Troubleshooting

- Adapters

Admob iOS Adapter

Mopub iOS Adapter

API Documentation

Reporting API

Help

Supported Networks & Ad Types

General

Earnings

Payments and Accounting

Integration

Reporting

Mediation Network Optimization

Legal and Privacy

Updates

SDK Change Log

Android Change Log

iOS Change Log

Stream

Updated 13 days ago ​by Chris

Overview

This tutorial helps you setup stream ads and receive your first Avocarrot Stream ad.

Steam Ads

Stream Ads is an ad unit that encapsulates native ads into a scroll collection.

Prerequisites

You need an Avocarrot account to complete the tutorial. Create an account
You need to create a stream ad unit for your app on your Avocarrot dashboard.
You need to setup Avocarrot SDK. Setup  SDK

Setup Stream Ads

  1. Configure In-Feed Viewer
    All SDK method calls should be done from the main thread (Main thread, UI thread).
    ID of advertising space for testing (like for native ad): "e5cc8e6d-d674-402a-aeca-eda7856bd7af"


    The ID above is meant for testing purpose only, please replace it with the Ad unit Id of your placement on dashboard.

    Add the following code to your activity:

    StreamAdBaseAdapter adAdapter = new StreamAdBaseAdapter.Builder()
      .setAdapter(new MainAdapter(this))
      .setAdUnitId("YOUR_NATIVE_AD_UNIT_ID")
      .setViewBuilder(ListNativeAdView.BUILDER)
      .setNativeAdCallback(streamNativeAdListener)
      .build(this);
    listView.setAdapter(adAdapter);
    adAdapter.loadAd();
    
    StreamAdRecyclerAdapter adAdapter = new StreamAdRecyclerAdapter.Builder()
      .setAdapter(new MainAdapter(this))
      .setAdUnitId("YOUR_NATIVE_AD_UNIT_ID")
      .setViewBuilder(FeedNativeAdView.BUILDER)
      .setEventCallback(streamNativeAdListener)
      .build(this);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adAdapter);
    adAdapter.loadAd();
    
  2. Setting DynamicNativeAdView Template.

    DynamicNativeAdView Template is a template that uses the template set on the dashboard and you can do "on the fly" changes to your native ads by customising them on your dashboard.
    .setAdViewBuilder(DynamicNativeAdView.BUILDER);
    Advance Customisation is not applicable to DynamicNativeAdView
  3. The method below starts the loading ad process:

    adAdapter.loadAd();
    After calling the loadAd() method, the in-feed ad download starts. If you call loadAd() again before the native ad is fully served, new request processing is cancelled. Only one request will be processed.  When in-feed ad download is completed, it will show automatically. To learn about download completion, subscribe to ad events (see Ad Events Handling section).
  4. Activity lifecycle events handling

    destroy() methods should be called depending on the activity lifecycle events.
    Example:d

    @Override
    protected void onPause() {
        super.onPause();
        adAdapter.onActivityPaused();
    }
    @Override
    protected void onResume() {
        super.onResume();
        adAdapter.onActivityResumed();
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        adAdapter.destroy();
    }
  5. Congratulations! Compile and Run your project . You can now customize your stream ads to match the look and feel of your app.

Advanced Customization


Go Live!

  1. Remove sandbox If you have received a sample ad then simply disable the Sandbox mode by including the following instruction in your code:
    Avocarrot.setTestMode(false);
    You should disable Sandbox mode ONLY when you are done with the integration and you are ready to publish your app. It is against Avocarrot's policies to use live ads during development, and doing so could get your Avocarrot account banned.
  2. Test your implementation on real devices with real ads before rolling it out to production. Please make sure that your test device has a sim-card and 'Ads Personalization' setting is turned on.
  3. Check whether Google Play Services are installed within your application.
  4. Publish app You are now ready to upload your app and start making money! If you have submitted your app in the Google Play/ Apple Store and you can see live ads, then you have nothing to worry about. Just wait until the impressions threshold has been reached and the app will be shown as live in your dashboard as well.
  5. Update payment details. Login to your account and update your payment settings.



Was this article useful?