Appstock SDK is a native library that monetizes Android applications.
The latest SDK version is 1.0.6.
The minimum supported Android version: Android 5.0 (API level 21)
Demo applications (Kotlin, JAVA).
Follow the integration instructions to add the SDK to your app. Once the SDK is integrated, you can provide configuration options that will help increase your revenue. Keep in mind that the SDK supports basic consent providers according to industry standards.
Appstock SDK supports the following ad formats:
The SDK can be integrated directly into your app or via supported Mediation Adapters:
In order to integrate Appstock SDK into your application, you should
add the following dependency to the
app/build.gradle
file and sync Gradle:
{
dependencies implementation("com.appstock:appstock-sdk:1.0.6")
}
Add this custom maven repository URL into the
project/settings.gradle
file:
{
dependencyResolutionManagement {
repositories {
maven setUrl("https://public-sdk.al-ad.com/android/")
}
}
}
Manual integration using AAR files
Copy AAR files to your Android module libs folder (f.e. app/libs/).
Add dependencies to build.gradle file.
implementation(files("libs/core-release.aar"))
implementation(files("libs/omsdk.aar"))
// Only for AdMob integration
implementation(files("libs/admob-adapters-release.aar"))
// Only for AppLovin integration
implementation(files("libs/applovin-adapters-release.aar"))
Integration using ARR files requires additional dependencies. You should add ExoPlayer dependency for video ads and Google ads identifier dependency for better targeting.
'com.google.android.exoplayer:exoplayer-core:2.15.1'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.15.1'
implementation
'com.google.android.gms:play-services-base:18.1.0'
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
implementation
"androidx.localbroadcastmanager:localbroadcastmanager:1.0.0" implementation
Import the Appstock SDK core class in the main application class:
Kotlin:
import com.appstock.sdk.api.Appstock
Java:
import com.appstock.sdk.api.Appstock;
Initialize Appstock SDK in the .onCreate()
method by
calling Appstock.initializeSdk()
.
Kotlin:
class DemoApplication : Application() {
override fun onCreate() {
super.onCreate()
// Initialize Appstock SDK
.initializeSdk(this, PARTNER_KEY)
Appstock}
}
Java:
public class DemoApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Initialize Appstock SDK
.initializeSdk(this, PARTNER_KEY);
Appstock}
}
The Appstock.initializeSdk()
method has two parameters:
context - the reference to the Application subclass instance
partnerKey - determine the Appstock server URL. The Appstock account manager should provide you with this key.
It is recommended that contextual information be provided after initialization to enrich the ad requests. For this purpose, use SDK parametrization properties.
Once SDK is initialized and all needed parameters are provided, it is ready to request the ads.
If you want to see all requests made by the SDK and verbose logs, you should enable debug mode before the initialization.
Kotlin:
.setDebugRequests(true)
Appstock.setLogLevel(Appstock.LogLevel.DEBUG)
Appstock.initializeSdk(this, PARTNER_KEY) Appstock
Java:
.setDebugRequests(true);
Appstock.setLogLevel(Appstock.LogLevel.DEBUG);
Appstock.initializeSdk(this, PARTNER_KEY); Appstock
To load and show banner ads, you should initialize, configure, and
add the AppstockAdView
object to the app’s layout and
call the loadAd()
method.
Kotlin:
private var adView: AppstockAdView? = null
private fun createAd() {
// 1. Create AppstockAdView
val adView = AppstockAdView(this).also { this.adView = it }
// 2. Configure ad unit
.setPlacementId(PLACEMENT_ID)
adView.setAdSizes(AppstockAdSize(WIDTH, HEIGHT))
adView.setAdViewListener(createListener())
adView.autoRefreshDelay = 30
adView
// 3. Load ad
.loadAd()
adView
// 4. Add AppstockAdView to the app UI
.addView(adView)
containerForAd}
Java:
private AppstockAdView adView;
private void createAd() {
// 1. Create AppstockAdView
= new AppstockAdView(this);
adView
// 2. Configure ad unit
.setPlacementId(PLACEMENT_ID);
adView.setAdSizes(new AppstockAdSize(WIDTH, HEIGHT));
adView.setAutoRefreshDelay(30);
adView.setAdViewListener(createListener());
adView
// 3. Load ad
.loadAd();
adView
// 4. Add AppstockAdView to the app UI
getContainerForAd().addView(adView);
}
The AppstockAdView
should be provided with one of the
required configuration properties:
setPlacementId()
- Unique placement identifier
generated on the Appstock platform’s UI.
setEndpointId()
- Unique endpoint identifier
generated on the Appstock platform’s UI.
Which one to use depends on your type of Appstock account.
Important note: setAdSizes()
should
provide standard advertisement sizes, not the sizes of the screen.
It’s important to destroy ad view after leaving the screen. It
cleans the resources and stops auto refresh. Or you can just stop
auto refresh using stopAutoRefresh()
.
Kotlin:
override fun onDestroy() {
?.destroy()
adView}
Java:
@Override
public void onDestroy() {
super.onDestroy();
if (adView != null) {
.destroy();
adView}
}
If you need to integrate video ads, you can also use the
AppstockAdView
object in the same way as for banner
ads. The single required change is you should explicitly set the ad
format via the respective property:
Kotlin:
.setAdUnitFormat(AppstockAdUnitFormat.VIDEO) adView
Java:
.setAdUnitFormat(AppstockAdUnitFormat.VIDEO); adView
Once it is done, the Appstock SDK will make ad requests for video placement and render the respective creatives.
Additionally, you can set more parameters for better advertisement targeting.
Kotlin:
.setAdPosition(AppstockBannerAdPosition.HEADER)
adView.setVideoPlacementType(AppstockVideoPlacementType.IN_BANNER) // Only for video ad unit format adView
Java:
.setAdPosition(AppstockBannerAdPosition.HEADER);
adView.setVideoPlacementType(AppstockVideoPlacementType.IN_BANNER); // Only for video ad unit format adView
You can optionally subscribe to the ad’s lifecycle events by
implementing the AppstockAdViewListener
interface:
Kotlin:
private fun createListener(): AppstockAdViewListener {
return object : AppstockAdViewListener {
override fun onAdLoaded(adView: AppstockAdView) {
// Called when ad loaded
.d(TAG, "Ad loaded successfully")
Log}
override fun onAdFailed(adView: AppstockAdView, e: AppstockAdException) {
// Called when ad failed to load or parse
.e(TAG, "Ad failed to load: " + e.message)
Log}
override fun onAdDisplayed(adView: AppstockAdView) {
// Called when ad displayed
}
override fun onAdClicked(adView: AppstockAdView) {
// Called when ad clicked
}
override fun onAdClosed(adView: AppstockAdView) {
// Called when ad closed
}
}
}
Java:
private static AppstockAdViewListener createListener() {
return new AppstockAdViewListener() {
@Override
public void onAdLoaded(AppstockAdView AppstockAdView) {
// Called when ad loaded
.d(TAG, "Ad loaded successfully");
Log}
@Override
public void onAdFailed(AppstockAdView AppstockAdView, AppstockAdException e) {
// Called when ad failed to load
.e(TAG, "Ad failed to load: " + e.getMessage());
Log}
@Override
public void onAdDisplayed(AppstockAdView AppstockAdView) {
// Called when ad displayed on screen
}
@Override
public void onAdClicked(AppstockAdView AppstockAdView) {
// Called when ad clicked
}
@Override
public void onAdClosed(AppstockAdView AppstockAdView) {
// Called when ad hidden
}
};
}
Or you can subscribe to the video ad events (only for video ad unit format).
Kotlin:
private fun createListener(): AppstockAdViewVideoListener {
return object : AppstockAdViewVideoListener {
override fun onVideoCompleted(bannerView: AppstockAdView?) {
.d(TAG, "Video completed")
Log}
override fun onVideoPaused(bannerView: AppstockAdView?) {
.d(TAG, "Video paused")
Log}
override fun onVideoResumed(bannerView: AppstockAdView?) {
.d(TAG, "Video resumed")
Log}
override fun onVideoUnMuted(bannerView: AppstockAdView?) {
.d(TAG, "Video unmuted")
Log}
override fun onVideoMuted(bannerView: AppstockAdView?) {
.d(TAG, "Video muted")
Log}
}
}
Java:
private static AppstockAdViewVideoListener createListener() {
return new AppstockAdViewVideoListener() {
@Override
public void onVideoCompleted(AppstockAdView teqBlazeAdView) {
.d(TAG, "Video completed");
Log}
@Override
public void onVideoPaused(AppstockAdView teqBlazeAdView) {
.d(TAG, "Video paused");
Log}
@Override
public void onVideoResumed(AppstockAdView teqBlazeAdView) {
.d(TAG, "Video resumed");
Log}
@Override
public void onVideoUnMuted(AppstockAdView teqBlazeAdView) {
.d(TAG, "Video un muted");
Log}
@Override
public void onVideoMuted(AppstockAdView teqBlazeAdView) {
.d(TAG, "Video muted");
Log}
};
}
To load and show interstitial ads, you should initialize, configure,
and add the AppstockInterstitialAdUnit
object to the
app’s layout and call the loadAd()
method. Once the ad
is loaded, you can invoke the show()
method at any
appropriate point of the app flow to present the fullscreen ad.
Kotlin:
private var adUnit: AppstockInterstitialAdUnit? = null
private fun createAd() {
// 1. Create AppstockInterstitialAdUnit
= AppstockInterstitialAdUnit(this)
adUnit
// 2. Configure ad unit
?.setPlacementId(PLACEMENT_ID)
adUnit?.setInterstitialAdUnitListener(createListener())
adUnit?.setAdSizes(AppstockAdSize(320, 480))
adUnit
// 3. Load ad
?.loadAd()
adUnit}
Java:
private AppstockInterstitialAdUnit adUnit;
private void createAd() {
// 1. Create AppstockInterstitialAdUnit
= new AppstockInterstitialAdUnit(this);
adUnit
// 2. Configure ad unit
.setPlacementId(PLACEMENT_ID);
adUnit.setInterstitialAdUnitListener(createListener());
adUnit
// 3. Load ad
.loadAd();
adUnit}
Important note: setAdSizes()
should
provide standard advertisement sizes, not the sizes of the screen.
It’s important to destroy ad unit after leaving the screen. It cleans the resources and stops auto refresh.
Kotlin:
override fun onDestroy() {
?.destroy()
adUnit}
Java:
@Override
public void onDestroy() {
super.onDestroy();
if (adUnit != null) {
.destroy();
adUnit}
}
If you need to integrate video ads or multiformat ads, you should set the adFormats property to the respective value:
Kotlin:
// Make ad request for video ad
.setAdUnitFormats(EnumSet.of(AppstockAdUnitFormat.VIDEO))
adUnit
// Make ad request for both video and banner ads (default behaviour)
.setAdUnitFormats(EnumSet.of(AppstockAdUnitFormat.BANNER, AppstockAdUnitFormat.VIDEO))
adUnit
// Make ad request for banner ad
.setAdUnitFormats(EnumSet.of(AppstockAdUnitFormat.BANNER)) adUnit
Java:
// Make ad request for video ad
.setAdUnitFormats(EnumSet.of(AppstockAdUnitFormat.VIDEO));
adUnit
// Make ad request for both video and banner ads (default behaviour)
.setAdUnitFormats(EnumSet.of(AppstockAdUnitFormat.BANNER, AppstockAdUnitFormat.VIDEO));
adUnit
// Make ad request for banner ad
.setAdUnitFormats(EnumSet.of(AppstockAdUnitFormat.BANNER)); adUnit
Once the ad is loaded, you can invoke the show()
method
at any appropriate point of the app flow to present the full-screen
ad. To know when the ad is loaded, you should implement
AppstockInterstitialAdUnitListener
interface and
subscribe to the ad events in its methods.
When the delegate’s method onAdLoaded
is called, it
means that the SDK has successfully loaded the ad. Starting from
this point, you can call the show()
method to display
the full-screen ad.
Kotlin:
private fun createListener(): AppstockInterstitialAdUnitListener {
return object : AppstockInterstitialAdUnitListener {
override fun onAdLoaded(adUnit: AppstockInterstitialAdUnit) {
// Called when ad loaded
.d(TAG, "Ad loaded successfully")
Log
// 4. Show ad
.show()
adUnit}
override fun onAdDisplayed(adUnit: AppstockInterstitialAdUnit) {
// Called when ad displayed full screen
.d(TAG, "Ad displayed")
Log}
override fun onAdFailed(
adUnit: AppstockInterstitialAdUnit,
e: AppstockAdException,
) {
// Called when ad failed to load or parse
.e(TAG, "Ad failed to load: " + e.message, e)
Log}
override fun onAdClicked(adUnit: AppstockInterstitialAdUnit) {
// Called when ad clicked
}
override fun onAdClosed(adUnit: AppstockInterstitialAdUnit) {
// Called when ad closed
}
}
}
Java:
private static AppstockInterstitialAdUnitListener createListener() {
return new AppstockInterstitialAdUnitListener() {
@Override
public void onAdLoaded(AppstockInterstitialAdUnit adUnit) {
// Called when ad loaded
.d(TAG, "Ad loaded successfully");
Log
// 4. Show ad
.show();
adUnit}
@Override
public void onAdDisplayed(AppstockInterstitialAdUnit adUnit) {
// Called when ad displayed full screen
.d(TAG, "Ad displayed");
Log}
@Override
public void onAdFailed(AppstockInterstitialAdUnit adUnit, AppstockAdException e) {
// Called when ad failed to load
.e(TAG, "Ad failed to load: " + e.getMessage());
Log}
@Override
public void onAdClicked(AppstockInterstitialAdUnit adUnit) {
// Called when ad clicked
}
@Override
public void onAdClosed(AppstockInterstitialAdUnit adUnit) {
// Called when ad closed
}
};
}
The following properties enable rendering customization of video interstitial ads.
Setter | Description |
---|---|
setIsMuted |
This option lets you switch the sound on or off during
playback. Default is false .
|
setCloseButtonArea |
This setting determines the percentage of the device screen
that the close button should cover. Allowed range -
0...1 . Default value is 0.1 .
|
setSkipButtonPosition |
This setting controls where the close button appears on the
screen. Allowed values: topLeft ,
topRight . Other values will be ignored. Default
is topRight .
|
setSkipButtonArea |
This setting determines the percentage of the device screen
that the skip button should cover. Allowed range -
0...1 . Default value is 0.1 .
|
setSkipButtonPosition |
This control sets the position of the skip button. Allowed
values: topLeft , topRight . Other
values will be ignored. Default is topLeft .
|
setSkipDelay |
This setting determines the number of seconds after the start
of playback before the skip or close button should appear.
Default value is 10.0 .
|
setIsSoundButtonVisible |
This option switches on or off the visibility of the
sound/mute button for users. Default value is
false .
|
Usage examples:
Kotlin:
.setSkipDelay(10)
adUnit.setSkipButtonPosition(AppstockPosition.TOP_RIGHT)
adUnit.setSkipButtonArea(0.2)
adUnit
.setCloseButtonPosition(AppstockPosition.TOP_RIGHT)
adUnit.setCloseButtonArea(0.2)
adUnit
.setIsMuted(true)
adUnit.setIsSoundButtonVisible(true) adUnit
Java:
.setSkipDelay(10);
adUnit.setSkipButtonPosition(AppstockPosition.TOP_RIGHT);
adUnit.setSkipButtonArea(0.2);
adUnit
.setCloseButtonPosition(AppstockPosition.TOP_RIGHT);
adUnit.setCloseButtonArea(0.2);
adUnit
.setIsMuted(true);
adUnit.setIsSoundButtonVisible(true); adUnit
To load and show rewarded ads, you should initialize, configure, and
add the AppstockRewardedAdUnit
object to the app’s
layout and call the loadAd()
method. Once the ad is
loaded, you can invoke the show()
method at any
appropriate point of the app flow to present the fullscreen ad.
Kotlin:
private var adUnit: AppstockRewardedAdUnit? = null
private fun createAd() {
// 1. Create ad unit
= AppstockRewardedAdUnit(this)
adUnit
// 2. Configure ad unit
?.setPlacementId(PLACEMENT_ID)
adUnit?.setRewardedAdUnitListener(createListener())
adUnit?.setAdSizes(AppstockAdSize(320, 480))
adUnit
// 3. Load ad
?.loadAd()
adUnit}
Java:
private AppstockRewardedAdUnit adUnit;
private void createAd() {
// 1. Create ad unit
= new AppstockRewardedAdUnit(this);
adUnit
// 2. Configure ad unit
.setPlacementId(PLACEMENT_ID);
adUnit.setRewardedAdUnitListener(createListener());
adUnit
// 3. Load ad
.loadAd();
adUnit}
Important note: setAdSizes()
should
provide standard advertisement sizes, not the sizes of the screen.
It’s important to destroy ad unit after leaving the screen. It cleans the resources and stops auto refresh.
Kotlin:
override fun onDestroy() {
?.destroy()
adUnit}
Java:
@Override
public void onDestroy() {
super.onDestroy();
if (adUnit != null) {
.destroy();
adUnit}
}
If you need to integrate video ads or multiformat ads, you should set the adFormats property to the respective value:
Kotlin:
// Make ad request for video ad
.setAdUnitFormats(EnumSet.of(AppstockAdUnitFormat.VIDEO))
adUnit
// Make ad request for both video and banner ads (default behaviour)
.setAdUnitFormats(EnumSet.of(AppstockAdUnitFormat.BANNER, AppstockAdUnitFormat.VIDEO))
adUnit
// Make ad request for banner ad
.setAdUnitFormats(EnumSet.of(AppstockAdUnitFormat.BANNER)) adUnit
Java:
// Make ad request for video ad
.setAdUnitFormats(EnumSet.of(AppstockAdUnitFormat.VIDEO));
adUnit
// Make ad request for both video and banner ads (default behaviour)
.setAdUnitFormats(EnumSet.of(AppstockAdUnitFormat.BANNER, AppstockAdUnitFormat.VIDEO));
adUnit
// Make ad request for banner ad
.setAdUnitFormats(EnumSet.of(AppstockAdUnitFormat.BANNER)); adUnit
Once the ad is loaded, you can invoke the show()
method
at any appropriate point of the app flow to present the full-screen
ad. To know when the ad is loaded, you should implement
AppstockRewardedAdUnitListener
interface and subscribe
to the ad events in its methods.
When the delegate’s method onAdLoaded
is called, it
means that the SDK has successfully loaded the ad. Starting from
this point, you can call the show()
method to display
the full-screen ad.
Kotlin:
private fun createListener(): AppstockRewardedAdUnitListener {
return object : AppstockRewardedAdUnitListener {
override fun onAdLoaded(adUnit: AppstockRewardedAdUnit) {
// Called when ad loaded
.d(TAG, "Ad loaded successfully")
Log
// 4. Show ad
.show()
adUnit}
override fun onReward(adUnit: AppstockRewardedAdUnit, reward: Reward?) {
// Called when user earned reward
if (reward == null) {
.d(TAG, "User earned empty reward!")
Logreturn
}
.d(TAG, "User earned reward: " + reward.count + " " + reward.type)
Log}
override fun onAdDisplayed(adUnit: AppstockRewardedAdUnit) {
// Called when ad displayed full screen
.d(TAG, "Ad displayed")
Log}
override fun onAdFailed(
adUnit: AppstockRewardedAdUnit,
e: AppstockAdException,
) {
// Called when ad failed to load or parse
.e(TAG, "Ad failed to load: " + e.message, e)
Log}
override fun onAdClicked(adUnit: AppstockRewardedAdUnit) {
// Called when ad clicked
}
override fun onAdClosed(adUnit: AppstockRewardedAdUnit) {
// Called when ad closed
}
}
}
Java:
private static AppstockRewardedAdUnitListener createListener() {
return new AppstockRewardedAdUnitListener() {
@Override
public void onAdLoaded(AppstockRewardedAdUnit adUnit) {
// Called when ad loaded
.d(TAG, "Ad loaded successfully");
Log
// 4. Show ad
.show();
adUnit}
@Override
public void onReward(AppstockRewardedAdUnit adUnit, @Nullable Reward reward) {
// Called when user earned reward
if (reward == null) {
.d(TAG, "User earned empty reward!");
Logreturn;
}
.d(TAG, "User earned reward: " + reward.getCount() + " " + reward.getType());
Log}
@Override
public void onAdDisplayed(AppstockRewardedAdUnit adUnit) {
// Called when ad displayed full screen
.d(TAG, "Ad displayed");
Log}
@Override
public void onAdFailed(AppstockRewardedAdUnit adUnit, AppstockAdException e) {
// Called when ad failed to load
.e(TAG, "Ad failed to load: " + e.getMessage());
Log}
@Override
public void onAdClicked(AppstockRewardedAdUnit adUnit) {
// Called when ad clicked
}
@Override
public void onAdClosed(AppstockRewardedAdUnit adUnit) {
// Called when ad closed
}
};
}
onReward
method allows to process user’s reward.
Additionally, publishers can set up the ext
JSON value
which can contain more info about reward.
Kotlin:
override fun onReward(adUnit: AppstockRewardedAdUnit, reward: Reward?) {
if (reward == null) {
.d(TAG, "User earned empty reward!")
Logreturn
}
val type = reward.type
val count = reward.count
val ext = reward.ext
}
Java:
@Override
public void onReward(AppstockRewardedAdUnit adUnit, @Nullable Reward reward) {
if (reward == null) {
.d(TAG, "User earned empty reward!");
Logreturn;
}
String type = reward.getType();
int count = reward.getCount();
= reward.getExt();
JSONObject ext }
The following properties enable rendering customization of video rewarded ads.
Setter | Description |
---|---|
setIsMuted |
This option lets you switch the sound on or off during
playback. Default is false .
|
setCloseButtonArea |
This setting determines the percentage of the device screen
that the close button should cover. Allowed range -
0...1 . Default value is 0.1 .
|
setSkipButtonPosition |
This setting controls where the close button appears on the
screen. Allowed values: topLeft ,
topRight . Other values will be ignored. Default
is topRight .
|
setSkipButtonArea |
This setting determines the percentage of the device screen
that the skip button should cover. Allowed range -
0...1 . Default value is 0.1 .
|
setSkipButtonPosition |
This control sets the position of the skip button. Allowed
values: topLeft , topRight . Other
values will be ignored. Default is topLeft .
|
setSkipDelay |
This setting determines the number of seconds after the start
of playback before the skip or close button should appear.
Default value is 10.0 .
|
setIsSoundButtonVisible |
This option switches on or off the visibility of the
sound/mute button for users. Default value is
false .
|
Usage examples:
Kotlin:
.setSkipDelay(10)
adUnit.setSkipButtonPosition(AppstockPosition.TOP_RIGHT)
adUnit.setSkipButtonArea(0.2)
adUnit
.setCloseButtonPosition(AppstockPosition.TOP_RIGHT)
adUnit.setCloseButtonArea(0.2)
adUnit
.setIsMuted(true)
adUnit.setIsSoundButtonVisible(true) adUnit
Java:
.setSkipDelay(10);
adUnit.setSkipButtonPosition(AppstockPosition.TOP_RIGHT);
adUnit.setSkipButtonArea(0.2);
adUnit
.setCloseButtonPosition(AppstockPosition.TOP_RIGHT);
adUnit.setCloseButtonArea(0.2);
adUnit
.setIsMuted(true);
adUnit.setIsSoundButtonVisible(true); adUnit
To load a native ad, you should initialize and configure
AppstockNativeAdUnit
object and call the
loadAd()
method.
Kotlin:
private var adUnit: AppstockNativeAdUnit? = null
private fun createAd() {
// 1. Create AppstockNativeAdUnit
= AppstockNativeAdUnit()
adUnit
// 2. Configure ad unit with native config
?.setPlacementId(PLACEMENT_ID)
adUnit?.setNativeAdConfig(createNativeConfig())
adUnit
// 3. Load ad
?.loadAd { result: AppstockNativeResult ->
adUnitval nativeAd = result.nativeAd
if (nativeAd == null) {
.e("AdExample", "Native ad is null: " + result.status)
Log@loadAd
return}
.d(TAG, "Native ad loaded successfully")
Log// 4. Create native view
(nativeAd)
createNativeView}
}
private fun createNativeConfig(): AppstockNativeAdConfig {
val eventTrackingMethods = ArrayList(
.asList(
Arrays.EventTrackingMethod.IMAGE,
NativeEventTracker.EventTrackingMethod.JS
NativeEventTracker)
)
val eventTracker = NativeEventTracker(
.EventType.IMPRESSION,
NativeEventTracker
eventTrackingMethods)
val title = NativeTitleAsset()
.setLength(90)
title.isRequired = true
title
val icon = NativeImageAsset(20, 20, 20, 20)
.imageType = NativeImageAsset.ImageType.ICON
icon.isRequired = true
icon
val mainImage = NativeImageAsset(200, 200, 200, 200)
.imageType = NativeImageAsset.ImageType.MAIN
mainImage.isRequired = true
mainImage
val sponsored = NativeDataAsset()
.len = 90
sponsored.dataType = NativeDataAsset.DataType.SPONSORED
sponsored.isRequired = true
sponsored
val description = NativeDataAsset()
.dataType = NativeDataAsset.DataType.DESC
description.isRequired = true
description
val ctaText = NativeDataAsset()
.dataType = NativeDataAsset.DataType.CTATEXT
ctaText.isRequired = true
ctaText
val assets = Arrays.asList(
,
title,
icon,
mainImage,
sponsored,
description
ctaText)
return AppstockNativeAdConfig.Builder()
.setContextType(NativeContextType.SOCIAL_CENTRIC)
.setPlacementType(NativePlacementType.CONTENT_FEED)
.setContextSubType(NativeContextSubtype.GENERAL_SOCIAL)
.setNativeEventTrackers(listOf(eventTracker))
.setNativeAssets(assets)
.build()
}
Java:
private AppstockNativeAdUnit adUnit;
private void createAd() {
// 1. Create AppstockNativeAdUnit
= new AppstockNativeAdUnit();
adUnit
// 2. Configure ad unit with native config
.setPlacementId(PLACEMENT_ID);
adUnit.setNativeAdConfig(createNativeConfig());
adUnit
// 3. Load ad
.loadAd((result) -> {
adUnit= result.getNativeAd();
AppstockNativeAd nativeAd if (nativeAd == null) {
.e("AdExample", "Native ad is null: " + result.getStatus());
Logreturn;
}
.d(TAG, "Native ad loaded successfully");
Log// 4. Create native view
createNativeView(nativeAd);
});
}
private AppstockNativeAdConfig createNativeConfig() {
ArrayList<NativeEventTracker.EventTrackingMethod> eventTrackingMethods = new ArrayList<>(
Arrays.asList(
.EventTrackingMethod.IMAGE,
NativeEventTracker.EventTrackingMethod.JS
NativeEventTracker)
);
= new NativeEventTracker(
NativeEventTracker eventTracker .EventType.IMPRESSION,
NativeEventTracker
eventTrackingMethods);
= new NativeTitleAsset();
NativeTitleAsset title .setLength(90);
title.setRequired(true);
title
= new NativeImageAsset(20, 20, 20, 20);
NativeImageAsset icon .setImageType(NativeImageAsset.ImageType.ICON);
icon.setRequired(true);
icon
= new NativeImageAsset(200, 200, 200, 200);
NativeImageAsset mainImage .setImageType(NativeImageAsset.ImageType.MAIN);
mainImage.setRequired(true);
mainImage
= new NativeDataAsset();
NativeDataAsset sponsored .setLen(90);
sponsored.setDataType(NativeDataAsset.DataType.SPONSORED);
sponsored.setRequired(true);
sponsored
= new NativeDataAsset();
NativeDataAsset description .setDataType(NativeDataAsset.DataType.DESC);
description.setRequired(true);
description
= new NativeDataAsset();
NativeDataAsset ctaText .setDataType(NativeDataAsset.DataType.CTATEXT);
ctaText.setRequired(true);
ctaText
List<NativeAsset> assets = Arrays.asList(
,
title,
icon,
mainImage,
sponsored,
description
ctaText);
return new AppstockNativeAdConfig.Builder()
.setContextType(NativeContextType.SOCIAL_CENTRIC)
.setPlacementType(NativePlacementType.CONTENT_FEED)
.setContextSubType(NativeContextSubtype.GENERAL_SOCIAL)
.setNativeEventTrackers(Collections.singletonList(eventTracker))
.setNativeAssets(assets)
.build();
}
The class responsible for configuration native ad parameters. Here is a brief description of parameters for the builder:
setNativeAssets
- an array of
assets associated with the native ad.
setNativeEventTrackers
- an array
of event trackers used for tracking native ad events.
setContextType
- the context type
for the native ad (e.g., content, social).
setContextSubType
- a more
detailed context in which the ad appears.
setPlacementType
- the
design/format/layout of the ad unit being offered.
setPlacementCount
- the number of
identical placements in this layout. Default is 1
.
setSequence
- the sequence number
of the ad in a series. Default is 0
.
setAUrlSupport
- whether the
supply source / impression impression supports returning an
assetsurl instead of an asset object. Default is
0
(unsupported).
setDUrlSupport
- whether the
supply source / impression supports returning a dco url instead
of an asset object. Default is 0
(unsupported).
setPrivacy
- set to 1 when the
native ad support buyer-specific privacy notice. Default is
0
.
setExt
- a dictionary to hold any
additional data as key-value pairs.
Once the ad is loaded, the SDK provides you with a
AppstockNativeAd
object in the callback of the
loadAd()
method. This object contains ad assets that
you should apply to the native ad layout.
Request asset for the advertisement title. Parameters:
length
- the length of the title.required
- flag whether the field is mandatory.
ext
- additional json data.Kotlin:
val title = NativeTitleAsset()
.setLength(90)
title.isRequired = true title
Java:
= new NativeTitleAsset();
NativeTitleAsset title .setLength(90);
title.setRequired(true); title
Request asset for any text data. Parameters:
length
- the length of the data.type
- the type of data asset (e.g., sponsored,
description).
required
- flag whether the field is mandatory.
ext
- additional json data.Kotlin:
val sponsored = NativeDataAsset()
.len = 90
sponsored.dataType = NativeDataAsset.DataType.SPONSORED
sponsored.isRequired = true sponsored
Java:
= new NativeDataAsset();
NativeDataAsset sponsored .setLen(90);
sponsored.setDataType(NativeDataAsset.DataType.SPONSORED);
sponsored.setRequired(true); sponsored
Available data types:
SPONSORED
- represents sponsored content.DESC
- represents a description.RATING
- represents a rating.LIKES
- represents likes.DOWNLOADS
- represents download count.PRICE
- represents the price.SALEPRICE
- represents a sale price.PHONE
- represents a phone number.ADDRESS
- represents an address.DESC2
- represents a secondary description.DESPLAYURL
- represents a display URL.CTATEXT
- represents call-to-action text.CUSTOM
- represents a custom data asset. You can set
custom exchange id.
Request asset for image. In the example below we request ad with desired size 200x200, and minimal size: 30x30. Parameters:
imageType
- the type of image asset (e.g., icon, main
image).
width
, height
- the desired size of the
image.
minWidth
, minHeight
- the minimum
allowed size of the image.
mimes
- an array of supported MIME types for the
image.
required
- flag whether the field is mandatory.
ext
- additional json data.Kotlin:
val mainImage = NativeImageAsset(200, 200, 30, 30)
.imageType = NativeImageAsset.ImageType.MAIN
mainImage.isRequired = true
mainImage.addMime("image/jpeg") mainImage
Java:
= new NativeImageAsset(200, 200, 200, 200);
NativeImageAsset mainImage .setImageType(NativeImageAsset.ImageType.MAIN);
mainImage.setRequired(true);
mainImage.addMime("image/jpeg") mainImage
Available data types:
ICON
- represents an icon image asset.MAIN
- represents a main image asset.CUSTOM
- represents a custom image asset.
You can also specify what type of event tracking is supported. For
that you need to set setEventTrackers
setter.
Kotlin:
val eventTrackingMethods = ArrayList(
.asList(
Arrays.EventTrackingMethod.IMAGE,
NativeEventTracker.EventTrackingMethod.JS
NativeEventTracker)
)
val eventTracker = NativeEventTracker(
.EventType.IMPRESSION,
NativeEventTracker
eventTrackingMethods)
Java:
ArrayList<NativeEventTracker.EventTrackingMethod> eventTrackingMethods = new ArrayList<>(
Arrays.asList(
.EventTrackingMethod.IMAGE,
NativeEventTracker.EventTrackingMethod.JS
NativeEventTracker)
);
= new NativeEventTracker(
NativeEventTracker eventTracker .EventType.IMPRESSION,
NativeEventTracker
eventTrackingMethods);
The event method configures desired tracking method: -
Impression
- represents an impression event.
- ViewableImpression50
- represents a 50% viewable
impression event.
- ViewableImpression100
- represents a 100% viewable
impression event.
- ViewableVideoImpression50
- represents a 50% viewable
video impression event.
- Custom
- represents a custom event type.
The event type configures desired tracking type: -
Image
- represents image-based event tracking.
- JS
- represents JavaScript-based event tracking.
- Custom
- represents a custom tracking method.
Once the ad is loaded, the SDK provides you with a
AppstockNativeAd
object in the callback of the
loadAd()
method. This object contains ad assets that
you should apply to the native ad layout.
Kotlin:
private fun createNativeView(ad: AppstockNativeAd) {
val nativeContainer = View.inflate(this, R.layout.layout_native, null)
val icon = nativeContainer.findViewById<ImageView>(R.id.imgIcon)
.download(ad.iconUrl, icon)
ImageUtils
val title = nativeContainer.findViewById<TextView>(R.id.tvTitle)
.text = ad.title
title
val image = nativeContainer.findViewById<ImageView>(R.id.imgImage)
.download(ad.imageUrl, image)
ImageUtils
val description = nativeContainer.findViewById<TextView>(R.id.tvDesc)
.text = ad.description
description
val cta = nativeContainer.findViewById<Button>(R.id.btnCta)
.text = ad.callToAction
cta
.addView(nativeContainer)
containerForAd
.registerView(nativeContainer, Lists.newArrayList(icon, title, image, description, cta), createListener())
ad}
Java:
private void createNativeView(AppstockNativeAd ad) {
View nativeContainer = View.inflate(this, R.layout.layout_native, null);
ImageView icon = nativeContainer.findViewById(R.id.imgIcon);
.download(ad.getIconUrl(), icon);
ImageUtils
= nativeContainer.findViewById(R.id.tvTitle);
TextView title .setText(ad.getTitle());
title
ImageView image = nativeContainer.findViewById(R.id.imgImage);
.download(ad.getImageUrl(), image);
ImageUtils
= nativeContainer.findViewById(R.id.tvDesc);
TextView description .setText(ad.getDescription());
description
Button cta = nativeContainer.findViewById(R.id.btnCta);
.setText(ad.getCallToAction());
ctagetContainerForAd().addView(nativeContainer);
.registerView(nativeContainer, Arrays.asList(icon, title, image, description, cta), createListener());
ad}
If you need to manage stages of the ad lifecycle you should
implement the
AppstockNativeAdUnitEventListener
interface.
Kotlin:
private fun createListener(): AppstockNativeAdUnitEventListener {
return object : AppstockNativeAdUnitEventListener {
override fun onAdImpression() {
// Called when ad displayed
.d(TAG, "Ad displayed on the screen")
Log}
override fun onAdClicked() {
// Called when ad clicked
.d(TAG, "Ad clicked")
Log}
override fun onAdExpired() {
// Called when ad expired
.d(TAG, "Ad expired")
Log}
}
}
Java:
private static AppstockNativeAdUnitEventListener createListener() {
return new AppstockNativeAdUnitEventListener() {
@Override
public void onAdImpression() {
// Called when ad displayed
.d(TAG, "Ad displayed on the screen");
Log}
@Override
public void onAdClicked() {
// Called when ad clicked
.d(TAG, "Ad clicked");
Log}
@Override
public void onAdExpired() {
// Called when ad expired
.d(TAG, "Ad expired");
Log}
};
}
AppstockTargeting
class
The AppstockTargeting
class provided a set of
properties that allow to enrich the ad request.
Method | Description | OpenRTB Field |
---|---|---|
AppstockTargeting.setPublisherName() |
App’s publisher name | app.publisher.name |
AppstockTargeting.setDomain() |
Domain of the app (e.g., mygame.foo.com ). |
app.domain |
AppstockTargeting.setStoreUrl() |
App store URL for an installed app. | app.storeurl |
AppstockTargeting.setSubjectToCOPPA() |
Integer flag indicating if this request is subject to the COPPA regulations established by the USA FTC, where 0 = no, 1 = yes | regs.coppa |
AppstockTargeting.setExternalUserId() |
App store URL for an installed app. | user.ext.eids[] |
AppstockTargeting.setUserLatLong() |
Location of the user’s home base defined by a Geo object This is not necessarily their current location. | user.geo.lat/lon |
AppstockTargeting.setUserKeywords() |
Comma separated list of keywords, interests, or intent. | user.keywords |
AppstockTargeting.setUserCustomData() |
Optional feature to pass bidder data that was set in the exchange’s cookie. The string must be in base85 cookie safe characters and be in any format. Proper JSON encoding must be used to include “escaped” quotation marks. | user.customdata |
Usage examples:
Kotlin:
.setPublisherName("appstock")
AppstockTargeting.setDomain("appstock.com")
AppstockTargeting.setStoreUrl("https://google.play.url")
AppstockTargeting.setSubjectToCOPPA(true)
AppstockTargeting.setExternalUserId(ExternalUserId("adserver.org", "111111111111", null, mapOf("rtiPartner" to "TDID")))
AppstockTargeting.setUserLatLong(35.82348f, 23.8243823f)
AppstockTargeting.setUserKeywords(setOf("cats", "hobby", "sport"))
AppstockTargeting.setUserCustomData("custom")
AppstockTargeting.initializeSdk(context, PARTNER_KEY) Appstock
Java:
.setPublisherName("appstock");
AppstockTargeting.setDomain("appstock.com");
AppstockTargeting.setStoreUrl("https://google.play.url");
AppstockTargeting.setSubjectToCOPPA(true);
AppstockTargeting.setUserLatLong(35.82348f, 23.8243823f);
AppstockTargeting.setUserCustomData("custom");
AppstockTargeting
HashMap<String, Object> externalUserIdExt = new HashMap<>();
.put("rtiPartner", "TDID");
externalUserIdExt.setExternalUserId(new ExternalUserId("adserver.org", "111111111111", null, externalUserIdExt));
AppstockTargeting
HashSet<String> keywords = new HashSet<>();
.add("cats");
keywords.add("sport");
keywords.setUserKeywords(keywords);
AppstockTargeting
.initializeSdk(context, PARTNER_KEY); Appstock
Appstock
class
Public methods:
initializeSdk
- initializes the SDK.setEndpointId
- a unique identifier generated on the
platform’s UI.
setExternalUserIds
- an array containing objects that
hold external user ID parameters.
setAssignNativeAssetId
- determines whether the asset
ID for native ads should be manually assigned.
setDebugRequests
- sets debug mode for verbose
logging of requests and responses bodies (use with
setLogLevel(LogLevel.DEBUG)
)
setLogLevel
- sets the desired verbosity level for
the SDK’s logs.
setTimeoutMillis
- set network HTTP timeout for all
requests.
setCreativeFactoryTimeout
- timeout for parsing and
render banner ads content (default: 6000).
setCreativeFactoryTimeoutPreRenderContent
- timeout
for parsing and render video ads content (default: 30000).
Kotlin:
.setEndpointId("endpoint_id")
Appstock.getAssignNativeAssetId(true)
Appstock.setDebugRequests(true)
Appstock.setLogLevel(Appstock.LogLevel.DEBUG)
Appstock
.setTimeoutMillis(3000)
Appstock.setCreativeFactoryTimeout(10000)
Appstock.setCreativeFactoryTimeoutPreRenderContent(40000)
Appstock
val externalUserIdExt = HashMap<String, Any>()
["rtiPartner"] = "TDID"
externalUserIdExtval externalUserId = ExternalUserId("adserver.org", "111111111111", null, externalUserIdExt)
.setExternalUserIds(List.of(externalUserId))
Appstock
.initializeSdk(this, PARTNER_KEY) Appstock
Java:
.setEndpointId(ENDPOINT_ID);
Appstock.getAssignNativeAssetId(true);
Appstock.setDebugRequests(true);
Appstock.setLogLevel(Appstock.LogLevel.DEBUG);
Appstock
.setTimeoutMillis(3000);
Appstock.setCreativeFactoryTimeout(10_000);
Appstock.setCreativeFactoryTimeoutPreRenderContent(40_000);
Appstock
HashMap<String, Object> externalUserIdExt = new HashMap<>();
.put("rtiPartner", "TDID");
externalUserIdExt= new ExternalUserId("adserver.org", "111111111111", null, externalUserIdExt);
ExternalUserId externalUserId .setExternalUserIds(List.of(externalUserId));
Appstock
.initializeSdk(this, PARTNER_KEY); Appstock
Appstock SDK reads consent data provided by CMPs from User Settings and sends it in the ad request. You shouldn’t do anything except to be sure that the CMP SDKs write data into particular place in the user storage defined by the IAB standards.
The following table describes which data is used by SDK and how exactly:
Storage Key | Description | |
---|---|---|
TCF v2 | ||
IABTCF_gdprApplies |
Number: 1 GDPR applies in current context 0 - GDPR does not apply in current context Unset - undetermined (default before initialization) |
regs.ext.gdpr |
IABTCF_TCString |
String: Full encoded TC string | user.ext.consent |
IABTCF_PurposeConsents |
Binary String: The ‘0’ or ‘1’ at position n – where n’s indexing begins at 0 – indicates the consent status for purpose ID n+1; false and true respectively. eg. ‘1’ at index 0 is consent true for purpose ID 1 | Defines the ability of SDK to collect device info. |
CCPA | ||
IABUSPrivacy_String |
String: Aligns with IAB OpenRTB CCPA Advisory. The String encodes all choices and information. |
regs.ext.us_privacy |
GPP | ||
IABGPP_HDR_GppString |
Full consent string in its encoded form | regs.gpp |
IABGPP_GppSID |
Section ID(s) considered to be in force. Multiple IDs are separated by underscore, e.g. “2_3” | regs.gpp_sid |
To integrate the Appstock SDK into your app, you should add the
following dependency into the app/build.gradle
file and
sync Gradle:
{
dependencies implementation("com.appstock:appstock-sdk:1.0.6")
implementation("com.appstock:appstock-sdk-google-mobile-ads-adapters:1.0.6")
}
Add this custom maven repository URL into the
project/settings.gradle
file:
{
dependencyResolutionManagement {
repositories {
maven setUrl("https://public-sdk.al-ad.com/android/")
}
}
}
Initialize Appstock SDK in the .onCreate()
method by
calling Appstock.initializeSdk()
.
Kotlin:
class DemoApplication : Application() {
override fun onCreate() {
super.onCreate()
// Initialize Appstock SDK
.initializeSdk(this, PARTNER_KEY)
Appstock}
}
Java:
public class DemoApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Initialize Appstock SDK
.initializeSdk(this, PARTNER_KEY);
Appstock}
}
In order to add Appstock to the waterfall, you need to create a custom event in your AdMob account and then add this event to the respective mediation groups.
To create a Appstock custom event, follow the instructions:
Parameters:
placement_id
or
endpoint_id
.placement_id
or
endpoint_id
.
w
field and height in
h
field. Make sure you’ve provided both width and
height values;
banner
or video
ad formats.
Note that the multiformat request is not supported for the banner
ad, so it uses only first value.
Examples:
{
"placement_id": "4",
"sizes": [
{
"w": 729,
"h": 90
}
],
"ad_formats": ["video"]
}
{
"endpoint_id": "1",
"sizes": [
{
"w": 320,
"h": 50
},
{
"w": 300,
"h": 250
}
],
"ad_formats": ["banner"]
}
Class Name: com.appstock.sdk.admob.AppstockGadMediationAdapter
After you’ve finished setting up your custom event, you’re ready to add it to a mediation group. To add your ad source to an existing mediation group:
Click Continue.
Select an existing mapping to use for this custom event or click Add mapping to set up a new mapping. To use multiple custom events, you’ll have to create an additional mapping for each custom event.
To integrate the Appstock SDK into your app, you should add the
following dependency into the app/build.gradle
file and
sync Gradle:
{
dependencies implementation("com.appstock:appstock-sdk:1.0.6")
implementation("com.appstock:appstock-sdk-ironsource-adapters:1.0.6")
}
Add this custom maven repository URL into the
project/settings.gradle
file:
{
dependencyResolutionManagement {
repositories {
maven setUrl("https://public-sdk.al-ad.com/android/")
}
}
}
Initialize Appstock SDK in the .onCreate()
method by
calling Appstock.initializeSdk()
.
Kotlin:
class DemoApplication : Application() {
override fun onCreate() {
super.onCreate()
// Initialize Appstock SDK
.initializeSdk(this, PARTNER_KEY)
Appstock}
}
Java:
public class DemoApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Initialize Appstock SDK
.initializeSdk(this, PARTNER_KEY);
Appstock}
}
In order to add Appstock to the waterfall, you need to create a custom SDK network in your IronSource account and then add this ad source to the desired ad units.
To create the Appstock SDK network, follow the instructions:
15c03f8f1
and click
Save.
After setting up the SDK network it the Appstock adapters will be automatically applied in the application using reflection.
To integrate the Appstock SDK into your app, you should add the
following dependency into the app/build.gradle
file and
sync Gradle:
{
dependencies implementation("com.appstock:appstock-sdk:1.0.6")
implementation("com.appstock:appstock-sdk-topon-adapters:1.0.6")
}
Add this custom maven repository URL into the
project/settings.gradle
file:
{
dependencyResolutionManagement {
repositories {
maven setUrl("https://public-sdk.al-ad.com/android/")
}
}
}
Initialize Appstock SDK in the .onCreate()
method by
calling Appstock.initializeSdk()
.
Kotlin:
class DemoApplication : Application() {
override fun onCreate() {
super.onCreate()
// Initialize Appstock SDK
.initializeSdk(this, PARTNER_KEY)
Appstock}
}
Java:
public class DemoApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Initialize Appstock SDK
.initializeSdk(this, PARTNER_KEY);
Appstock}
}
In order to add Appstock to the waterfall, you need to create a custom mediation network in your TopOn account and then add this ad source to the desired placement.
To create the Appstock ad source, follow the instructions:
Fields for Other Parameters:
Example:
{
"placement_id": "5"
}
For the banner ad type it’s important to set the size of TopOn banner based on screen size and the standardized ad size for Appstock banner (f.e. 320x50, 300x250, 728x90).
val width = 320
val height = 50
val adView = ATBannerView(this)
val localExtras = HashMap<String, Any>()
[ATAdConst.KEY.AD_WIDTH] = resources.displayMetrics.widthPixels
localExtras[ATAdConst.KEY.AD_HEIGHT] = height * resources.displayMetrics.density
localExtras[AppstockBannerAdapter.KEY_WIDTH] = width
localExtras[AppstockBannerAdapter.KEY_HEIGHT] = height
localExtras.setLocalExtra(localExtras) adView
int width = 320;
int height = 50;
= new ATBannerView(this);
ATBannerView adView
HashMap<String, Object> localExtras = new HashMap<>();
.put(ATAdConst.KEY.AD_WIDTH, getResources().getDisplayMetrics().widthPixels);
localExtras.put(ATAdConst.KEY.AD_HEIGHT, height * getResources().getDisplayMetrics().density);
localExtras.put(AppstockBannerAdapter.KEY_WIDTH, width);
localExtras.put(AppstockBannerAdapter.KEY_HEIGHT, height);
localExtras.setLocalExtra(localExtras); adView
The interstitial ad type doesn’t require any additional setup in code. You just have to add the Appstock mediation for the interstitial ad unit in the TopOn server.
For the native ad unit it’s important to add native assets.
private fun createAd() {
// 1. Create ad unit
val adUnit = ATNative(this, AD_UNIT_ID, createListener()).also { adUnit = it }
// 2. Configure ad unit with native config
val localExtras = HashMap<String, Any>()
[AppstockNativeAdConfig.KEY_EXTRAS] = createNativeConfig()
localExtras.setLocalExtra(localExtras)
adUnit
// 3. Load ad
.makeAdRequest()
adUnit}
private fun createNativeConfig(): AppstockNativeAdConfig {
val eventTrackingMethods = ArrayList(
.asList(
Arrays.EventTrackingMethod.IMAGE,
NativeEventTracker.EventTrackingMethod.JS
NativeEventTracker)
)
val eventTracker = NativeEventTracker(
.EventType.IMPRESSION,
NativeEventTracker
eventTrackingMethods)
val title = NativeTitleAsset()
.setLength(90)
title.isRequired = true
title
val icon = NativeImageAsset(20, 20, 20, 20)
.imageType = NativeImageAsset.ImageType.ICON
icon.isRequired = true
icon
val mainImage = NativeImageAsset(200, 200, 200, 200)
.imageType = NativeImageAsset.ImageType.MAIN
mainImage.isRequired = true
mainImage
val sponsored = NativeDataAsset()
.len = 90
sponsored.dataType = NativeDataAsset.DataType.SPONSORED
sponsored.isRequired = true
sponsored
val description = NativeDataAsset()
.dataType = NativeDataAsset.DataType.DESC
description.isRequired = true
description
val ctaText = NativeDataAsset()
.dataType = NativeDataAsset.DataType.CTATEXT
ctaText.isRequired = true
ctaText
val assets = Arrays.asList(
,
title,
icon,
mainImage,
sponsored,
description
ctaText)
return AppstockNativeAdConfig.Builder()
.setContextType(NativeContextType.SOCIAL_CENTRIC)
.setPlacementType(NativePlacementType.CONTENT_FEED)
.setContextSubType(NativeContextSubtype.GENERAL_SOCIAL)
.setNativeEventTrackers(listOf(eventTracker))
.setNativeAssets(assets)
.build()
}
private void createAd() {
// 1. Create ad unit
= new ATNative(this, AD_UNIT_ID, createListener());
adUnit
// 2. Configure ad unit with native config
HashMap<String, Object> localExtras = new HashMap<>();
.put(AppstockNativeAdConfig.KEY_EXTRAS, createNativeConfig());
localExtras.setLocalExtra(localExtras);
adUnit
// 3. Load ad
.makeAdRequest();
adUnit}
private AppstockNativeAdConfig createNativeConfig() {
ArrayList<NativeEventTracker.EventTrackingMethod> eventTrackingMethods = new ArrayList<>(
Arrays.asList(
.EventTrackingMethod.IMAGE,
NativeEventTracker.EventTrackingMethod.JS
NativeEventTracker)
);
= new NativeEventTracker(
NativeEventTracker eventTracker .EventType.IMPRESSION,
NativeEventTracker
eventTrackingMethods);
= new NativeTitleAsset();
NativeTitleAsset title .setLength(90);
title.setRequired(true);
title
= new NativeImageAsset(20, 20, 20, 20);
NativeImageAsset icon .setImageType(NativeImageAsset.ImageType.ICON);
icon.setRequired(true);
icon
= new NativeImageAsset(200, 200, 200, 200);
NativeImageAsset mainImage .setImageType(NativeImageAsset.ImageType.MAIN);
mainImage.setRequired(true);
mainImage
= new NativeDataAsset();
NativeDataAsset sponsored .setLen(90);
sponsored.setDataType(NativeDataAsset.DataType.SPONSORED);
sponsored.setRequired(true);
sponsored
= new NativeDataAsset();
NativeDataAsset description .setDataType(NativeDataAsset.DataType.DESC);
description.setRequired(true);
description
= new NativeDataAsset();
NativeDataAsset ctaText .setDataType(NativeDataAsset.DataType.CTATEXT);
ctaText.setRequired(true);
ctaText
List<NativeAsset> assets = Arrays.asList(
,
title,
icon,
mainImage,
sponsored,
description
ctaText);
return new AppstockNativeAdConfig.Builder()
.setContextType(NativeContextType.SOCIAL_CENTRIC)
.setPlacementType(NativePlacementType.CONTENT_FEED)
.setContextSubType(NativeContextSubtype.GENERAL_SOCIAL)
.setNativeEventTrackers(Collections.singletonList(eventTracker))
.setNativeAssets(assets)
.build();
}
To integrate the Appstock SDK into your app, you should add the
following dependency into the app/build.gradle
file and
sync Gradle:
{
dependencies implementation("com.appstock:appstock-sdk:1.0.6")
implementation("com.appstock:appstock-sdk-applovin-adapters:1.0.6")
}
Add this custom maven repository URL into the
project/settings.gradle
file:
{
dependencyResolutionManagement {
repositories {
maven setUrl("https://public-sdk.al-ad.com/android/")
}
}
}
Initialize Appstock SDK in the .onCreate()
method by
calling Appstock.initializeSdk()
.
Kotlin:
class DemoApplication : Application() {
override fun onCreate() {
super.onCreate()
// Initialize Appstock SDK
.initializeSdk(this, PARTNER_KEY)
Appstock}
}
Java:
public class DemoApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Initialize Appstock SDK
.initializeSdk(this, PARTNER_KEY);
Appstock}
}
To integrate the Appstock into your AppLovin monetization stack, you should enable a Appstock SDK ad network and add it to the respective ad units.
Add the information about your custom network:
Network Type : Choose SDK.
Name : Appstock.
Android Adapter Class Name:
com.applovin.mediation.adapters.AppstockAppLovinMediationAdapter
Typically, the custom parameters field should contain a JSON that contains IDs (placement ID, endpoint ID) that will be used to load ads.
Parameters:
placement_id
or
endpoint_id
.
placement_id
or
endpoint_id
.
w
field and height in
h
field. Make sure you’ve provided both width and
height values;
banner
or video
ad formats.
Note that the multiformat request is not supported for the banner
ad, so it uses only first value.
Examples:
{
"placement_id": "4",
"sizes": [
{
"w": 729,
"h": 90
}
],
"ad_formats": ["video"]
}
{
"endpoint_id": "1",
"sizes": [
{
"w": 320,
"h": 50
},
{
"w": 300,
"h": 250
}
],
"ad_formats": ["banner"]
}