Skip to content

RevContent/RCNativeAndroidSDK

Repository files navigation

Introduction

Revcontent's Android library written in Java for enables you quickly and reliably include our JS widgets into your application.

Prerequisites

  • Android Studio
  • Android SDK

Features

  • Load widget by WidgetId
  • Load widget by SubId (Optional)
  • Define Base URL as FQDN or Article URL
  • Flexible widget size

Installation

  • Create a new project in Android Studio as you would normally for e.g. MyApp.

  • In your project’s build.gradle add the following line:

      allprojects{
      	repositories{
          	...
              maven { url 'https://jitpack.io' }
          }
      }
    
  • In your app’s build.gradle add the dependency:

      dependencies{
          implementation 'com.github.RevContent:RCNativeAndroidSDK:0.1.6'
      }
    

RCNativeJSWidgetView

Basic usage in app

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Should be called before widget usage
        RCNativeSDK.setup();

        // Get the widget view from layout
        RCNativeJSWidgetView widgetView = findViewById(R.id.rc_widget);

        // WidgetId is required
        widgetView.setWidgetId("168072");

        // WidgetSubId is optional
        Map<String, String> map = new HashMap<>();
        map.put("category","entertainment");
        map.put("utm_code","123456");
        widgetView.setWidgetSubId(map);

        // baseUrl defined here
        widgetView.setBaseUrl("https://performance.revcontent.dev");

        //will load the given data into widget;
        widgetView.loadWidget();
    }
}

Using OnSizeChangedListener

//Optionally, you can add a listener for the widget's size changes.
widgetView.addOnSizeChangedListener(new OnSizeChangedListener() {
    @Override
    public void onSizeChanged(int height, int width) {
    //add your code here
    }
});

//OnSizeChangedListener can be removed like this:
widgetView.removeOnSizeChangedListener();

Clear cache

//You can clear cache by this method. Note that the cache is per-application, so this will clear
//the cache for all WebViews used.
//
//Boolean parameter used:
//false - only the RAM cache is cleared,
//true - both the RAM cache and the cache on the disk files clears;
widgetView.removeCache(true);

GDPR

The General Data Protection Regulation (GDPR) is the toughest privacy and security law in the world. Though it was drafted and passed by the European Union (EU), it imposes obligations onto organizations anywhere, so long as they target or collect data related to people in the EU. The regulation was put into effect on May 25, 2018.

Revcontent's widget supports GDPR consent parameters. In order to provide user's GDPR consent status you can implement your own or third party CMP. You can also check the demo app provided by IAB The parameters are optional and can be passed to Revcontent's widget via below method, which should be called before loadWidget() method:

// boolean value, which determines if GDPR is applicable.
boolean isGDPRApplicable = true;

// GDPR consent string is IAB standard URL-safe base64 encoded value.
String gdprConsent = "<GDPR_CONSENT_STRING>";

widgetView.setGDPRConsentInfo(isGDPRApplicable, gdprConsent);

// GDPR consent info should be provided before this method call:
widgetView.loadWidget();

CCPA

The California Consumer Privacy Act (CCPA) is a law that allows any California consumer to demand to see all the information a company has saved on them, as well as a full list of all the third parties that data is shared with. In addition, the California law allows consumers to sue companies if the privacy guidelines are violated, even if there is no breach.

Revcontent's widget supports CCPA consent parameter. In order to provide user's CCPA consent status you should get US Privacy String.

The parameter is optional and can be passed to Revcontent's widget via below method, which should be called before loadWidget() method:

// CCPA consent string. Is IAB standard URL-encoded U.S. Privacy string.
String ccpaConsent = "<CCPA_CONSENT_STRING>";
widgetView.setUSPrivacyConsentInfo(ccpaConsent);

//CCPA consent info should be provided before this method call
widgetView.loadWidget();

RCNativeSliderBanner

Basic usage in app

// Create instance of banner.
// RCNativeSliderBanner will try and find a parent view to hold RCNativeSliderBanner view
// from the value given to view;
final RCNativeSliderBanner banner = new RCNativeSliderBanner(findViewById(R.id.main));

