HyBid Configuration - pubnative/pubnative-hybid-android-sdk GitHub Wiki
Requirements:
- PubNative App Token from the PubNative Publisher Dashboard
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, MoPub adapter and DFP Adapter dependencies to the module level build.gradle file:
implementation 'net.pubnative:hybid.sdk:3.1.0'
implementation 'net.pubnative:hybid.adapters.dfp:3.1.0'
MoPub and DFP adapters are optional. Just use them if you plan to use HyBid through the mediation of any of these networks.
To enable the basic features of the HyBid 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" />
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);
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.** { *; }
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);
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);
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
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);
By default all video ads will start on. Alternatively you can define the default behaviour for all videos in delivered via HyBid SDK.
HyBid.setVideoAudioStatus(AudioState.MUTED);
The audio can have the following three states:
- DEFAULT (Video start muted or not depending of the current audio settings of the device)
- ON (Video always starts with audio)
- MUTED (Video always starts muted)
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");