Skip to content

Commit

Permalink
Merge pull request #9 from alexeyfeskov/mediation-debugger
Browse files Browse the repository at this point in the history
Mediation debugger support, update applovin-sdk to 10.1.2
  • Loading branch information
alexeyfeskov authored Apr 5, 2021
2 parents 56c9ea0 + c9e476d commit 7300f4b
Show file tree
Hide file tree
Showing 11 changed files with 216 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
*.gui_script linguist-language=Lua

# Defold YAML Files
*.script_api=YAML
*.script_api=yml
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ATTENTION! Currently only Android SDK is supported! No iOs support in current im

Supported ad types: [Interstitials](https://dash.applovin.com/documentation/mediation/android/getting-started/interstitials), [Rewarded Ads](https://dash.applovin.com/documentation/mediation/android/getting-started/rewarded-ads), [Banners](https://dash.applovin.com/documentation/mediation/android/getting-started/banners), [MRECs](https://dash.applovin.com/documentation/mediation/android/getting-started/mrecs)

Used AppLovin Max SDK v10.1.1.
Used AppLovin Max SDK v10.1.2.

## Installation

Expand All @@ -17,6 +17,17 @@ Open your game.project file and in the dependencies field under project add:
or point to the ZIP file of a [specific release](https://github.com/alexeyfeskov/defold-maxsdk/releases).

#### Android

You must enable [AndroidX support](https://defold.com/manuals/android/#using-androidx) for your project.

Also you must add [SDK key from Applovin Dashboard](https://dash.applovin.com/docs/integration#androidEventTracking) to `game.project` file by adding lines:

```
[applovin]
sdk_key_android = YOUR_SDK_KEY_HERE
```

## Example

See the [example folder](https://github.com/alexeyfeskov/defold-maxsdk/tree/master/example) for understand how to use extension. Especially [ads.gui_script](https://github.com/alexeyfeskov/defold-maxsdk/blob/master/example/ads.gui_script) file.
Expand All @@ -41,14 +52,24 @@ if maxsdk then

maxsdk.set_callback(maxsdk_callback)
maxsdk.initialize()
end

-----------------------
-- Start loading ads --
-----------------------
if maxsdk then
-- After SDK was initialized (`maxsdk.MSG_INITIALIZATION` event) - you can start loading ads
maxsdk.load_interstitial(interstitial_ad_unit)
maxsdk.load_rewarded(rewarded_ad_unit)
maxsdk.load_banner(banner_ad_unit, maxsdk.SIZE_BANNER)
-- Supported banner sizes:
-- maxsdk.SIZE_BANNER
-- maxsdk.SIZE_LEADER
-- maxsdk.SIZE_MREC (use separate ad_unit, all other APIs are same to banners)

-- To validate integration you can use Mediation Debugger
-- https://dash.applovin.com/documentation/mediation/android/testing-networks/mediation-debugger
maxsdk.open_mediation_debugger()
end

--------------
Expand Down
160 changes: 160 additions & 0 deletions example/ads.gui
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,166 @@ nodes {
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 200.0
y: 1127.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEMPLATE
id: "mediation_debugger"
parent: "inited"
layer: ""
inherit_alpha: true
alpha: 1.0
template: "/dirtylarry/button.gui"
template_node_child: false
}
nodes {
position {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 300.0
y: 88.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "button/button_normal"
id: "mediation_debugger/larrybutton"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "mediation_debugger"
layer: ""
inherit_alpha: true
slice9 {
x: 32.0
y: 32.0
z: 32.0
w: 32.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Open Debugger"
font: "larryfont"
id: "mediation_debugger/larrylabel"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: false
parent: "mediation_debugger/larrybutton"
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 1.0
shadow_alpha: 1.0
overridden_fields: 1
overridden_fields: 8
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
}
nodes {
position {
x: 385.0
Expand Down
6 changes: 5 additions & 1 deletion example/ads.gui_script
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function on_input(self, action_id, action)
end

local prev_type = self.ad_type

dirtylarry:button("initialization", action_id, action, function ()
-- https://developers.facebook.com/docs/audience-network/guides/ccpa
-- To explicitly not enable Limited Data Use (LDU) mode, use:
Expand All @@ -215,6 +215,10 @@ function on_input(self, action_id, action)
maxsdk.set_verbose_logging(true)
maxsdk.initialize()
end)

dirtylarry:button("mediation_debugger", action_id, action, function ()
maxsdk.open_mediation_debugger()
end)

self.ad_type = dirtylarry:radio("ad_type_interstitial", action_id, action, maxsdk.MSG_INTERSTITIAL, self.ad_type)
self.ad_type = dirtylarry:radio("ad_type_rewarded", action_id, action, maxsdk.MSG_REWARDED, self.ad_type)
Expand Down
5 changes: 5 additions & 0 deletions extension-maxsdk/api/maxsdk.script_api
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
- name: state
type: number

#*****************************************************************************************************

- name: open_mediation_debugger
type: function

#*****************************************************************************************************

- name: load_interstitial
Expand Down
2 changes: 1 addition & 1 deletion extension-maxsdk/ext.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ name: "AppLovinMaxExt"
platforms:
android:
context:
aaptExtraPackages: ['androidx.work', 'com.google.android.gms.common']
aaptExtraPackages: ['com.applovin.sdk']
4 changes: 2 additions & 2 deletions extension-maxsdk/manifests/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repositories {

dependencies {
// https://dash.applovin.com/documentation/mediation/android/getting-started/integration
compile 'com.applovin:applovin-sdk:10.1.1'
compile 'com.applovin:applovin-sdk:10.1.2'

compile 'com.applovin.mediation:adcolony-adapter:4.4.1.5'
compile 'com.applovin.mediation:facebook-adapter:6.3.0.0'
Expand All @@ -17,7 +17,7 @@ dependencies {
compile 'com.squareup.picasso:picasso:2.71828'
compile 'com.android.support:customtabs:28.+'
compile 'com.applovin.mediation:bytedance-adapter:3.4.1.1.2'
compile 'com.applovin.mediation:smaato-adapter:21.5.8.0'
compile 'com.applovin.mediation:smaato-adapter:21.5.8.1'
compile 'com.applovin.mediation:tapjoy-adapter:12.7.1.2'
compile 'com.applovin.mediation:verizonads-adapter:1.9.0.0'
compile 'com.applovin.mediation:vungle-adapter:6.9.1.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ public void setFbDataProcessingOptions(String mode, int country, int state) {
}
}

public void openMediationDebugger() {
AppLovinSdk.getInstance(mActivity).showMediationDebugger();
}

// https://www.baeldung.com/java-json-escaping
private String getJsonConversionErrorMessage(String messageText) {
String message = null;
Expand Down
7 changes: 7 additions & 0 deletions extension-maxsdk/src/android/maxsdk_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct AppLovin
jmethodID m_SetIsAgeRestrictedUser;
jmethodID m_SetDoNotSell;
jmethodID m_SetFbDataProcessingOptions;
jmethodID m_OpenMediationDebugger;

jmethodID m_LoadInterstitial;
jmethodID m_ShowInterstitial;
Expand Down Expand Up @@ -169,6 +170,7 @@ static void InitJNIMethods(JNIEnv* env, jclass cls)
g_maxsdk.m_SetIsAgeRestrictedUser = env->GetMethodID(cls, "setIsAgeRestrictedUser", "(Z)V");
g_maxsdk.m_SetDoNotSell = env->GetMethodID(cls, "setDoNotSell", "(Z)V");
g_maxsdk.m_SetFbDataProcessingOptions = env->GetMethodID(cls, "setFbDataProcessingOptions", "(Ljava/lang/String;II)V");
g_maxsdk.m_OpenMediationDebugger = env->GetMethodID(cls, "openMediationDebugger", "()V");

g_maxsdk.m_LoadInterstitial = env->GetMethodID(cls, "loadInterstitial", "(Ljava/lang/String;)V");
g_maxsdk.m_ShowInterstitial = env->GetMethodID(cls, "showInterstitial", "(Ljava/lang/String;)V");
Expand Down Expand Up @@ -245,6 +247,11 @@ void SetFbDataProcessingOptions(const char* cstr, int cint1, int cint2)
CallVoidMethodCharIntInt(g_maxsdk.m_AppLovinMaxJNI, g_maxsdk.m_SetFbDataProcessingOptions, cstr, cint1, cint2);
}

void OpenMediationDebugger()
{
CallVoidMethod(g_maxsdk.m_AppLovinMaxJNI, g_maxsdk.m_OpenMediationDebugger);
}

void LoadInterstitial(const char* unitId)
{
CallVoidMethodChar(g_maxsdk.m_AppLovinMaxJNI, g_maxsdk.m_LoadInterstitial, unitId);
Expand Down
8 changes: 8 additions & 0 deletions extension-maxsdk/src/maxsdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ static int Lua_SetFbDataProcessingOptions(lua_State* L)
return 0;
}

static int Lua_OpenMediationDebugger(lua_State* L)
{
DM_LUA_STACK_CHECK(L, 0);
OpenMediationDebugger();
return 0;
}

static int Lua_LoadInterstitial(lua_State* L)
{
DM_LUA_STACK_CHECK(L, 0);
Expand Down Expand Up @@ -241,6 +248,7 @@ static const luaL_reg Module_methods[] =
{"set_is_age_restricted_user", Lua_SetIsAgeRestrictedUser},
{"set_do_not_sell", Lua_SetDoNotSell},
{"set_fb_data_processing_options", Lua_SetFbDataProcessingOptions},
{"open_mediation_debugger", Lua_OpenMediationDebugger},

{"load_interstitial", Lua_LoadInterstitial},
{"show_interstitial", Lua_ShowInterstitial},
Expand Down
1 change: 1 addition & 0 deletions extension-maxsdk/src/maxsdk_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ void SetHasUserConsent(bool hasConsent);
void SetIsAgeRestrictedUser(bool ageRestricted);
void SetDoNotSell(bool doNotSell);
void SetFbDataProcessingOptions(const char* cstr, int cint1, int cint2);
void OpenMediationDebugger();

void LoadInterstitial(const char* unitId);
void ShowInterstitial(const char* placement);
Expand Down

0 comments on commit 7300f4b

Please sign in to comment.