-
Notifications
You must be signed in to change notification settings - Fork 5
Video ads
If you have not created ad spaces or downloaded SDK, please refer to the link below.
If you have not imported Unity package into project, please follow the link below.
-
Create an
NendAdInterstitialVideo
object usingNewVideoAd
method ofNendAdInterstitialVideo
. -
If you want to receive response event from
NendAdInterstitialVideo
process, please register event call backs. The events are as follows.public event NendAdVideoLoaded AdLoaded; public event NendAdVideoFailedToLoad AdFailedToLoad; public event NendAdVideoFailedToPlay AdFailedToPlay; public event NendAdVideoShown AdShown; public event NendAdVideoClick AdStarted; //Never called on AdType.Playable!! public event NendAdVideoClick AdStopped; //Never called on AdType.Playable!! public event NendAdVideoClick AdCompleted; //Never called on AdType.Playable!! public event NendAdVideoClick AdClicked; public event NendAdVideoClick InformationClicked; public event NendAdVideoClosed AdClosed;
-
To load an interstitial video, call the
NendAdInterstitialVideo
object'sLoad
method.
When failed toLoad
, you've receive same error code via callbacks. Error code is as follows.Code Description 204 No delivery ads 400 BAD request 5XX Server error 600 Error in SDK 601 Ad download failed 602 Fallback fullscreen ad failed 603 Invalid network 604 Advertisement acquisition network error (timeout etc.) You can get ad type information by
AdType
property.AdType Description Normal
Normal video ads Playable
User-controllable ads -
Call
NendAdInterstitialVideo
object'sShow
method to show interstitial video ad, after loading is completed. -
Please make sure to call the
NendAdInterstitialVideo
object'sRelease
method after your video ad session has been completed.
using UnityEngine;
using NendUnityPlugin.AD.Video;
public class VideoObject : MonoBehaviour
{
#if UNITY_IOS
private int spotId = 802557;
private string apiKey = "b6a97b05dd088b67f68fe6f155fb3091f302b48b";
#else
private int spotId = 802559;
private string apiKey = "e9527a2ac8d1f39a667dfe0f7c169513b090ad44";
#endif
private NendAdInterstitialVideo m_InterstitialVideoAd;
// Use this for initialization
void Start ()
{
m_InterstitialVideoAd =
NendAdInterstitialVideo.NewVideoAd (spotId, apiKey);
m_InterstitialVideoAd.AdLoaded += (instance) => {
// loading of ad is completed
};
m_InterstitialVideoAd.AdFailedToLoad += (instance, errorCode) => {
// loading of ad is failed
};
m_InterstitialVideoAd.AdFailedToPlay += (instance) => {
// playing of video is failed
};
m_InterstitialVideoAd.AdShown += (instance) => {
// ad shown
};
m_InterstitialVideoAd.AdStarted += (instance) => {
// video started (never called on AdType.Playable)
};
m_InterstitialVideoAd.AdStopped += (instance) => {
// video stopped (never called on AdType.Playable)
};
m_InterstitialVideoAd.AdCompleted += (instance) => {
// video completed playing to the end (never called on AdType.Playable)
};
m_InterstitialVideoAd.AdClicked += (instance) => {
// ad clicked
};
m_InterstitialVideoAd.InformationClicked += (instance) => {
// information button clicked
};
m_InterstitialVideoAd.AdClosed += (instance) => {
// ad closed
};
}
void OnDestroy () {
m_InterstitialVideoAd.Release ();
}
public void Load ()
{
m_InterstitialVideoAd.Load ();
}
public void Show ()
{
if (m_InterstitialVideoAd.IsLoaded()) {
m_InterstitialVideoAd.Show ();
}
}
}
You can also set user id, Features of User, fallback fullboard ad, and set mute state to play video.
After version 5.0.0, UserId property is no longer supported in iOS. Android support will be discontinued soon. |
Call NendAdInterstitialVideo
object's UserId
property. This is your app's original identifier.
m_InterstitialVideoAd.UserId = "user id";
After version 5.0.0, UserFeature property is no longer supported in iOS. Android support will be discontinued soon. |
In the Unity-plugin version 2.3.3 or higher, targeting-ad option of video ad is available to using Features of User.
Here are available options.
- Gender
- Birthday
- Age
- Others: could be customized from own your app.
Call NendAdInterstitialVideo
object's UserFeature
property.
//e.g. Only single feature
NendAdUserFeature userFeature = new NendAdUserFeature ();
userFeature.SetBirthday (1985, 12, 31); // Birthday (e.g. Dec 31, 1985)
m_InterstitialVideoAd.UserFeature = userFeature;
...
//e.g. Multiple features
NendAdUserFeature userFeature = new NendAdUserFeature ();
userFeature.gender = NendAdUserFeature.Gender.Female;
userFeature.SetBirthday (1985, 12, 31); // Birthday (e.g. Dec 31, 1985)
userFeature.age = 10; // age
userFeature.AddCustomFeature ("someString", "TestText"); // Others: customized parameters that formatted key-value type.
userFeature.AddCustomFeature ("someInt", 1);
userFeature.AddCustomFeature ("someDouble", 23.4);
userFeature.AddCustomFeature ("someBool", true);
m_InterstitialVideoAd.UserFeature = userFeature;
Note:
- Birthday is high priority than age if set both parameters.
- You can only using
string
orint
ordouble
orbool
value at custom parameters. - If you want to set age group, please use custom parameters not age.
Call NendAdInterstitialVideo
object's AddFallbackFullboard
method.
If you can not display interstitial video for reasons such as out of stock, you can display fullscreen ads instead.
In order to use this function, you need to register ad space of fullscreen ads separately on the management screen.
m_InterstitialVideoAd.AddFallbackFullboard (fullboard_spotid, "fullboard_apikey");
If you want to customize background-color of area that outside of iPhoneX Safe Area, use following function instead of above one.
using UnityEngine;
...
// e.g. gray color
m_InterstitialVideoAd.AddFallbackFullboard (fullboard_spotid, "fullboard_apikey", Color.gray);
Call NendAdInterstitialVideo
object's IsMuteStartPlaying
property.
Default is true
.
m_InterstitialVideoAd.IsMuteStartPlaying = false;
-
Create an
NendAdRewardedVideo
object usingNewVideoAd
method ofNendAdRewardedVideo
. -
Please register event call backs to receive
Rewarded
event. And optionally, if you want to receive other response event fromNendAdRewardedVideo
process. The events are as follows.public event NendAdVideoLoaded AdLoaded; public event NendAdVideoFailedToLoad AdFailedToLoad; public event NendAdVideoFailedToPlay AdFailedToPlay; public event NendAdVideoShown AdShown; public event NendAdVideoClick AdStarted; //Never called on AdType.Playable!! public event NendAdVideoClick AdStopped; //Never called on AdType.Playable!! public event NendAdVideoClick AdCompleted; //Never called on AdType.Playable!! public event NendAdVideoClick AdClicked; public event NendAdVideoClick InformationClicked; public event NendAdVideoClosed AdClosed; public event NendAdVideoRewarded Rewarded; //Please register to receive reward!!
-
To load an interstitial video, call the
NendAdRewardedVideo
object'sLoad
method. When failed toLoad
, you've receive same error code as via callbacks.
Error code is as follows.
Ad type information is as follows. -
Call
NendAdRewardedVideo
object'sShow
method to show interstitial video ad, after loading is completed. -
Please make sure to call the
NendAdRewardedVideo
object'sRelease
method after your video ad session has been completed.
using UnityEngine;
using NendUnityPlugin.AD.Video;
public class VideoObject : MonoBehaviour
{
#if UNITY_IOS
private int spotId = 802555;
private string apiKey = "ca80ed7018734d16787dbda24c9edd26c84c15b8";
#else
private int spotId = 802558;
private string apiKey = "a6eb8828d64c70630fd6737bd266756c5c7d48aa";
#endif
private NendAdRewardedVideo m_RewardedVideoAd;
// Use this for initialization
void Start ()
{
m_RewardedVideoAd =
NendAdRewardedVideo.NewVideoAd (spotId, apiKey);
m_RewardedVideoAd.AdLoaded += (instance) => {
// loading of ad is completed
};
m_RewardedVideoAd.AdFailedToLoad += (instance, errorCode) => {
// loading of ad is failed
};
m_RewardedVideoAd.AdFailedToPlay += (instance) => {
// playing of video is failed
};
m_RewardedVideoAd.AdShown += (instance) => {
// ad shown
};
m_RewardedVideoAd.AdStarted += (instance) => {
// video started (never called on AdType.Playable)
};
m_RewardedVideoAd.AdStopped += (instance) => {
// video stopped (never called on AdType.Playable)
};
m_RewardedVideoAd.AdCompleted += (instance) => {
// video completed playing to the end (never called on AdType.Playable)
};
m_RewardedVideoAd.AdClicked += (instance) => {
// ad clicked
};
m_RewardedVideoAd.InformationClicked += (instance) => {
// information button clicked
};
m_RewardedVideoAd.AdClosed += (instance) => {
// ad closed
};
m_RewardedVideoAd.Rewarded += (instance, rewardedItem) => {
// Rewards
Debug.Log ("CurrencyName = " + rewardedItem.currencyName);
Debug.Log ("CurrencyAmount = " + rewardedItem.currencyAmount);
};
}
void OnDestroy () {
m_RewardedVideoAd.Release ();
}
public void Load ()
{
m_RewardedVideoAd.Load ();
}
public void Show ()
{
if (m_RewardedVideoAd.IsLoaded()) {
m_RewardedVideoAd.Show ();
}
}
}
You can also set user id, Features of User.
After version 5.0.0, UserId property is no longer supported in iOS. Android support will be discontinued soon. |
Call NendAdRewardedVideo
object's UserId
property. This is your app's original identifier.
m_RewardedVideoAd.UserId = "user id";
Please use one of the following test modes for video ads.
- Use test apiKey and spotID
- Register Advertisement ID
You must register Advertisement ID on management screen of nend. Please check how to test these platforms: