Corresponding procedure in the case of GoogleMobileAds Video Rewards ad becomes the No fill
- Introduction
- to introduce the GoogleMobileAds Video Rewards mediation ad SDK Unity Plugin
- Import the GNSAdSDK-UnityPlugin-Reward plugin to Unity project
- Rewrite the Import the Unity plug-in life cycle Activity
- Modification of AndroidManifest.xml
- Use the Plugin API, registered a video Rewards advertising of events
- Video Rewards ad load of at the time of GoogleMobileAds advertising acquisition failure
- Add the video Rewards instance discarding process at the time of GoogleMobileAds advertising acquisition failure
- display of video Rewards ad
0. Introduction
GoogleMobileAds Video Rewards mediation ad SDK Unity introduction of Plugin
Make sure that it is only in the ad playback GoogleMobileAds following the procedure of the above-mentioned page.
1. to introduce the GoogleMobileAds Video Rewards mediation ad SDK Unity Plugin
GoogleMobileAds Video Rewards mediation ad SDK Unity introduction of Plugin
Please introduce a 1 and 2 of the above-mentioned page.
- Import the Google Mobile Ads Unity plugin to Unity project
- Import the GNSAdSDK-UnityPlugin-Google-Reward-5.0.0 to Unity project
2. Import the GNSAdSDK-UnityPlugin-Reward plugin to Unity project
Open the Unity project to incorporate a Plugin.
of the menu bar Assets -> Import Package - choose> Custom Package.
Select the reward of Dist folder on the side of
GNSAdSDK-UnityPlugin-Reward-4.0.0
file. (No fill corresponding since 2.1.0)Check that the following files of the check box is selected, and then click the
Import
.- GNSAdSDK
- Api
- RewardVideoAd.cs
- VideoRewardData.cs
- VideoRewardFailedData.cs
- Clients
- MockClient.cs
- RewardVideoAdClient.cs
- Platforms
- AdClientFactory.cs
- Android
- RewardVideoAdClientImpl.cs
- Utils.cs
- iOS
- Externs.cs
- RewardVideoAdClientImpl.cs
- Api
- Plugins
- iOS
- GNSUInterface.m
- GNSUObjectCache.h
- GNSUObjectCache.m
- GNSURewardVideoAd.h
- GNSURewardVideoAd.m
- GNSUTypes.h
- iOS
- GNSAdSDK
3. Rewrites the Import and Activity to work with the Unity plug-in
NoFill to switch to the corresponding ExtendsDfpNoFillUnityPlayerActivity class.
Assets/GNSAdSDK/Platforms/Android/Utils.cs
- public static string LifecycleListenerClassName = "jp.co.geniee.utgnsrewardvideo.ExtendsDfpUnityPlayerActivity$LifecycleListener";
+ public static string LifecycleListenerClassName = "jp.co.geniee.utgnsrewardvideo.ExtendsDfpNoFillUnityPlayerActivity$LifecycleListener";
2
4. Modify the AndroidManifest.xml
Rewrite to pass the life cycle information to ExtendsDfpNoFillUnityPlayerActivity
.
Assets/Plugins/Android/AndroidManifest.xml
- <activity android:name="jp.co.geniee.utgnsrewardvideo.ExtendsDfpUnityPlayerActivity"
- android:label="@string/app_name"
- android:configChanges="orientation|keyboardHidden|screenSize"
- >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
- </activity>
+ <activity android:name="jp.co.geniee.utgnsrewardvideo.ExtendsDfpNoFillUnityPlayerActivity"
+ android:label="@string/app_name"
+ android:configChanges="orientation|keyboardHidden|screenSize"
+ >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
+ </activity>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Use the 5. Plugin API, registered a video Rewards advertising of events
The following is the code needed to register the event by creating a video reward advertising. When you register an event, please complete the registration process before the video load.
using GNSAdSDK.Api;
...
static bool isRegistedRewardVideoEventHandler = false;
void RegistRewardVideoAdEventHandler()
{
if (!isRegistedRewardVideoEventHandler)
{
// Video Rewards event that you want to use from here to NoFill corresponding time
RewardVideoAd rewardVideoAd = RewardVideoAd.Instance;
rewardVideoAd.OnAdLoaded += (object sender, System.EventArgs args) => {
// processing of when the video Rewards ad load has been completed
};
rewardVideoAd.OnAdStarted += (object sender, VideoRewardData args) => {
// processing of when the video Rewards ad was played
// ※ only to iOS, properties are all passed instance of an empty VideoRewardData in args.
};
rewardVideoAd.OnAdRewarded += (object sender, VideoRewardData args) => {
// processing of when the reward has been granted to the user
};
rewardVideoAd.OnAdClosed += (object sender, VideoRewardData args) => {
// processing of when the video Rewards ad is closed
// ※ only to iOS, properties are all passed instance of an empty VideoRewardData in args.
};
rewardVideoAd.OnAdFailedToLoad += (object sender, VideoRewardFailedData args) => {
// processing of when the video Rewards ad load has failed
};
// Get singleton reward based video ad reference.
RewardBasedVideoAd rewardBasedVideo = RewardBasedVideoAd.Instance;
// Called when an ad request has successfully loaded.
rewardBasedVideo.OnAdLoaded += HandleRewardBasedVideoLoaded;
// Called when an ad request failed to load.
rewardBasedVideo.OnAdFailedToLoad += HandleRewardBasedVideoFailedToLoad;
// Called when an ad is shown.
rewardBasedVideo.OnAdOpening += HandleRewardBasedVideoOpened;
// Called when the ad starts to play.
rewardBasedVideo.OnAdStarted += HandleRewardBasedVideoStarted;
// Called when the user should be rewarded for watching a video.
rewardBasedVideo.OnAdRewarded += HandleRewardBasedVideoRewarded;
// Called when the ad is closed.
rewardBasedVideo.OnAdClosed += HandleRewardBasedVideoClosed;
// Called when the ad click caused the user to leave the application.
rewardBasedVideo.OnAdLeavingApplication += HandleRewardBasedVideoLeftApplication;
}
isRegistedRewardVideoEventHandler = true;
}
public void HandleRewardBasedVideoLoaded(object sender, EventArgs args)
{
MonoBehaviour.print("HandleRewardBasedVideoLoaded event received");
}
public void HandleRewardBasedVideoFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
MonoBehaviour.print(
"HandleRewardBasedVideoFailedToLoad event received with message: "
+ args.Message);
}
public void HandleRewardBasedVideoOpened(object sender, EventArgs args)
{
MonoBehaviour.print("HandleRewardBasedVideoOpened event received");
}
public void HandleRewardBasedVideoStarted(object sender, EventArgs args)
{
MonoBehaviour.print("HandleRewardBasedVideoStarted event received");
}
public void HandleRewardBasedVideoClosed(object sender, EventArgs args)
{
MonoBehaviour.print("HandleRewardBasedVideoClosed event received");
}
public void HandleRewardBasedVideoRewarded(object sender, Reward args)
{
string type = args.Type;
double amount = args.Amount;
RewardBasedVideoAd rewardBasedVideo = RewardBasedVideoAd.Instance;
MonoBehaviour.print(
"HandleRewardBasedVideoRewarded event received for "
+ amount.ToString() + " " + type + " " + rewardBasedVideo.MediationAdapterClassName());
}
public void HandleRewardBasedVideoLeftApplication(object sender, EventArgs args)
{
MonoBehaviour.print("HandleRewardBasedVideoLeftApplication event received");
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
- RewardVideoAd instance, will be the singleton object for operating the video reward advertising.
- Because RewardVideoAd instance of the singleton object, event registration in order to avoid the events overlap is recommended that you only once.
VideoRewardData
are in possession of the following property.
public class VideoRewardData: EventArgs
{
// name
// ※ In the case of iOS, will always be null.
public string AdName {get; set;}
// Amount of money
public double Amount {get; set;}
// type
public string Type {get; set;}
}
2
3
4
5
6
7
8
9
10
VideoRewardFailedData
are in possession of the following property.
public class VideoRewardFailedData : EventArgs
{
// ad network name
// ※ In the case of iOS, will always be null.
public string AdnetworkName {get; set;}
// code
public int Code {get; set;}
// message
public string Message {get; set;}
}
2
3
4
5
6
7
8
9
10
6. Video Rewards ad load of at the time of GoogleMobileAds advertising acquisition failure
Please add the following in the event of failure to obtain HandleRewardBasedVideoFailedToLoad
of GoogleMobileAds.
public void HandleRewardBasedVideoFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
MonoBehaviour.print(
"HandleRewardBasedVideoFailedToLoad event received with message: "
+ args.Message);
string zoneId = "";
#if UNITY_ANDROID
zoneId = "Please put the zoneId here";
#elif UNITY_IPHONE
zoneId = "Please put the zoneId here";
#endif
RewardVideoAd rewardVideoAd = RewardVideoAd.Instance;
rewardVideoAd.LoadAd (zoneId);
}
2
3
4
5
6
7
8
9
10
11
12
13
14
- RewardVideoAd instance, will be the singleton object for operating the video reward advertising.
7. Add Videos Rewards instance the process of disposing of the GoogleMobileAds advertising acquisition failure
In order to perform the discarding process at OnDestroy case of Android, please set the callback of Application.Quit as follows. ※ If you want to create only iOS is not mandatory.
using GNSAdSDK.Api;
...
void OnApplicationQuit()
{
RewardVideoAd.Instance.DisposeAd();
}
2
3
4
5
6
7
8
8. Display of video Rewards ad
The following is the code required to display the video Rewards advertising.
GoogleMobileAds Video Rewards is unloaded and, if the video Rewards of the load that was requested at the time GoogleMobileAds advertising acquisition failure has been completed,
ShowAd ()
calls will be possible.
using GNSAdSDK.Api;
...
void ShowRewardVideoAd()
{
RewardBasedVideoAd rewardBasedVideo = RewardBasedVideoAd.Instance;
RewardVideoAd rewardVideoAd = RewardVideoAd.Instance;
if (rewardBasedVideo.IsLoaded())
{
rewardBasedVideo.Show();
}
else
{
if (rewardVideoAd.IsLoaded())
{
rewardVideoAd.ShowAd();
} else {
MonoBehaviour.print("Not yet been loaded");
}
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22