Callback when caching fails. Reasons can be found through errorCode.getMsg()
404 Not Found
Android Unity
1、Overview
1.1 Target Readers
This document is for developers who need to integrate ZPLAY Ads Unity 3D SDK into their Unity3D product.
1.2 Development environment
OS:Windows、Mac、Linux
Android SDK: 2.1 and newer versions
IDE:Eclipse with ADT, Unity64-5.2.3f1
2、SDK Download
2.1 Choose third-party SDK
2.2 Download ZPLAY Ads SDK
Please download ZPLAY Ads SDK and add it to your project
2.3 Download third-party SDK
Please download third-party SDK and add it to your project according to instructions of the third-party platform
3、Integration
3.1 Add resource files
All the resource files needed are under resource\Android.
Note: you can download and add third-party jar (yumi_adapter_******_v*.*.*.jar) according to your needs. Please copy all the other resource files, and do not modify anything or else error would occur. If the resource files conflict with your existing files, please rename your resource files in the original project. If conflict occurs with AndroidManifest.xml, please add the following contents in the existing AndroidManifest.xml:
1、Add permission needed by ZPLAY Ads SDK:
Mandatory:
Optional:
<!-- optional --> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
2、Register components
3.2 Quick Integration
3.2.1 Environment configuration
1. Copy YumiUnityAdUtils.cs to Assets in your Unity project, this file is one of the Unity plugin tools of Android ZPLAY Ads SDK.
This class includes construction method, related call methods of banner, interstitial and rewarded video and callback interface declaration.
2. After finishing the steps above, add the following code in your Start () method of your C#:
// your YumiID,YumiID You need to create a Yumi ID on ZPLAY Ads. private string adID = "a36777775b*******1b3a9de3c166"; // Android ZPLAY Ads plugin Utils private YumiUnityAdUtils uad; void Start () { // Use this for instantiation uad = new YumiUnityAdUtils(adID); }
3.2.2 Banner
1) Call following to show banner, pass parameter GameObject:
uad.AddBannerAd("Main Camera");
2) Call following to hide banner:
uad.DismissBanner();
3) Call following to resume showing banner:
uad.ResumeBanner();
3.2.3 Interstitial
1) Call following to initialize interstitial, pass parameter GameObject:
uad.InitInterstitialAd("Main Camera");
2) Call following to request interstitial:
uad.RequestInterstitial();
3) Call following to show interstitial:
uad.ShowInterstitialAd();
3.2.4 Rewarded video
1) Call following to initialize rewarded video, pass parameter GameObject:
uad.InitMedia("Main Camera");
2) Call following to request rewarded video:
uad.RequestMedia();
3) Call following to query if rewarded video is available:
uad.IsMediaPrepared();
4) Call following to show rewarded video:
uad.ShowMedia();
4、Advanced features
4.1 Banner
1) Automatic adaptation to screen size:
- Non auto adaptation
- Auto adaptation
When you set banner ad container, you can use isMatchWindowWidth, a parameter of boolean type provided by ZPLAY Ads SDK. This parameter indicates if banner width has populated full screen. When it's true, banner width equals the screen width.
uad.AddBannerAd("Main Camera", isMatchWindowWidth);
2) Banner ad callback, inherit Assets.YumiUnityAdUtils.BannerAdCallbackListener and implement the following method:
-
onBannerPreparedFailed(LayerErrorCode errorCode)
-
onBannerPrepared()
Callback when caching succeeds.
-
onBannerExposure()
Callback when impression succeeds.
-
onBannerClosed()
Callback when Banner is closed.
-
onBannerClicked()
Callback when Banner is clicked.
Sample
#region Banner Callback //Banner Callback method when banner fails to load public void onBannerPreparedFailed(string data) { uad.ShowLog("onBannerPreparedFailed:" + data); } //Banner Callback method when banner loads successfully public void onBannerPrepared(string data) { uad.ShowLog("onBannerPrepared:" + data); } //Banner Callback method when impression succeeds public void onBannerExposure(string data) { uad.ShowLog("onBannerExposure:" + data); } //Banner Callback method when banner is closed public void onBannerClosed(string data) { uad.ShowLog("onBannerClosed:" + data); } //Banner Callback method when banner is clicked public void onBannerClicked(string data) { uad.ShowLog("onBannerClicked:" + data); } #endregion
4.2 Interstitial
Interstitial ad callback, inherit Assets. YumiUnityAdUtils.InterstitialAdCallbackListener and implement the following method:
-
onInterstitialPreparedFailed(LayerErrorCode error)
Callback when caching fails. Reason can be found through errorCode.getMsg()
-
onInterstitialPrepared()
Callback when loading succeeds.
Note: please do not call show interstitial method in this callback.
-
onInterstitialExposure()
Callback when Interstitial impression succeeds.
-
onInterstitialClosed()
Callback when interstitial is closed.
-
onInterstitialClicked()
Callback when interstitial is clicked.
Sample
#region InterstitialAd Callback //Interstitial Callback method when interstitial fails to load public void onInterstitialPreparedFailed(string data) { uad.ShowLog("onInterstitialPreparedFailed:" + data); } //Interstitial Callback method when interstitial loads successfully public void onInterstitialPrepared(string data) { uad.ShowLog("onInterstitialPrepared:" + data); } //Interstitial Callback method when impression succeeds public void onInterstitialExposure(string data) { uad.ShowLog("onInterstitialExposure:" + data); } //Interstitial Callback method when interstitial is closed public void onInterstitialClosed(string data) { uad.ShowLog("onInterstitialClosed:" + data); } //Interstitial Callback method when interstitial is clicked public void onInterstitialClicked(string data) { uad.ShowLog("onInterstitialClicked:" + data); } #endregion
4.3 Rewarded video
Rewarded video ad callback, inherit Assets.YumiUnityAdUtils.MediaAdCallbackListener and implement the following method:
-
onMediaExposure()
Callback when rewarded video impression succeeds
-
onMediaClosed()
Callback when rewarded video is closed
-
onMediaClicked()
Callback when rewarded video is clicked.
Note: this does not guarantee 100% callback due to platform differences.
-
onMediaIncentived()
Callback for rewards after video has been played completely.
Note: if the video has not been played completely, this callback won't be used. In addition, this method is always triggered after onInterstitialClosed().
Sample:
#region MediaAd Callback // MediaAd Callback method public void onMediaIncentived(string data) { uad.ShowLog("onMediaIncentived:" + data); } // MediaAd Callback method when impression is complete public void onMediaExposure(string data) { uad.ShowLog("onMediaExposure:" + data); } // MediaAd Callback method when video is closed public void onMediaClosed(string data) { uad.ShowLog("onMediaClosed:" + data); } // MediaAd Callback method when video is clicked public void onMediaClicked (string data) { uad.ShowLog("onMediaClicked:" + data); } // MediaAd Callback after video been loaded, return true when loading has completed(this method only calls back after uad.IsMediaPrepared) public void onIsMediaPrepared (string data) { uad.ShowLog("onIsMediaPrepared:" + data); } #endregion
4.4 Test mode
ZPLAY Ads SDK provideds a test mode to test your 3rd-party Integrations.
Call following method to launch test page:
uad.StartDebugging();
1. Call method to open test page:
YumiDebugging. startDebugging (Activity, YumiID);
2. ZPLAY Ads SDK will get configuration and show third-party platform list; If it shows green on the left, it indicates that the platform has
been integrated correctly and has successfully shown ads
3. Choose a platform:
1) SDK Available indicates third-party adapter has been added
2) Configuration present indicates that third-party adapter component Manifest has been registered
3) SDK Failed to start or No_fill indicates that no ad has been successfully shown
4. Click Fetch to start requesting ads, click Show to show ads
5. If all check items turn to green after ads being successfully shown, the platform has been successfully integrated
6. Comment out the test code before app launch
4.5 Log and Toast
The callback sample shows the following Android Log output method provided by pluggins, developers could choose whether to use them.
//Control panel output log uad.ShowLog("********"); //Screen toast uad. ShowToast("********");
4.6 Proguard
If you are using Proguard add the following to your Proguard config file:
5、Compilation
Note: please set the screen orientation in Unity3D project the same as that of AndroidManifest.xml in your Android project, or else app would crash when screen rotates after launch.
Click【Build And Run】 and wait for the progress bar to complete