// Start loading banner.
// Once loaded, banner will appear from the bottom of parent view.
// Banner can be loaded only once. For the new banner create new banner instance.
//
// Required parameters - widgetID & BannerSize from public enum.
banner.loadBanner(1233, BannerSize.W970XH250);

BannerEventListener

// Add a listener that will provide callbacks when:
//  - the banner finished loading;
//  - the banner was closed by user;
//  - user was navigated by the link after tapping on the banner;
banner.addEventListener(new BannerEventListener() {
    @Override
        public void onLoaded() {
            Toast.makeText(getApplicationContext(), "onLoaded", Toast.LENGTH_SHORT).show();
        }

    @Override
        public void onClosed() {
            Toast.makeText(getApplicationContext(), "onClosed", Toast.LENGTH_SHORT).show();
        }

    @Override
        public void onLinkTap() {
            Toast.makeText(getApplicationContext(), "onLinkTap", Toast.LENGTH_SHORT).show();
    }
});

// Remove event listener
banner.removeEventListener();

Optional RCNativeSliderBanner settings

// You can set whether banner should be shown when loaded.
// By default banner will be shown once finished loading.
banner.showWhenLoaded(false);

// In order to show banner, when the showWhenLoaded(false) was set, use this method
banner.show();

// Banner can be cancelled.
// If visible - it will be closed and then detached from parent view.
banner.cancel();

Ads.txt for Publishers

Click Here for the lines needed for your Ads.txt file to work with Revcontent.

What is Ads.txt?

Ads.txt is an initiative founded by the IAB Technology Laboratory to increase transparency in the programmatic landscape. The goal is to ensure publishers’ inventory is only sold through authorized partners to prevent counterfeiting in addition to providing advertisers more control over their purchased inventory.

What exactly is ads.txt?

  • Authorized Digital Sellers (ads.txt for short) is an IAB initiative to improve transparency and reduce fraud in programmatic advertising.
  • Ads.txt is a publicly available file that publishers create and add to their websites. The file is plain text and contains the names of the authorized networks that have permission to sell their inventory.

How does ads.txt benefit me?

  • The Ads.txt file can help protect your brand from counterfeit inventory that is intentionally mislabeled as originating from a specific domain, app, or video.
  • Declaring authorized sellers will open up more demand as many buyers will not purchase inventory unless they have an ads.txt file outlining authorized to sellers.

How do I create a .txt file?

Create your file as a text (.txt) using Notepad or a similar program.

  • Your file should be hosted at the root level for your domain.Example: https://example.com/ads.txt
  • Root Domain is defined as one level down from the Public Suffix List, which is also how it is defined in the IAB ads.txt specification. Example: google.co.uk would be considered a root domain as co.uk is on the Public Suffix List, but maps.google.co.uk would not be considered a root domain.

What information is included in an ads.txt file?

Publishers should include a separate line in the file for each authorized seller. Each line in a publisher’s ads.txt list requires three pieces of data (plus a fourth optional field) <Field #1>, <Field #2>, <Field #3>, <Field #4>:

  • The domain name of the advertising system (required) Example: revcontent.com
  • Publisher’s Account ID (required) Example: 12345 (Your publisher ID for Revcontent)
  • Type of Account/Relationship (required) DIRECT - A direct business contract between the publisher and the advertising system RESELLER - Publishers who do not directly control the account indicated in should specify RESELLER NOTE: This field is case-sensitive and should always be in all-caps for both DIRECT and RESELLER
  • Certification Authority ID (optional) A current certification authority is the Trustworty Accountability Group (TAG), and the TAG ID would be included here.

Information that needs to be in your ads.txt file as a publisher with Revcontent should be copied directly from the list found inside of your account settings. Click here to go directly to the relevant page.

How do I create an ads.txt file in DFP?

Check out Google’s Step-By-Step Guide on ads.txt management in DFP.

Need more Information?

You can learn more about this IAB initiative here. For more information from Revcontent, feel free to reach out to your Publisher Account Representative.

Changelog

History of all changes is available here.

License

MIT

About

Revcontent's Official Javascript Widget SDK for Android

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages