Audiofy SDK - Integration

Integration of Audiofy SDK consists of two major steps - adding the dependency to the application and initializing the SDK once the app is launched. Once these two steps are implemented, you can add ad units to particular place in the application.

Add Dependency

In order to integrate Audiofy SDK into your application, you should add the the following dependency to the app/build.gradle file and sync Gradle:

dependencies {
  implementation("com.mediafy:mediafy-sdk:2.4.5")
}

Add this custom maven repository URL into the project/settings.gradle file:

repositories {
    maven {
        setUrl("https://sdk-cdn.mediafy.io/android/mediafy-sdk")
    }
}

Initialize SDK

Import the Audiofy SDK core class in the main application class:

import com.mediafy.sdk.api.Mediafy

Initialize Audiofy SDK in the .onCreate() method by calling Mediafy.initializeSdk() method.

class DemoApplication : Application() {
  override fun onCreate() {
    super.onCreate()

    // Initialize Audiofy SDK
    Mediafy.initializeSdk(applicationContext, ACCOUNT_SETTINGS)
}

The Mediafy.initializeSdk() method has two parameters:

  • context - the reference to the Application subclass instance.
  • accountSettings - the unique query parameters that will be used in the request to the server. You should get these params on our Audiofy account.

At the application initialization stage, you can also provide additional contextual information that SDK will use in the ad requests. The complete list of supported contextual signals is available in the documentation for SDK Global Parameters class.

Once SDK is initialized and contextual information is provided, it is ready to request the ads.

+

Contact Us