Skip to content

Commit

Permalink
Prodege Android IronSource Adapter v7.0.0-beta01.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Fotis Mitropoulos committed Oct 27, 2023
1 parent 65d8633 commit 11d8a9d
Show file tree
Hide file tree
Showing 34 changed files with 664 additions and 408 deletions.
116 changes: 80 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,26 @@
# Pollfish Android IronSource Mediation Adapter
# Prodege Android IronSource Mediation Adapter

IronSource Mediation Adapter for Android apps looking to load and show Rewarded Surveys from Pollfish in the same waterfall with other Rewarded Ads.
IronSource Mediation Adapter for Android apps looking to load and show Rewarded ads from Prodege in the same waterfall with other Rewarded Ads.

> **Note:** A detailed step by step guide is provided on how to integrate can be found [here](https://www.pollfish.com/docs/android-ironsource-adapter)
<br/>

## Step 1: Add Pollfish IronSource Adapter to your project
## Add Prodege IronSource Adapter to your project

Download the following libraries

* [Pollfish SDK](https://www.pollfish.com/docs/android/google-play)
* [IronSource SDK](https://developers.is.com/ironsource-mobile/android/android-sdk/)
* [PollfishIronSourceAdapter](https://pollfish.com/docs/android-ironsource-adapter)

Import Pollfish IronSource adapter **.aar** file as it can be found in the **pollfish-ironsource-aar** folder, into your project libraries. Also import the **pollfish-googleplay-xxx.aar** which can be found [here](https://pollfish.com/docs/android/google-play)

If you are using Android Studio, right click on your project and select New Module. Then select Import .jar or .aar Package option and from the file browser locate Pollfish IronSource Adapter aar file. Right click again on your project and in the Module Dependencies tab choose to add Pollfish module that you recently added, as a dependency.

**OR**

#### **Retrieve Pollfish IronSource Adapter through mavenCentral()**

Retrieve Pollfish IronSource Adapter through **mavenCentral()** with gradle by adding the following line in your project **build.gradle** (not the top level one, the one under 'app') in dependencies section:
Retrieve Prodege IronSource Adapter through **maven()** with gradle by adding the following line in your app's module **build.gradle** file:

```groovy
dependencies {
implementation 'com.pollfish.mediation:pollfish-ironsource:6.4.0.0'
implementation 'com.pollfish.mediation:prodege-ironsource:7.0.0-beta01.0'
}
```

<br/>

## Step 2: Request for a RewardedAd
## Request for a RewardedAd

Import the following packages
Import the following packages.

<span style="text-decoration:underline">Kotlin</span>

Expand All @@ -56,9 +42,7 @@ import com.ironsource.mediationsdk.model.Placement;
import com.ironsource.mediationsdk.sdk.RewardedVideoListener;
```

<br/>

Initialize IronSource SDK by calling the `init` method, passing the `Activity` and your App Key as provided by the IronSource dashboard. Do this as soon as possible after your app starts, for example in the `onCreate()` method of your launch Activity.
<br/>Initialize IronSource SDK by calling the `init` method, passing the `Activity` and your App Key as provided by the IronSource dashboard. Do this as soon as possible after your app starts, for example in the `onCreate()` method of your launch Activity.

<span style="text-decoration:underline">Kotlin</span>

Expand Down Expand Up @@ -120,29 +104,29 @@ if (IronSource.isRewardedVideoAvailable())

<br/>

You can view a short example on how to intergate rewarded ads below
You can view a short example on how to intergate rewarded ads below.

<span style="text-decoration:underline">Kotlin</span>

```kotlin
class MainActivity : AppCompatActivity(), RewardedVideoListener {

override fun onCreate(savedInstanceState: Bundle?) {
...
// ...

IntegrationHelper.validateIntegration(this)
IronSource.setRewardedVideoListener(this)
IronSource.init(this, "APP_KEY")
}

override fun onResume() {
...
// ...

IronSource.onResume(this)
}

override fun onPause() {
...
// ...

IronSource.onPause(this)
}
Expand Down Expand Up @@ -178,7 +162,7 @@ class MainActivity extends AppCompatActivity implements RewardedVideoListener {

@Override
protected void onCreate(Bundle savedInstanceState) {
...
// ...

IntegrationHelper.validateIntegration(this);
IronSource.setRewardedVideoListener(this);
Expand All @@ -187,14 +171,14 @@ class MainActivity extends AppCompatActivity implements RewardedVideoListener {

@Override
protected void onResume() {
...
// ...

IronSource.onResume(this);
}

@Override
protected void onPause() {
...
// ...

IronSource.onPause(this);
}
Expand Down Expand Up @@ -233,18 +217,78 @@ class MainActivity extends AppCompatActivity implements RewardedVideoListener {

<br/>

## Step 3: Publish
## Configure the Prodege SDK programmatically

Prodege IronSource Adapter provided a couple of options you can use to control the behaviour of Prodege SDK. Any configuration, if applied, will override the corresponding configuration done in IronSource's dashboard.

### **6.1. `.setUserId(String)`**

An optional id used to identify a user.

Setting the Prodege's `userId` will override the default behaviour and use that instead of the Advertising Id in order to identify a user.

> **Note:** <span style="color: red">You can pass the id of a user as identified on your system. Prodege will use this id to identify the user across sessions instead of an ad id/idfa as advised by the stores. You are solely responsible for aligning with store regulations by providing this id and getting relevant consent by the user when necessary. Prodege takes no responsibility for the usage of this id. In any request from your users on resetting/deleting this id and/or profile created, you should be solely liable for those requests.</span>
<span style="text-decoration:underline">Kotlin</span>

```kotlin
ProdegeCustomAdapter.setUserId("USER_ID")
```

<span style="text-decoration:underline">Java</span>

```java
ProdegeCustomAdapter.setUserId("USER_ID");
```

<br/>

### **6.2. `.setTestMode(Boolean)`**

- **`true`** is used to show to the developer how Prodege ads will be shown through an app (useful during development and testing).
- **`false`** is the mode to be used for a released app in any app store (start receiving paid surveys).

If you have already specified the test mode on IronSource's UI, this will override the one defined on Web UI.

Prodege IronSource Adapter works by default in live mode. If you would like to test with test ads:

<span style="text-decoration:underline">Kotlin</span>

```kotlin
ProdegeCustomAdapter.setTestMode(true)
```

<span style="text-decoration:underline">Java</span>

```java
ProdegeCustomAdapter.setTestMode(true);
```

<br/>

## Proguard

If you use proguard with your app, please insert the following lines in your proguard configuration file:

```java
-dontwarn com.prodege.**
-keep class com.prodege.** { *; }
```

<br/>

## Publish

If you everything worked fine during the previous steps, you should turn Pollfish to release mode and publish your app.
If everything worked fine during the previous steps, you are ready to proceed with publishing your app.

> **Note:** After you take your app live, you should request your account to get verified through Pollfish Dashboard in the App Settings area.
> **Note:** After you take your app live, you should request your account to get verified through the [Publisher Dashboard](https://www.pollfish.com/publisher/) in the App Settings area.
> **Note:** There is an option to show **Standalone Demographic Questions** needed for Pollfish to target users with surveys even when no actually surveys are available. Those surveys do not deliver any revenue to the publisher (but they can increase fill rate) and therefore if you do not want to show such surveys in the Waterfall you should visit your **App Settings** are and disable that option.
> **Note:** There is an option to show **Standalone Demographic Questions** needed for Prodege to target users with surveys even when no actually surveys are available. Those surveys do not deliver any revenue to the publisher (but they can increase fill rate) and therefore if you do not want to show such surveys in the Waterfall you should visit your **App Settings** are and disable that option. You can read more [here](https://www.pollfish.com/docs/demographic-surveys).
# More info

You can read more info on how the Pollfish SDKs work or how to get started with IronSource at the following links:

[Pollfish iOS SDK](https://pollfish.com/docs/android/google-play)
[Prodege iOS SDK](https://pollfish.com/docs/android)

[IronSource iOS SDK](https://developers.is.com/ironsource-mobile/android/android-sdk)
15 changes: 11 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
id 'com.android.application' version '8.1.2' apply false
id 'com.android.library' version '8.1.2' apply false
id 'org.jetbrains.kotlin.android' version '1.9.10' apply false
id "io.codearte.nexus-staging" version "0.30.0"
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}

ext {
prodegeSdkVersion = "7.0.0-beta01"
adapterVersionCode = 7
adapterVersionName = "${prodegeSdkVersion}.0"
ironSourceSdkVersion = "7.2.2.1"
}
14 changes: 8 additions & 6 deletions example-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ plugins {
}

android {
compileSdk 33
compileSdk 34

defaultConfig {
applicationId "com.pollfish.mediation.ironsource.example"
applicationId "com.prodege.mediation.ironsource.example"
minSdk 21
targetSdk 33
targetSdk 34
versionCode 1
versionName "1.0"
}
Expand All @@ -23,13 +23,15 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
namespace 'com.prodege.mediation.ironsource.example'
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.10.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

implementation 'com.ironsource.sdk:mediationsdk:7.2.2.1'
implementation project(':pollfish-ironsource')
implementation 'com.pollfish:prodege:7.0.0-beta01'
implementation project(':prodege-ironsource')
}
3 changes: 1 addition & 2 deletions example-java/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ironsource.mediation.ironsource.example">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
package com.ironsource.mediation.ironsource.example;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.ironsource.adapters.custom.prodege.ProdegeCustomAdapter;
import com.ironsource.mediationsdk.IronSource;
import com.ironsource.mediationsdk.integration.IntegrationHelper;
import com.ironsource.mediationsdk.logger.IronSourceError;
import com.ironsource.mediationsdk.model.Placement;
import com.ironsource.mediationsdk.sdk.RewardedVideoListener;
import com.prodege.mediation.ironsource.example.R;

public class MainActivity extends AppCompatActivity implements RewardedVideoListener {

private static final String TAG = MainActivity.class.getSimpleName();
// TODO: Place your App Key here
private static final String APP_KEY = "APP_KEY";

private Button mRewardedAdButton;
private Placement mPlacement;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -35,7 +35,12 @@ protected void onCreate(Bundle savedInstanceState) {
private void initIronSource() {
IntegrationHelper.validateIntegration(this);
IronSource.setRewardedVideoListener(this);
IronSource.init(this, APP_KEY);

// Optional
ProdegeCustomAdapter.setTestMode(true);
ProdegeCustomAdapter.setUserId("USER_ID");

IronSource.init(this, getString(R.string.iron_source_app_id));
}

@Override
Expand Down Expand Up @@ -70,14 +75,6 @@ private void onShowRewardedAdClick() {
IronSource.showRewardedVideo();
}

private void showToastMessage(Placement placement) {
Toast.makeText(
this,
"You've received " + placement.getRewardAmount() + " " + placement.getRewardName(),
Toast.LENGTH_SHORT
).show();
}

@Override
public void onRewardedVideoAdOpened() {
Log.d(TAG, "onRewardedVideoAdOpened");
Expand All @@ -86,19 +83,13 @@ public void onRewardedVideoAdOpened() {
@Override
public void onRewardedVideoAdClosed() {
Log.d(TAG, "onRewardedVideoAdClosed");

if (mPlacement != null) {
showToastMessage(mPlacement);
mPlacement = null;
}

initIronSource();
}

@Override
public void onRewardedVideoAvailabilityChanged(boolean available) {
handleVideoButtonState(available);
Log.d(TAG, "onRewardedVideoAvailabilityChanged $available");
Log.d(TAG, String.format("onRewardedVideoAvailabilityChanged: %s", available ? "Available" : "Unavailable"));
}

@Override
Expand All @@ -113,8 +104,14 @@ public void onRewardedVideoAdEnded() {

@Override
public void onRewardedVideoAdRewarded(Placement placement) {
Log.d(TAG, "onRewardedVideoAdRewarded $placement");
mPlacement = placement;
@SuppressLint("DefaultLocale") String message =
String.format("onRewardedVideoAdRewarded: %d %s", placement.getRewardAmount(), placement.getRewardName());
Toast.makeText(
this,
message,
Toast.LENGTH_SHORT
).show();
Log.d(TAG, message);
}

@Override
Expand All @@ -123,6 +120,8 @@ public void onRewardedVideoAdShowFailed(IronSourceError ironSourceError) {
}

@Override
public void onRewardedVideoAdClicked(Placement placement) {}
public void onRewardedVideoAdClicked(Placement placement) {
Log.d(TAG, "onRewardedVideoAdClicked");
}

}
1 change: 1 addition & 0 deletions example-java/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<resources>
<string name="app_name">Android IronSource Adapter</string>
<string name="show_rewarded_ad_button_text">Show Rewarded Ad</string>
<string name="iron_source_app_id">APP_ID</string>
</resources>
Loading

0 comments on commit 11d8a9d

Please sign in to comment.