Requirements:

  • PubNative App Token from the PubNative Publisher Dashboard

Install using Gradle

Add PubNative Maven repo to your project level build.gradle file:

buildscript {
    repositories {
        // Other dependencies
        maven { url 'https://verve.jfrog.io/artifactory/verve-gradle-release' }
    }
    dependencies {
        // ...
    }
}

allprojects {
    repositories {
        // Other dependencies
        maven { url 'https://verve.jfrog.io/artifactory/verve-gradle-release' }
    }
}

Add HyBid SDK dependency to the module level build.gradle file:

implementation 'net.pubnative:hybid.sdk:3.0.0'
implementation 'net.pubnative:hybid.adapters.dfp:3.0.0'
implementation 'net.pubnative:hybid.adapters.admob:3.0.0'

Manifest Permissions

To enable the basic features of the PN Lite SDK, the following permissions must be added in the AndroidManifest.xml file:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

For improved targeting and therefore higher eCPMs you can add this other permissions but keep in mind that the user needs to approve them explicitly on Android versions 6 or higher.

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<!-- For location use one of the following permissions -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- or -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

SDK initialisation

On your main Activity or your Application class onCreate method you should initialise the SDK using the app token that was provided to you in the PubNative Publisher Dashboard.

HyBid.initialize("APP_TOKEN", this);

Advanced configurations

Proguard

If you are using Proguard in your gradle build, you should add these lines to your proguard file:

-keepattributes Signature
-keep class net.pubnative.** { *; }
-keep class com.iab.omid.library.pubnativenet.** { *; }

Test mode

During development and testing of the SDK integration it is recommended to enable test mode. This will make the impressions and click not count on the PubNative side. Testing without enabling this mode could result in your account getting blocked because the traffic will be considered fraudulent.

Test mode is disabled by default. To enable test mode, you should use this line in the same location where you initialise the SDK:

HyBid.setTestMode(true);

Location tracking

If the user has given location permissions, HyBid SDK will use the available user location to provide better targeted ads.
This feature is enabled by default, but can be disabled by setting the setLocationTrackingEnabled on the HyBid class:

HyBid.setLocationTrackingEnabled(false);

Location updates

The SDK refreshes the user location after every ad request if the user has given permission for location tracking. This is done to keep the best accuracy possible. However if the app will do many requests in a short time it might display location updates very often which can be intrusive for some users.

You can disable this behaviour by setting the setLocationUpdatesEnabled on the HyBid class:

HyBid.setLocationUpdatesEnabled(false);

Keep in mind that if location tracking is disabled, anything you set in here will have no effect since location tracking will be disabled globally for HyBid SDK

Enable COPPA compliance

If your app is intended for children you should enable the COPPA compatibility in order to protect the privacy of the information in their devices. It is disabled by default.

HyBid.setCoppaEnabled(true);

Targeting parameters

You can add extra information to the requests the SDK makes to the ad server. This can result in higher eCPMs and more accurate ads for the users.

You can set the age, gender and some related keywords that can help improve the audience targeting in the delivered ads.

HyBid.setAge("30");
HyBid.setGender("female");
HyBid.setKeywords("sports,racket,tennis");