Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ builtins
/debug.keystore.pass.txt
/.editor_settings
/.vscode
*.eclipse.buildship.core.prefs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zed adds such files when edit java

15 changes: 15 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The extension can be configured by adding the following fields to `game.project`
[admob]
app_id_ios = ca-app-pub-3940256099942544~1458002511
app_id_android = ca-app-pub-3940256099942544~3347511713
test_ads_in_debug = 1
app_open_android = ca-app-pub-3940256099942544/9257395921
app_open_ios = ca-app-pub-3940256099942544/5575463023
ios_tracking_usage_description = Your data will be used to provide you a better and personalized ad experience.
Expand All @@ -39,6 +40,9 @@ This is your iOS AdMob app ID. An app ID is a unique ID number assigned to your
### app_id_android
This is your Android AdMob app ID. An app ID is a unique ID number assigned to your apps when they're added to AdMob. The app ID is used to identify your apps.

### test_ads_in_debug
Android only. When set to `1`, the extension enables test ads in non-release builds.

### app_open_android
Ad unit to use for App Open ads on Android. If this value is set App Open Ads will be shown when the app is brought to the foreground.

Expand All @@ -52,6 +56,17 @@ Before requesting the unique IDFA string for a device on iOS 14 the application
Apple documentation: https://developer.apple.com/documentation/apptrackingtransparency?language=objc


## Mediation (Android)

For now mediation is supported on Android only. To enable it:

