集成 Admob for Unity + Vungle SDK v.5

本文介绍了如何将 Admob for Unity 与 Vungle SDK v. 5 (iOS)/(Android) 进行集成。

  1. 有关 Admob for Unity 集成的详细步骤,请访问:https://developers.google.com/admob/unity/start

  2. 下载各平台最新版 Vungle SDK 工具包,请访问:https://dashboard.vungle.com/sdk

    • 对于 iOS:将框架文件放置在以下路径:/Plugins/IOS/
      例如:
      /Plugins/IOS/VungleSDK.framework

    • 对于 Android:jar 文件放置在以下路径:/Plugins/Android/
      例如:
      /Plugins/publisher-sdk-android-5.3.0.jar/

  3. 自 Vungle SDK v.5 起,Vungle 需要您传递所有广告位置才能初始化。为此,您必须从以下网址下载专用的 Admob Unity 软件包:https://vungle.box.com/s/4c69oacqrrcer63wg4v35vrmgsew26ub

    或者,也可使用以下 gradle 脚本自行构建此软件包:https://github.com/googleads/googleads-mobile-unity/blob/master/mediation/Vungle/build.gradle

  4. 设置各平台的特定要求:
    • 对于 iOS:playersettings 设为 ios 8 或更高版本;否则,Unity 将无法调用相应的 cocoapod。从 Unity-IPhone.xcworkspace 启动。

    • 对于 Android:您必须使用 Admob 的工具解析相应的依赖关系。为此,单击“资产 播放服务解析器 Android 解析器 解析”。

    如果面向 Windows 系统构建,则菜单选项的外观如下:
    image2.png

    如果面向 Mac 系统构建,则菜单选项的外观如下:
    image1.png
  5. 确定您想要显示的是奖励式还是插屏式广告:
    • 对于插屏式广告:使用 VungleInterstitialMediationExtrasSetAllPlacements 函数设置所有广告位置参数。
    • 对于奖励式广告:通过 VungleRewardedVideoMediationExtrasSetAllPlacements 函数设置所有广告位置。

    代码示例:

    using GoogleMobileAds.Api.Mediation.Vungle; private void RequestInterstitial() { #iif UNITY_ANDROID string adUnitId = "ca-app-pub-8179651753653275/5515034537"; #elif UNITY_IPHONE string adUnitId = "ca-app-pub-8179651753653275/3316025494"; #else string adUnitId = "unexpected_platform"; #endif //Create a new empty VIME Object, required to add additional parameters, Interstitial only VungleInterstitialMediationExtras extras = new VungleInterstitialMediationExtras(); //All placements must be passed at all times, this is because the SDK doesn't start until //admob calls it the first time. extras.SetAllPlacements(new string[] { "NONREWA26038", "DEFAULT71817" }); // Create an empty ad request with extra parameters required to load Vungle AdRequest request = new AdRequest.Builder().AddMediationExtras(extras).Build(); // Initialize an InterstitialAd with the adunit interstitial = new InterstitialAd(adUnitId); // Load the interstitial with the request. interstitial.LoadAd(request); } private void RequestRewarded() { #if UNITY_ANDROID string adUnitId = "ca-app-pub-8179651753653275/3571397475"; #elif UNITY_IPHONE string adUnitId = "ca-app-pub-8179651753653275/2306018548"; #else string adUnitId = "unexpected_platform"; #endif //Create a new empty VRVME Object, required to add additional parameters, rewarded only VungleRewardedVideoMediationExtras extras = new VungleRewardedVideoMediationExtras(); //Same as above, all placements must be passed at all times, as Admob doesn't initlize Vungle until admob calls it extras.SetAllPlacements(new string[] { "NONREWA26038", "DEFAULT71817" }); //Same as above AdRequest request = new AdRequest.Builder().AddMediationExtras(extras).Build(); // Initialize a Rewarded Video Ad rewardBasedVideo = RewardBasedVideoAd.Instance; //Loads an ad with the above parameters rewardBasedVideo.LoadAd(request, adUnitId); } private void ShowInterstitial() { if (interstitial.IsLoaded()) { interstitial.Show(); } } private void ShowRewarded() { if (rewardBasedVideo.IsLoaded()) { rewardBasedVideo.Show(); } } 
还有其它问题?提交请求

评论