AdMob AppLovin Interstitial
Hello, Everyone
I was trying to add few more blueprints nodes exposing AdMob, and AppLovin Interstitial functionality.
In GameActivity.java if i add the following code inside AndroidThunkJava_ShowAdBanner(String AdMobAdUnitID, boolean bShowOnBottonOfScreen):
public void AndroidThunkJava_ShowAdBanner(String AdMobAdUnitID, boolean bShowOnBottonOfScreen)
{
Log.debug("In AndroidThunkJava_ShowAdBanner");
Log.debug("AdID: " + AdMobAdUnitID);
AndroidThunkJava_ShowAdMobInterstitial();
//AndroidThunkJava_ShowAppLovinInterstitial();
//...code...//
}
where :
public void AndroidThunkJava_ShowAdMobInterstitial()
{
/** AdMob Interstitial Support */
if(_activity.interstitialAd != null)
{
_activity.runOnUiThread(new Runnable()
{
@Override
public void run()
{
if(_activity.interstitialAd.isLoaded() == true)
{
_activity.interstitialAd.show();
}
}
});
}
}
and
public void AndroidThunkJava_ShowAppLovinInterstitial()
{
/**AppLovin Support */
if(AppLovinInterstitialAd.isAdReadyToDisplay(this))
{
// An ad is available to display. It's safe to call show.
AppLovinInterstitialAd.show(this);
}
}
when i call the Show Ad Banner blueprint node, i either show AdMob or AppLovin interstitial ads(receiving test ads for both) together with AdMob banners without any problem.
I am trying to add few more blueprint nodes like Show Ad Banner in order to show Interstitial when i want regardless of showing banner, load them and check if they are loaded for both AdMob and AppLovin.
What i have done so far:
In the GameActivity.java:
public class GameActivity extends NativeActivity
{
//...code...//
/** AdMob and AppLovin Support */
public void AndroidThunkJava_LoadAdMobInterstitial()
{
interstitialAd.loadAd(request);
}
public void AndroidThunkJava_LoadAppLovinInterstitial()
{
AppLovinSdk.getInstance(this).getAdService().preloadAd(AppLovinAdSize.INTERSTITIAL);
}
public boolean AndroidThunkJava_HasAdMobInterstitial()
{
return _activity.interstitialAd.isLoaded();
}
public boolean AndroidThunkJava_HasApplovinInterstitial()
{
return AppLovinInterstitialAd.isAdReadyToDisplay(this);
}
public void AndroidThunkJava_ShowAppLovinInterstitial()
{
/**AppLovin Support */
if(AppLovinInterstitialAd.isAdReadyToDisplay(this))
{
// An ad is available to display. It's safe to call show.
AppLovinInterstitialAd.show(this);
}
}
public void AndroidThunkJava_ShowAdMobInterstitial()
{
/** AdMob Interstitial Support */
if(_activity.interstitialAd != null)
{
_activity.runOnUiThread(new Runnable()
{
@Override
public void run()
{
if(_activity.interstitialAd.isLoaded() == true)
{
_activity.interstitialAd.show();
}
}
});
}
}
//...code...//
}
In the AndroidJNI.cpp:
//...code...//
// Admob Interstitials
AndroidThunkJava_ShowAdMobInterstitial = FindMethod(Env, GoogleServicesClassID, "AndroidThunkJava_ShowAdMobInterstitial", "()V", bIsOptional);
AndroidThunkJava_LoadAdMobInterstitial = FindMethod(Env, GoogleServicesClassID, "AndroidThunkJava_LoadAdMobInterstitial", "()V", bIsOptional);
AndroidThunkJava_HasAdMobInterstitial = FindMethod(Env, GoogleServicesClassID, "AndroidThunkJava_HasAdMobInterstitial", "()V", bIsOptional);
// AppLovin Interstitials
AndroidThunkJava_ShowAppLovinInterstitial = FindMethod(Env, GoogleServicesClassID, "AndroidThunkJava_ShowAppLovinInterstitial", "()V", bIsOptional);
AndroidThunkJava_LoadAppLovinInterstitial = FindMethod(Env, GoogleServicesClassID, "AndroidThunkJava_LoadAppLovinInterstitial", "()V", bIsOptional);
AndroidThunkJava_HasAppLovinInterstitial = FindMethod(Env, GoogleServicesClassID, "AndroidThunkJava_HasAppLovinInterstitial", "()V", bIsOptional);
//...code...//
// Admob AppLovin Interstitials
jmethodID FJavaWrapper::AndroidThunkJava_ShowAdMobInterstitial;
jmethodID FJavaWrapper::AndroidThunkJava_LoadAdMobInterstitial;
jmethodID FJavaWrapper::AndroidThunkJava_HasAdMobInterstitial;
// Admob AppLovin Interstitials
jmethodID FJavaWrapper::AndroidThunkJava_ShowAppLovinInterstitial;
jmethodID FJavaWrapper::AndroidThunkJava_LoadAppLovinInterstitial;
jmethodID FJavaWrapper::AndroidThunkJava_HasAppLovinInterstitial;
//...code...//
//AdMob Interstitials
void AndroidThunkCpp_ShowAdMobInterstitial()
{
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
{
FJavaWrapper::CallVoidMethod(Env, FJavaWrapper::GoogleServicesThis, FJavaWrapper::AndroidThunkJava_ShowAdMobInterstitial);
}
}
void AndroidThunkCpp_LoadAdMobInterstitial()
{
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
{
FJavaWrapper::CallVoidMethod(Env, FJavaWrapper::GoogleServicesThis, FJavaWrapper::AndroidThunkJava_LoadAdMobInterstitial);
}
}
void AndroidThunkCpp_HasAdMobInterstitial()
{
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
{
FJavaWrapper::CallVoidMethod(Env, FJavaWrapper::GoogleServicesThis, FJavaWrapper::AndroidThunkJava_HasAdMobInterstitial);
}
}
//AppLovin Interstitials
void AndroidThunkCpp_ShowAppLovinInterstitial()
{
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
{
FJavaWrapper::CallVoidMethod(Env, FJavaWrapper::GoogleServicesThis, FJavaWrapper::AndroidThunkJava_ShowAppLovinInterstitial);
}
}
void AndroidThunkCpp_LoadAppLovinInterstitial()
{
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
{
FJavaWrapper::CallVoidMethod(Env, FJavaWrapper::GoogleServicesThis, FJavaWrapper::AndroidThunkJava_LoadAppLovinInterstitial);
}
}
void AndroidThunkCpp_HasAppLovinInterstitial()
{
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
{
FJavaWrapper::CallVoidMethod(Env, FJavaWrapper::GoogleServicesThis, FJavaWrapper::AndroidThunkJava_HasAppLovinInterstitial);
}
}
In the Android.JNI.h:
//...code...//
/ Admob AppLovin Interstitials
static jmethodID AndroidThunkJava_ShowAdMobInterstitial;
static jmethodID AndroidThunkJava_LoadAdMobInterstitial;
static jmethodID AndroidThunkJava_HasAdMobInterstitial;
static jmethodID AndroidThunkJava_ShowAppLovinInterstitial;
static jmethodID AndroidThunkJava_LoadAppLovinInterstitial;
static jmethodID AndroidThunkJava_HasAppLovinInterstitial;
In the KismetSystemLibrary.cpp:
//...code...//
/** AdMob Interstitial */
void UKismetSystemLibrary::ShowAdMobInterstitial()
{
if (IAdvertisingProvider* Provider = FAdvertising::Get().GetDefaultProvider())
{
Provider->ShowAdMobInterstitial();
}
}
void UKismetSystemLibrary::LoadAdMobInterstitial()
{
if (IAdvertisingProvider* Provider = FAdvertising::Get().GetDefaultProvider())
{
Provider->LoadAdMobInterstitial();
}
}
bool UKismetSystemLibrary::HasAdMobInterstitial()
{
bool bHasAdMob = false;
if (IAdvertisingProvider* Provider = FAdvertising::Get().GetDefaultProvider())
{
bHasAdMob = Provider->HasAdMobInterstitial();
}
return bHasAdMob;
}
/** AppLovin Interstitial */
void UKismetSystemLibrary::ShowAppLovinInterstitial()
{
if (IAdvertisingProvider* Provider = FAdvertising::Get().GetDefaultProvider())
{
Provider->ShowAppLovinInterstitial();
}
}
void UKismetSystemLibrary::LoadAppLovinInterstitial()
{
if (IAdvertisingProvider* Provider = FAdvertising::Get().GetDefaultProvider())
{
Provider->LoadAppLovinInterstitial();
}
}
bool UKismetSystemLibrary::HasAppLovinInterstitial()
{
bool bHasAppLovin = false;
if (IAdvertisingProvider* Provider = FAdvertising::Get().GetDefaultProvider())
{
bHasAppLovin = Provider->HasAppLovinInterstitial();
}
return bHasAppLovin;
}
//...code...//
In the KismetSystemLibrary.h
//...code...//
/**
* Will show an Interstitial ad (AdMob on Android) on the top or bottom of screen, on top of the GL view (doesn't resize the view)
* (Android only)
*
*/
UFUNCTION(BlueprintCallable, Category = "Utilities|Platform")
static void ShowAdMobInterstitial();
/**
* Will load an Interstitial ad (AdMob on Android)
* (Android only)
*
*/
UFUNCTION(BlueprintCallable, Category = "Utilities|Platform")
static void LoadAdMobInterstitial();
/**
* Will check if an Interstitial ad is available (AdMob on Android)
* (Android only)
*
*/
UFUNCTION(BlueprintCallable, Category = "Utilities|Platform")
static bool HasAdMobInterstitial();
/**
* Will show an Interstitial ad (AppLovin on Android) on the top or bottom of screen, on top of the GL view (doesn't resize the view)
* (Android only)
*
*/
UFUNCTION(BlueprintCallable, Category = "Utilities|Platform")
static void ShowAppLovinInterstitial();
/**
* Will load an Interstitial ad (AppLovin on Android)
* (Android only)
*
*/
UFUNCTION(BlueprintCallable, Category = "Utilities|Platform")
static void LoadAppLovinInterstitial();
/**
* Will check if an Interstitial ad is available (AppLovin on Android)
* (Android only)
*
*/
UFUNCTION(BlueprintCallable, Category = "Utilities|Platform")
static bool HasAppLovinInterstitial();
//...code...//
In the AndroidAdvertising.cpp:
//...code...//
void FAndroidAdvertisingProvider::ShowAdMobInterstitial()
{
extern void AndroidThunkCpp_ShowAdMobInterstitial();
AndroidThunkCpp_ShowAdMobInterstitial();
}
void FAndroidAdvertisingProvider::LoadAdMobInterstitial()
{
extern void AndroidThunkCpp_LoadAdMobInterstitial();
AndroidThunkCpp_LoadAdMobInterstitial();
}
bool FAndroidAdvertisingProvider::HasAdMobInterstitial()
{
extern bool AndroidThunkCpp_HasAdMobInterstitial();
bool bHasAdMob =AndroidThunkCpp_HasAdMobInterstitial();
return bHasAdMob;
}
void FAndroidAdvertisingProvider::ShowAppLovinInterstitial()
{
extern void AndroidThunkCpp_ShowAppLovinInterstitial();
AndroidThunkCpp_ShowAppLovinInterstitial();
}
void FAndroidAdvertisingProvider::LoadAppLovinInterstitial()
{
extern void AndroidThunkCpp_LoadAppLovinInterstitial();
AndroidThunkCpp_LoadAppLovinInterstitial();
}
bool FAndroidAdvertisingProvider::HasAppLovinInterstitial()
{
extern bool AndroidThunkCpp_HasAppLovinInterstitial();
bool bHasAppLovin = AndroidThunkCpp_HasAppLovinInterstitial();
return bHasAppLovin;
//...code...//
In the AdroidAdvertising.h:
//...code...//
virtual void ShowAdMobInterstitial() override;
virtual void LoadAdMobInterstitial() override;
virtual bool HasAdMobInterstitial() override;
virtual void ShowAppLovinInterstitial() override;
virtual void LoadAppLovinInterstitial() override;
virtual bool HasAppLovinInterstitial() override;
In the IAdvertisingProvider .h
//...code...//
virtual void ShowAdMobInterstitial() = 0;
virtual void LoadAdMobInterstitial() = 0;
virtual bool HasAdMobInterstitial() = 0;
virtual void ShowAppLovinInterstitial() = 0;
virtual void LoadAppLovinInterstitial() = 0;
virtual bool HasAppLovinInterstitial() = 0;
The new Blueprint nodes are exposed to Editor but they don’t seem to have any functionality.
Any feedback is highly appreciated.
Best,
.
*UPDATE: 14/12/2015
AdColony Interstitial Videos seems to integrate great too, now we need to expose them too, to blueprints.