Skip to content

adpushup/ApMobileSDKDemo

Repository files navigation

Getting Started Guide

Get started

Release version: 1.9.5 | Release date: 26.11.2024

Follow this guide to get started with Ap Mobile SDK.

The Ap Mobile SDK allows you to add multiple demand sources in your app and makes them compete against each other in real-time auctions, maximizing your ad revenues.

The following document shows how to integrate Ap Mobile SDK in your Android App.

You can use our demo apps as a reference project.

📎 Demo Apps Link: https://github.com/adpushup/ApMobileSDKDemo

Before you begin

To prepare your app, complete the steps in the following sections.

App prerequisites

  • Use Android Studio Dolphin (2021.3.1) or higher
  • Make sure that your app's build file uses the following values:
    • minSdkVersion of 21 or higher
    • compileSdkVersion of 34 or higher
  • Requires java 17 or higher
  • (Important) Get the following IDs from AdPushup:
    • Ad Manager App Id: For Android Manifest File.
    • Ap App Id: Used in initializing Ap Mobile SDK.
    • Ap Placement Ids: Each Ad Unit has a unique placement Id.

Configure your app

  1. In your Gradle settings file, include the Google's Maven repository, Maven central repository, and Jitpack.io repository, normally settings.gradle:

    pluginManagement {
        repositories {
            google()
            mavenCentral()
            maven { url 'https://jitpack.io' }
            gradlePluginPortal()
        }
    }
    
    dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
            maven { url 'https://jitpack.io' }
        }
    }
    
    rootProject.name = "My Application"
    include ':app'
  2. Add the dependencies for the Ap Mobile SDK and Google Mobile Ads SDK to your module's app-level Gradle file, normally app/build.gradle:

    dependencies {
      implementation 'com.adpushup:apmobilesdk:1.9.5'
      implementation 'com.google.android.gms:play-services-ads:23.2.0'
    }
  3. Add your Ad manager app ID (provided by AdPushup) to your app’s AndroidManifest.xml file. To do so, add a <meta-data> tag with android:name="com.google.android.gms.ads.APPLICATION_ID". For android:value, insert your own Ad manager app ID, surrounded by quotation marks.

    <manifest>
        <application>
            <!-- Ad Manager app ID will be provided by AdPushup -->
            <meta-data
                android:name="com.google.android.gms.ads.APPLICATION_ID"
                android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
        </application>
    </manifest>

Initialize the Ap Mobile SDK

Before loading ads, have your app initialize the Ap Mobile SDK by calling ApMobileSdk.init() which initializes the SDK and calls back a completion listener once initialization is complete. This needs to be done only once, ideally at the app launch.

Ads may be preloaded by the Ap Mobile SDK upon calling ApMobileSdk.init(). If you need to obtain consent from users in the European Economic Area (EEA), or otherwise take action before loading ads, ensure you do so before initializing the Ap Mobile SDK.

Here's an example of how to call the init() method in an Activity:

Kotlin Example:

import com.adpushup.apmobilesdk.ApMobileSdk

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
				
	    // apAppId is your app ID in AdPushUp. It will be provided to you by AdPushup.
        ApMobileSdk.init(this, "apAppId")
    }
}

JAVA Example:

import com.adpushup.apmobilesdk.ApMobileSdk;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // apAppId is your app ID in AdPushUp. It will be provided to you by AdPushup.
        ApMobileSdk.init(this, "apAppId");
    }
}

(Important) Additinal Steps - For Proper SDK Functioning

Ap Mobile Sdk may try to preload ads when app resumes from background or user navigates between multiple screens. To keep ads preloaded so that they can be shown instantly, you must call ApMobileSdk.resume() method.

Here's an example of how to call the resume() method in an Activity:

Kotlin Example:

import com.adpushup.apmobilesdk.ApMobileSdk

class MainActivity : AppCompatActivity() {
    override fun onResume() {
        super.onResume()
        // Inform Sdk about Activty's Resume Event
        ApMobileSdk.resume(this)
    }
}

JAVA Example:

import com.adpushup.apmobilesdk.ApMobileSdk;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onResume() {
        super.onResume();
        // Inform Sdk about Activty's Resume Event
        ApMobileSdk.resume(this);
    }
}

Implementing ads to your app

Banner Ads

Adaptive Banner Ads

Interstitial Ads

Rewarded Ads

Rewarded Interstitial Ads

Native Ads

In-Stream Ads

ApVideo

App Open Ads


Debugging Tools

Ap SDK provides ApMobileSdk.enableDebugging() function to enable debugging logs for the SDK. Once enabled, SDK will print debug Logs in your Android Studio's Logcat.

Its advisable to only enable debugging in Test environments. You must disable debugging after completing the tests.

Here's an example of how to call the enableDebugging() method in an Activity:

Kotlin Example:

import com.adpushup.apmobilesdk.ApMobileSdk

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // Enable Debugging
        ApMobileSdk.enableDebugging(this, true)

		// Initialise SDK		
	    ApMobileSdk.init(this, "apAppId")
    }
}

JAVA Example:

import com.adpushup.apmobilesdk.ApMobileSdk;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Enable Debugging
        ApMobileSdk.enableDebugging(this, true);

		// Initialise SDK		
        ApMobileSdk.init(this, "apAppId");
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages