- The example is for iOS only.
- The example class for the SDK is
public sealed class Example : MonoBehaviour
- add PangleSDK.unitypackage to Unity project
- add PangleAdapterScripts.unitypackage to Unity project
- it was Pangle's SDK and Adapter files, so you must set them import settings->Select platforms for plugin to Any platform or iOS
- you should set the information with PangleConfiguration and initialize PangleSDK with Pangle.
private static void callbackmethod (bool success, string message) {
Debug.Log("PangleSDK initialize result is "+success+" error message:"+message);
}
void Start () {
PangleConfiguration configuration = PangleConfiguration.CreateInstance();
configuration.appID = "5000546";
Pangle.InitializeSDK(callbackmethod);
}
- XCodePostProcess.cs
private AdNative adNative;
private AdNative AdNative
{
get
{
if (this.adNative == null)
{
this.adNative = SDK.CreateAdNative();
}
return this.adNative;
}
}
this
is Example class instance.
private FullScreenVideoAd fullScreenVideoAd;
public void LoadFullScreenVideoAd()
{
var rit = "900546299";
var adSlot = new AdSlot.Builder()
.SetCodeId(rit)
.Build();
this.AdNative.LoadFullScreenVideoAd(adSlot, new FullScreenVideoAdListener(this));
}
- you can get the load status With FullScreenVideoAdListener.
this.example
is the sample object holding fullScreenVideoAd.OnFullScreenVideoAdLoad
you can get fullScreenVideoAd object in this method.
private sealed class FullScreenVideoAdListener : IFullScreenVideoAdListener
{
private Example example;
public FullScreenVideoAdListener(Example example)
{
this.example = example;
}
public void OnError(int code, string message) { }
public void OnFullScreenVideoAdLoad(FullScreenVideoAd ad)
{
this.example.fullScreenVideoAd = ad;
/// add FullScreenAdInteractionListener
ad.SetFullScreenVideoAdInteractionListener(new FullScreenAdInteractionListener(this.example));
/// show ad
ad.ShowFullScreenVideoAd();
}
public void OnFullScreenVideoCached() { }
}
- You can get a series of events about the user's action
private sealed class FullScreenAdInteractionListener : IFullScreenVideoAdInteractionListener
{
private Example example;
public FullScreenAdInteractionListener(Example example)
{
this.example = example;
}
public void OnAdShow() {}
public void OnAdVideoBarClick() {}
public void OnAdClose() {}
public void OnVideoComplete() {}
public void OnVideoError() {}
public void OnSkippedVideo() {}
}
this.fullScreenVideoAd.Dispose();
this.fullScreenVideoAd = null;
this
is Example class instance.
private RewardVideoAd rewardAd;
public void LoadRewardAd()
{
var rit = "900546826";
var adSlot = new AdSlot.Builder()
.SetCodeId(rit)
.SetMediaExtra("Optional - Example Extra Data")
.Build();
this.AdNative.LoadRewardVideoAd(adSlot, new RewardVideoAdListener(this));
}
- you can get the load status With RewardVideoAdListener.
this.example
is the sample object holding rewardAd.OnRewardVideoAdLoad
you can get rewardAd object in this method.
private sealed class RewardVideoAdListener : IRewardVideoAdListener
{
private Example example;
public RewardVideoAdListener(Example example)
{
this.example = example;
}
public void OnError(int code, string message){ }
public void OnRewardVideoAdLoad(RewardVideoAd ad)
{
this.example.rewardAd = ad;
///RewardAdInteractionListener
ad.SetRewardAdInteractionListener(new RewardAdInteractionListener(this.example));
///show ad
this.rewardAd.ShowRewardVideoAd();
}
public void OnRewardVideoCached() {}
}
- You can get a series of events about the user's action
private sealed class RewardAdInteractionListener : IRewardAdInteractionListener
{
private Example example;
public RewardAdInteractionListener(Example example)
{
this.example = example;
}
public void OnAdShow() {}
public void OnAdVideoBarClick() {}
public void OnAdClose() {}
public void OnVideoComplete() {}
public void OnVideoError() {}
public void OnRewardVerify(bool rewardVerify, int rewardAmount, string rewardName) {}
}
this.rewardAd.Dispose();
this.rewardAd = null;
PangleTools
allows you to get the screen scale
height
, width
, and safeAreaInsets up
, down
, left
and right
of window. ( the unit of value is pixel. )
getScreenScale()
getScreenWidth()
getScreenHeight()
getWindowSafeAreaInsetsTop()
getWindowSafeAreaInsetsLeft()
getWindowSafeAreaInsetsBottom()
getWindowSafeAreaInsetsRight()
this
is Example class instance.
private ExpressBannerAd bannerAd;
public void LoadBannerAd()
{
var rit = "900546833";
float expressWidth = 320;
float expressHeight = 250;
var adSlot = new AdSlot.Builder()
.SetCodeId(ritID)
.SetExpressViewAcceptedSize(expressWidth, expressHeight)
.Build();
this.AdNative.LoadExpressBannerAd(adSlot, new ExpressAdListener(this, 1));
}
- you can get the load status With ExpressAdListener.
this.example
is the sample object holding bannerAd.OnExpressAdLoad
you can get bannerAd object in this method.
private sealed class ExpressAdListener : IExpressAdListener
{
private Example example;
private int type;//0:feed 1:banner 2:interstitial
public ExpressAdListener(Example example, int type)
{
this.example = example;
this.type = type;
}
public void OnExpressBannerAdLoad(ExpressBannerAd ad)
{
this.example.bannerAd = ad;
ad.SetExpressInteractionListener(new ExpressAdInteractionListener(this.example,1));
///show ad
float x = PangleTools. getWindowSafeAreaInsetsLeft();
float y = PangleTools. getWindowSafeAreaInsetsTop();
this.bannerAd.ShowExpressAd(x, y);
}
public void OnError(int code, string message) { }
}
- You can get a series of events about the user's action
private sealed class ExpressAdInteractionListener : IExpressAdInteractionListener
{
private Example example;
int type;//0:feed 1:banner 2:interstitial
public ExpressAdInteractionListener(Example example, int type)
{
this.example = example;
this.type = type;
}
public void OnAdClicked(ExpressAd ad) { }
public void OnAdShow(ExpressAd ad) { }
public void OnAdClose(ExpressAd ad) { }
}
this.bannerAd.Dispose();
this.bannerAd = null;
this
is Example class instance.
private NativeAd nativeFeedAd;
public void LoadNativeAd()
{
var adSlot = new AdSlot.Builder()
.SetCodeId("900546910")
.SetNativeAdType(AdSlotType.Feed)
.SetImageAcceptedSize(600, 400)
.SetAdCount(1)
.Build();
this.AdNative.LoadNativeAd(adSlot, new NativeAdListener(this));
}
- you can get the load status With NativeAdListener.
this.example
is the sample object holding nativeAd.OnNativeAdLoad
you can get nativeAd object in this method.- you can customize the view in NativeAd.mm file at
buildupViewFeed
method
private sealed class NativeAdListener : INativeAdListener
{
private Example example;
public NativeAdListener(Example example)
{
this.example = example;
}
public void OnError(int code, string message) { }
public void OnNativeAdLoad(AndroidJavaObject list,NativeAd ad)
{
if (ad.GetAdType() == AdSlotType.Feed)
{
this.example.nativeFeedAd = ad;
ad.SetNativeAdInteractionListener(new NativeAdInteractionListener(this.example));
this.nativeFeedAd.ShowNativeAd(AdSlotType.Feed);
}
}
}
- You can get a series of events about the user's action
private sealed class NativeAdInteractionListener : IInteractionAdInteractionListener
{
private Example example;
public NativeAdInteractionListener(Example example)
{
this.example = example;
}
public void OnAdShow() { }
public void OnAdClicked() { }
public void OnAdDismiss() { }
}
this.nativeFeedAd.Dispose();
this.nativeFeedAd = null;