- Enable the adapters you need in the `[admob]` section of `game.project` (for example `unity_android = 1`).
- Follow [each network’s official mediation guide](https://developers.google.com/admob/android/mediation/applovin) end-to-end. There is no partial “adapter added but not initialized” state.
- You must use your own ad unit IDs. Google’s demo IDs only show Google ads and won’t exercise mediation.
- If something is missing in the dashboard configuration, there may be no logs or Ad Inspector hints; when it is correct it simply reports as working.
- For testing the AdMob network, set `admob.test_ads_in_debug = 1` to mark the device as a test device in debug builds.
- The extension supports all officially supported adapters, except for Chartboost.

## Usage

### Setup
Expand Down
65 changes: 64 additions & 1 deletion extension-admob/ext.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[admob]
group = Runtime
title = AdMob
group = Runtime
help = Settings for AdMob extension

app_id_ios.type = string
Expand All @@ -9,9 +9,72 @@ app_id_ios.label = App ID iOS
app_id_android.type = string
app_id_android.label = App ID Android

test_ads_in_debug.type = bool
test_ads_in_debug.label = Testable In Debug

app_open_android.type = string

app_open_ios.type = string
app_open_ios.label = App Open iOS

ios_tracking_usage_description.type = string

applovin_android.type = bool
applovin_android.label = AppLovin Android
applovin_android.private = 1

dt_exchange_android.type = bool
dt_exchange_android.label = DT Exchange Android
dt_exchange_android.private = 1

imobile_android.type = bool
imobile_android.label = i-mobile Android
imobile_android.private = 1

inmobi_android.type = bool
inmobi_android.label = InMobi Android
inmobi_android.private = 1

ironsource_android.type = bool
ironsource_android.label = ironSource Android
ironsource_android.private = 1

liftoff_android.type = bool
liftoff_android.label = Liftoff Monetize (Vungle) Android
liftoff_android.private = 1

line_android.type = bool
line_android.label = Line Ads Android
line_android.private = 1

maio_android.type = bool
maio_android.label = maio Android
maio_android.private = 1

meta_android.type = bool
meta_android.label = Meta Android
meta_android.private = 1

mintegral_android.type = bool
mintegral_android.label = Mintegral Android
mintegral_android.private = 1

moloco_android.type = bool
moloco_android.label = Moloco Android
moloco_android.private = 1

mytarget_android.type = bool
mytarget_android.label = MyTarget Android
mytarget_android.private = 1

pangle_android.type = bool
pangle_android.label = Pangle Android
pangle_android.private = 1

pubmatic_android.type = bool
pubmatic_android.label = PubMatic Android
pubmatic_android.private = 1

unity_android.type = bool
unity_android.label = Unity Ads Android
unity_android.private = 1
91 changes: 89 additions & 2 deletions extension-admob/manifests/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,98 @@
// Auto-generated by updater/android.py. Do not edit by hand.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generator is the key here, it helps to reduce maintenance burden

repositories {
mavenCentral()
google()
{{#admob.chartboost_android}}
maven { url 'https://cboost.jfrog.io/artifactory/chartboost-ads/' }
{{/admob.chartboost_android}}
{{#admob.imobile_android}}
maven { url 'https://imobile.github.io/adnw-sdk-android'}
{{/admob.imobile_android}}
{{#admob.ironsource_android}}
maven { url 'https://android-sdk.is.com/'}
{{/admob.ironsource_android}}
{{#admob.maio_android}}
maven { url 'https://imobile-maio.github.io/maven'}
{{/admob.maio_android}}
{{#admob.mintegral_android}}
maven { url 'https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea'}
{{/admob.mintegral_android}}
{{#admob.pangle_android}}
maven { url 'https://artifact.bytedance.com/repository/pangle/'}
{{/admob.pangle_android}}
{{#admob.pubmatic_android}}
maven { url 'https://repo.pubmatic.com/artifactory/public-repos'}
{{/admob.pubmatic_android}}
}

dependencies {
// https://developers.google.com/admob/android/quick-start#example_app-level_buildgradle_excerpt
implementation "com.google.android.gms:play-services-ads:24.5.0"
implementation "com.google.android.gms:play-services-ads:24.9.0"
implementation "androidx.lifecycle:lifecycle-common:2.8.3"
implementation "androidx.lifecycle:lifecycle-process:2.8.3"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.8.3"

{{#admob.applovin_android}}
implementation 'com.google.ads.mediation:applovin:13.5.1.0'
{{/admob.applovin_android}}

{{#admob.chartboost_android}}
implementation 'com.google.ads.mediation:chartboost:9.11.0.0'
{{/admob.chartboost_android}}

{{#admob.dt_exchange_android}}
implementation 'com.google.ads.mediation:fyber:8.4.2.0'
{{/admob.dt_exchange_android}}

{{#admob.imobile_android}}
implementation 'com.google.ads.mediation:imobile:2.3.2.1'
{{/admob.imobile_android}}

{{#admob.inmobi_android}}
implementation 'com.google.ads.mediation:inmobi:11.1.0.0'
{{/admob.inmobi_android}}

{{#admob.ironsource_android}}
implementation 'com.google.ads.mediation:ironsource:9.2.0.0'
{{/admob.ironsource_android}}

{{#admob.liftoff_android}}
implementation 'com.google.ads.mediation:vungle:7.6.3.0'
{{/admob.liftoff_android}}

{{#admob.line_android}}
implementation 'com.google.ads.mediation:line:3.0.0.0'
{{/admob.line_android}}

{{#admob.maio_android}}
implementation 'com.google.ads.mediation:maio:2.0.8.0'
{{/admob.maio_android}}

{{#admob.meta_android}}
implementation 'com.google.ads.mediation:facebook:6.21.0.0'
{{/admob.meta_android}}

{{#admob.mintegral_android}}
implementation 'com.google.ads.mediation:mintegral:17.0.61.0'
{{/admob.mintegral_android}}

{{#admob.moloco_android}}
implementation 'com.google.ads.mediation:moloco:4.4.0.0'
{{/admob.moloco_android}}

{{#admob.mytarget_android}}
implementation 'com.google.ads.mediation:mytarget:5.27.4.0'
{{/admob.mytarget_android}}

{{#admob.pangle_android}}
implementation 'com.google.ads.mediation:pangle:7.8.5.2.0'
{{/admob.pangle_android}}

{{#admob.pubmatic_android}}
implementation 'com.google.ads.mediation:pubmatic:4.11.0.1'
{{/admob.pubmatic_android}}

{{#admob.unity_android}}
implementation 'com.unity3d.ads:unity-ads:4.16.5'
implementation 'com.google.ads.mediation:unity:4.16.5.0'
{{/admob.unity_android}}
}
67 changes: 66 additions & 1 deletion extension-admob/manifests/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,67 @@
# Auto-generated by updater/ios.py. Do not edit by hand.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I keep it here, because it will not be used anyways (without checkboxes in game.project I removed from ext.properties)

platform :ios, '12.0'
pod 'Google-Mobile-Ads-SDK', '12.9.0'
pod 'Google-Mobile-Ads-SDK', '12.14.0'

{{#admob.applovin_ios}}
pod 'GoogleMobileAdsMediationAppLovin'
{{/admob.applovin_ios}}

{{#admob.chartboost_ios}}
pod 'GoogleMobileAdsMediationChartboost'
{{/admob.chartboost_ios}}

{{#admob.dt_exchange_ios}}
pod 'GoogleMobileAdsMediationFyber'
{{/admob.dt_exchange_ios}}

{{#admob.imobile_ios}}
pod 'GoogleMobileAdsMediationIMobile'
{{/admob.imobile_ios}}

{{#admob.inmobi_ios}}
pod 'GoogleMobileAdsMediationInMobi'
{{/admob.inmobi_ios}}

{{#admob.ironsource_ios}}
pod 'GoogleMobileAdsMediationIronSource'
{{/admob.ironsource_ios}}

{{#admob.liftoff_ios}}
pod 'GoogleMobileAdsMediationVungle'
{{/admob.liftoff_ios}}

{{#admob.line_ios}}
pod 'GoogleMobileAdsMediationLine'
{{/admob.line_ios}}

{{#admob.maio_ios}}
pod 'GoogleMobileAdsMediationMaio'
{{/admob.maio_ios}}

{{#admob.meta_ios}}
pod 'GoogleMobileAdsMediationFacebook'
{{/admob.meta_ios}}

{{#admob.mintegral_ios}}
pod 'GoogleMobileAdsMediationMintegral'
{{/admob.mintegral_ios}}

{{#admob.moloco_ios}}
pod 'GoogleMobileAdsMediationMoloco'
{{/admob.moloco_ios}}

{{#admob.mytarget_ios}}
pod 'GoogleMobileAdsMediationMyTarget'
{{/admob.mytarget_ios}}

{{#admob.pangle_ios}}
pod 'GoogleMobileAdsMediationPangle'
{{/admob.pangle_ios}}

{{#admob.pubmatic_ios}}
pod 'GoogleMobileAdsMediationPubMatic'
{{/admob.pubmatic_ios}}

{{#admob.unity_ios}}
pod 'GoogleMobileAdsMediationUnity'
{{/admob.unity_ios}}
9 changes: 7 additions & 2 deletions extension-admob/src/admob_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,16 @@ void Initialize_Ext(dmExtension::Params* params, const char* defoldUserAgent)

InitJNIMethods(env, cls);

bool enableTestAds = false;
#ifdef DM_DEBUG
enableTestAds = dmConfigFile::GetInt(params->m_ConfigFile, "admob.test_ads_in_debug", 0) != 0;
#endif

const char* appOpenAdUnitId = dmConfigFile::GetString(params->m_ConfigFile, "admob.app_open_android", 0);
jstring jappOpenAdUnitId = env->NewStringUTF(appOpenAdUnitId);
jstring jdefoldUserAgent = env->NewStringUTF(defoldUserAgent);
jmethodID jni_constructor = env->GetMethodID(cls, "<init>", "(Landroid/app/Activity;Ljava/lang/String;Ljava/lang/String;)V");
g_admob.m_AdmobJNI = env->NewGlobalRef(env->NewObject(cls, jni_constructor, threadAttacher.GetActivity()->clazz, jappOpenAdUnitId, jdefoldUserAgent));
jmethodID jni_constructor = env->GetMethodID(cls, "<init>", "(Landroid/app/Activity;Ljava/lang/String;Ljava/lang/String;Z)V");
g_admob.m_AdmobJNI = env->NewGlobalRef(env->NewObject(cls, jni_constructor, threadAttacher.GetActivity()->clazz, jappOpenAdUnitId, jdefoldUserAgent, (jboolean)enableTestAds));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

annoying to add more params, but it may initialize App Open AD there, so we need to do it before that

env->DeleteLocalRef(jappOpenAdUnitId);
env->DeleteLocalRef(jdefoldUserAgent);
}
Expand Down
Loading
Loading