From 1f339d3a7fcda5c8e9cb33f1dc0c8e94be0872b3 Mon Sep 17 00:00:00 2001 From: Ram Parameswaran Date: Fri, 9 Mar 2018 16:54:24 -0800 Subject: [PATCH] Version 3.12.0 of the Google Mobile Ads Unity plugin --- ChangeLog.txt | 18 ++++ mediation/Maio/CHANGELOG.md | 9 +- mediation/Maio/build.gradle | 2 +- .../Editor/MaioMediationDependencies.xml | 6 +- .../google/unity/ads/RewardBasedVideo.java | 12 +++ .../Assets/GoogleMobileAds/Api/AdLoader.cs | 9 +- .../Assets/GoogleMobileAds/Api/AdRequest.cs | 2 +- .../Assets/GoogleMobileAds/Api/BannerView.cs | 12 +-- .../GoogleMobileAds/Api/InterstitialAd.cs | 11 +-- .../Assets/GoogleMobileAds/Api/MobileAds.cs | 1 - .../Api/NativeExpressAdView.cs | 12 +-- .../GoogleMobileAds/Api/RewardBasedVideoAd.cs | 21 +++-- .../Common/IRewardBasedVideoAdClient.cs | 3 + .../Common/MobileAdsEventExecutor.cs | 91 ------------------- .../Common/MobileAdsEventExecutor.cs.meta | 13 --- .../Assets/GoogleMobileAds/Common/Utils.cs | 11 --- .../Platforms/Android/AdLoaderClient.cs | 3 +- .../Android/RewardBasedVideoAdClient.cs | 5 + .../iOS/CustomNativeTemplateClient.cs | 2 +- .../GoogleMobileAds/Platforms/iOS/Externs.cs | 3 + .../Platforms/iOS/RewardBasedVideoAdClient.cs | 6 ++ .../plugin/Assets/Plugins/iOS/GADUInterface.m | 8 ++ .../Assets/Plugins/iOS/GADUInterstitial.m | 1 + .../Plugins/iOS/GADURewardBasedVideoAd.h | 5 +- .../Plugins/iOS/GADURewardBasedVideoAd.m | 5 + 25 files changed, 108 insertions(+), 163 deletions(-) delete mode 100644 source/plugin/Assets/GoogleMobileAds/Common/MobileAdsEventExecutor.cs delete mode 100644 source/plugin/Assets/GoogleMobileAds/Common/MobileAdsEventExecutor.cs.meta diff --git a/ChangeLog.txt b/ChangeLog.txt index 30876526e..46c02695a 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,5 +1,23 @@ Google Mobile Ads Unity Plugin Change Log +************** +Version 3.12.0 +************** + +Plugin: +- Add `setUserId` API to rewarded video ads to identify users in +server-to-server reward callbacks. +- Remove functionality that forced ad events to be invoked on the +main thread. + +Mediation packages: +- Updated maio Unity package to v1.0.1. + +Built and tested with: +- Google Play services 11.8.0 +- Google Mobile Ads iOS SDK 7.29.0 +- Unity Jar Resolver 1.2.61.0 + ************** Version 3.11.1 ************** diff --git a/mediation/Maio/CHANGELOG.md b/mediation/Maio/CHANGELOG.md index b6ac736d8..a9d60943a 100644 --- a/mediation/Maio/CHANGELOG.md +++ b/mediation/Maio/CHANGELOG.md @@ -1,7 +1,10 @@ # maio Adapter plugin for Google Mobile Ads SDK for Unity 3D Changelog -## 1.0.0 +## 1.0.1 +- Supports maio Android SDK version 1.0.7. +- Supports maio iOS SDK version 1.2.19. +## 1.0.0 - First release! -- Supports Android adapter version 1.0.6.0. -- Supports iOS adapter version 1.2.18.0. +- Supports maio Android SDK version 1.0.6. +- Supports maio iOS SDK version 1.2.18. diff --git a/mediation/Maio/build.gradle b/mediation/Maio/build.gradle index b94c6ccc2..6517fe7af 100644 --- a/mediation/Maio/build.gradle +++ b/mediation/Maio/build.gradle @@ -23,7 +23,7 @@ project.ext { 'UNITY_EXE environment variable and point it to your Unity installation.') } - versionString = '1.0.0' + versionString = '1.0.1' pluginName = 'GoogleMobileAdsMaioMediation' pluginFileName = "${pluginName}.unitypackage" zipName = "${pluginName}-${versionString}" diff --git a/mediation/Maio/source/plugin/Assets/GoogleMobileAds/Editor/MaioMediationDependencies.xml b/mediation/Maio/source/plugin/Assets/GoogleMobileAds/Editor/MaioMediationDependencies.xml index 28690f55d..18071ca5d 100644 --- a/mediation/Maio/source/plugin/Assets/GoogleMobileAds/Editor/MaioMediationDependencies.xml +++ b/mediation/Maio/source/plugin/Assets/GoogleMobileAds/Editor/MaioMediationDependencies.xml @@ -1,11 +1,11 @@ - + https://jcenter.bintray.com/ - + https://imobile-maio.github.io/maven @@ -13,7 +13,7 @@ - + https://github.com/CocoaPods/Specs diff --git a/source/android-library/app/src/main/java/com/google/unity/ads/RewardBasedVideo.java b/source/android-library/app/src/main/java/com/google/unity/ads/RewardBasedVideo.java index d0eebc898..f39b59fd0 100644 --- a/source/android-library/app/src/main/java/com/google/unity/ads/RewardBasedVideo.java +++ b/source/android-library/app/src/main/java/com/google/unity/ads/RewardBasedVideo.java @@ -126,6 +126,18 @@ public boolean isLoaded() { return isLoaded; } + /** + * Sets the user ID to be used in server-to-server reward callbacks. + */ + public void setUserId(final String userId) { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + rewardBasedVideo.setUserId(userId); + } + }); + } + /** * Shows the reward based video ad if it has loaded. */ diff --git a/source/plugin/Assets/GoogleMobileAds/Api/AdLoader.cs b/source/plugin/Assets/GoogleMobileAds/Api/AdLoader.cs index a1f319e0a..f446dc1a8 100644 --- a/source/plugin/Assets/GoogleMobileAds/Api/AdLoader.cs +++ b/source/plugin/Assets/GoogleMobileAds/Api/AdLoader.cs @@ -45,22 +45,17 @@ private AdLoader(Builder builder) BindingFlags.Static | BindingFlags.Public); this.adLoaderClient = (IAdLoaderClient)method.Invoke(null, new object[] { this }); - Utils.CheckInitialization(); - this.adLoaderClient.OnCustomNativeTemplateAdLoaded += delegate (object sender, CustomNativeEventArgs args) { - if (this.OnCustomNativeTemplateAdLoaded != null) - { - MobileAdsEventExecutor.executeInUpdate(() => this.OnCustomNativeTemplateAdLoaded(this, args)); - } + this.OnCustomNativeTemplateAdLoaded(this, args); }; this.adLoaderClient.OnAdFailedToLoad += delegate ( object sender, AdFailedToLoadEventArgs args) { if (this.OnAdFailedToLoad != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdFailedToLoad(this, args)); + this.OnAdFailedToLoad(this, args); } }; } diff --git a/source/plugin/Assets/GoogleMobileAds/Api/AdRequest.cs b/source/plugin/Assets/GoogleMobileAds/Api/AdRequest.cs index 03482d1f8..754a52b88 100644 --- a/source/plugin/Assets/GoogleMobileAds/Api/AdRequest.cs +++ b/source/plugin/Assets/GoogleMobileAds/Api/AdRequest.cs @@ -21,7 +21,7 @@ namespace GoogleMobileAds.Api { public class AdRequest { - public const string Version = "3.11.1"; + public const string Version = "3.12.0"; public const string TestDeviceSimulator = "SIMULATOR"; private AdRequest(Builder builder) diff --git a/source/plugin/Assets/GoogleMobileAds/Api/BannerView.cs b/source/plugin/Assets/GoogleMobileAds/Api/BannerView.cs index fa917ea46..d9cf299bc 100644 --- a/source/plugin/Assets/GoogleMobileAds/Api/BannerView.cs +++ b/source/plugin/Assets/GoogleMobileAds/Api/BannerView.cs @@ -34,7 +34,6 @@ public BannerView(string adUnitId, AdSize adSize, AdPosition position) this.client = (IBannerClient)method.Invoke(null, null); client.CreateBannerView(adUnitId, adSize, position); - Utils.CheckInitialization(); ConfigureBannerEvents(); } @@ -49,7 +48,6 @@ public BannerView(string adUnitId, AdSize adSize, int x, int y) this.client = (IBannerClient)method.Invoke(null, null); client.CreateBannerView(adUnitId, adSize, x, y); - Utils.CheckInitialization(); ConfigureBannerEvents(); } @@ -118,7 +116,7 @@ private void ConfigureBannerEvents() { if (this.OnAdLoaded != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdLoaded(this, args)); + this.OnAdLoaded(this, args); } }; @@ -126,7 +124,7 @@ private void ConfigureBannerEvents() { if (this.OnAdFailedToLoad != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdFailedToLoad(this, args)); + this.OnAdFailedToLoad(this, args); } }; @@ -134,7 +132,7 @@ private void ConfigureBannerEvents() { if (this.OnAdOpening != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdOpening(this, args)); + this.OnAdOpening(this, args); } }; @@ -142,7 +140,7 @@ private void ConfigureBannerEvents() { if (this.OnAdClosed != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdClosed(this, args)); + this.OnAdClosed(this, args); } }; @@ -150,7 +148,7 @@ private void ConfigureBannerEvents() { if (this.OnAdLeavingApplication != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdLeavingApplication(this, args)); + this.OnAdLeavingApplication(this, args); } }; } diff --git a/source/plugin/Assets/GoogleMobileAds/Api/InterstitialAd.cs b/source/plugin/Assets/GoogleMobileAds/Api/InterstitialAd.cs index 68039c707..d15997d18 100644 --- a/source/plugin/Assets/GoogleMobileAds/Api/InterstitialAd.cs +++ b/source/plugin/Assets/GoogleMobileAds/Api/InterstitialAd.cs @@ -34,12 +34,11 @@ public InterstitialAd(string adUnitId) this.client = (IInterstitialClient)method.Invoke(null, null); client.CreateInterstitialAd(adUnitId); - Utils.CheckInitialization(); this.client.OnAdLoaded += (sender, args) => { if (this.OnAdLoaded != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdLoaded(this, args)); + this.OnAdLoaded(this, args); } }; @@ -47,7 +46,7 @@ public InterstitialAd(string adUnitId) { if (this.OnAdFailedToLoad != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdFailedToLoad(this, args)); + this.OnAdFailedToLoad(this, args); } }; @@ -55,7 +54,7 @@ public InterstitialAd(string adUnitId) { if (this.OnAdOpening != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdOpening(this, args)); + this.OnAdOpening(this, args); } }; @@ -63,7 +62,7 @@ public InterstitialAd(string adUnitId) { if (this.OnAdClosed != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdClosed(this, args)); + this.OnAdClosed(this, args); } }; @@ -71,7 +70,7 @@ public InterstitialAd(string adUnitId) { if (this.OnAdLeavingApplication != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdLeavingApplication(this, args)); + this.OnAdLeavingApplication(this, args); } }; } diff --git a/source/plugin/Assets/GoogleMobileAds/Api/MobileAds.cs b/source/plugin/Assets/GoogleMobileAds/Api/MobileAds.cs index 16bb4081a..74c8b93b2 100644 --- a/source/plugin/Assets/GoogleMobileAds/Api/MobileAds.cs +++ b/source/plugin/Assets/GoogleMobileAds/Api/MobileAds.cs @@ -26,7 +26,6 @@ public class MobileAds public static void Initialize(string appId) { client.Initialize(appId); - MobileAdsEventExecutor.Initialize(); } public static void SetApplicationMuted(bool muted) diff --git a/source/plugin/Assets/GoogleMobileAds/Api/NativeExpressAdView.cs b/source/plugin/Assets/GoogleMobileAds/Api/NativeExpressAdView.cs index 2d6c4c241..548b9aa1d 100644 --- a/source/plugin/Assets/GoogleMobileAds/Api/NativeExpressAdView.cs +++ b/source/plugin/Assets/GoogleMobileAds/Api/NativeExpressAdView.cs @@ -34,7 +34,6 @@ public NativeExpressAdView(string adUnitId, AdSize adSize, AdPosition position) this.client = (INativeExpressAdClient)method.Invoke(null, null); this.client.CreateNativeExpressAdView(adUnitId, adSize, position); - Utils.CheckInitialization(); ConfigureNativeExpressAdEvents(); } @@ -49,7 +48,6 @@ public NativeExpressAdView(string adUnitId, AdSize adSize, int x, int y) this.client = (INativeExpressAdClient)method.Invoke(null, null); this.client.CreateNativeExpressAdView(adUnitId, adSize, x, y); - Utils.CheckInitialization(); ConfigureNativeExpressAdEvents(); } @@ -94,7 +92,7 @@ private void ConfigureNativeExpressAdEvents() { if (this.OnAdLoaded != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdLoaded(this, args)); + this.OnAdLoaded(this, args); } }; @@ -102,7 +100,7 @@ private void ConfigureNativeExpressAdEvents() { if (this.OnAdFailedToLoad != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdFailedToLoad(this, args)); + this.OnAdFailedToLoad(this, args); } }; @@ -110,7 +108,7 @@ private void ConfigureNativeExpressAdEvents() { if (this.OnAdOpening != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdOpening(this, args)); + this.OnAdOpening(this, args); } }; @@ -118,7 +116,7 @@ private void ConfigureNativeExpressAdEvents() { if (this.OnAdClosed != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdClosed(this, args)); + this.OnAdClosed(this, args); } }; @@ -126,7 +124,7 @@ private void ConfigureNativeExpressAdEvents() { if (this.OnAdLeavingApplication != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdLeavingApplication(this, args)); + this.OnAdLeavingApplication(this, args); } }; } diff --git a/source/plugin/Assets/GoogleMobileAds/Api/RewardBasedVideoAd.cs b/source/plugin/Assets/GoogleMobileAds/Api/RewardBasedVideoAd.cs index 9da3064d8..6bdf8ebaa 100644 --- a/source/plugin/Assets/GoogleMobileAds/Api/RewardBasedVideoAd.cs +++ b/source/plugin/Assets/GoogleMobileAds/Api/RewardBasedVideoAd.cs @@ -43,12 +43,11 @@ private RewardBasedVideoAd() this.client = (IRewardBasedVideoAdClient)method.Invoke(null, null); client.CreateRewardBasedVideoAd(); - Utils.CheckInitialization(); this.client.OnAdLoaded += (sender, args) => { if (this.OnAdLoaded != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdLoaded(this, args)); + this.OnAdLoaded(this, args); } }; @@ -56,7 +55,7 @@ private RewardBasedVideoAd() { if (this.OnAdFailedToLoad != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdFailedToLoad(this, args)); + this.OnAdFailedToLoad(this, args); } }; @@ -64,7 +63,7 @@ private RewardBasedVideoAd() { if (this.OnAdOpening != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdOpening(this, args)); + this.OnAdOpening(this, args); } }; @@ -72,7 +71,7 @@ private RewardBasedVideoAd() { if (this.OnAdStarted != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdStarted(this, args)); + this.OnAdStarted(this, args); } }; @@ -80,7 +79,7 @@ private RewardBasedVideoAd() { if (this.OnAdClosed != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdClosed(this, args)); + this.OnAdClosed(this, args); } }; @@ -88,7 +87,7 @@ private RewardBasedVideoAd() { if (this.OnAdLeavingApplication != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdLeavingApplication(this, args)); + this.OnAdLeavingApplication(this, args); } }; @@ -96,7 +95,7 @@ private RewardBasedVideoAd() { if (this.OnAdRewarded != null) { - MobileAdsEventExecutor.executeInUpdate(() => this.OnAdRewarded(this, args)); + this.OnAdRewarded(this, args); } }; } @@ -134,6 +133,12 @@ public void Show() client.ShowRewardBasedVideoAd(); } + // Sets the user id of current user. + public void SetUserId(string userId) + { + client.SetUserId(userId); + } + // Returns the mediation adapter class name. public string MediationAdapterClassName() { diff --git a/source/plugin/Assets/GoogleMobileAds/Common/IRewardBasedVideoAdClient.cs b/source/plugin/Assets/GoogleMobileAds/Common/IRewardBasedVideoAdClient.cs index 973a985ce..584e30864 100644 --- a/source/plugin/Assets/GoogleMobileAds/Common/IRewardBasedVideoAdClient.cs +++ b/source/plugin/Assets/GoogleMobileAds/Common/IRewardBasedVideoAdClient.cs @@ -49,5 +49,8 @@ public interface IRewardBasedVideoAdClient // Shows the reward based video ad on the screen. void ShowRewardBasedVideoAd(); + + // Sets the user id of current user. + void SetUserId(string userId); } } diff --git a/source/plugin/Assets/GoogleMobileAds/Common/MobileAdsEventExecutor.cs b/source/plugin/Assets/GoogleMobileAds/Common/MobileAdsEventExecutor.cs deleted file mode 100644 index 54baa03fe..000000000 --- a/source/plugin/Assets/GoogleMobileAds/Common/MobileAdsEventExecutor.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (C) 2018 Google, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Collections; -using System.Collections.Generic; - -using UnityEngine; - -namespace GoogleMobileAds.Common -{ - internal class MobileAdsEventExecutor : MonoBehaviour - { - private static MobileAdsEventExecutor instance = null; - - private static List adEventsQueue = new List(); - - private volatile static bool adEventsQueueEmpty = true; - - public static void Initialize() - { - if (IsActive()) - { - return; - } - - // Add an invisible game object to the scene - GameObject obj = new GameObject("MobileAdsMainThreadExecuter"); - obj.hideFlags = HideFlags.HideAndDontSave; - DontDestroyOnLoad(obj); - instance = obj.AddComponent(); - } - - public static bool IsActive() - { - return instance != null; - } - - public void Awake() - { - DontDestroyOnLoad(gameObject); - } - - public static void executeInUpdate(Action action) - { - lock (adEventsQueue) - { - adEventsQueue.Add(action); - adEventsQueueEmpty = false; - } - } - - public void Update() - { - if (adEventsQueueEmpty) - { - return; - } - - List stagedAdEventsQueue = new List(); - - lock (adEventsQueue) - { - stagedAdEventsQueue.AddRange(adEventsQueue); - adEventsQueue.Clear(); - adEventsQueueEmpty = true; - } - - foreach (Action stagedEvent in stagedAdEventsQueue) - { - stagedEvent.Invoke(); - } - } - - public void OnDisable() - { - instance = null; - } - } -} \ No newline at end of file diff --git a/source/plugin/Assets/GoogleMobileAds/Common/MobileAdsEventExecutor.cs.meta b/source/plugin/Assets/GoogleMobileAds/Common/MobileAdsEventExecutor.cs.meta deleted file mode 100644 index ec47570a1..000000000 --- a/source/plugin/Assets/GoogleMobileAds/Common/MobileAdsEventExecutor.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: d5dfa1423353e45c9bb636c123e5a05a -timeCreated: 1517530267 -licenseType: Pro -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/source/plugin/Assets/GoogleMobileAds/Common/Utils.cs b/source/plugin/Assets/GoogleMobileAds/Common/Utils.cs index a9730554c..a0cf70c81 100644 --- a/source/plugin/Assets/GoogleMobileAds/Common/Utils.cs +++ b/source/plugin/Assets/GoogleMobileAds/Common/Utils.cs @@ -21,17 +21,6 @@ namespace GoogleMobileAds.Common { internal class Utils { - public static void CheckInitialization() - { - if (!MobileAdsEventExecutor.IsActive()) - { - Debug.Log("You intitialized an ad object but have not yet called MobileAds.Initialize(). We " + - "highly recommend you call MobileAds.Initialize() before interacting with the Google " + - "Mobile Ads SDK."); - } - MobileAdsEventExecutor.Initialize(); - } - public static Texture2D GetTexture2DFromByteArray(byte[] img) { // Create a texture. Texture size does not matter, since diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/Android/AdLoaderClient.cs b/source/plugin/Assets/GoogleMobileAds/Platforms/Android/AdLoaderClient.cs index f0355add8..d491ce340 100644 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/Android/AdLoaderClient.cs +++ b/source/plugin/Assets/GoogleMobileAds/Platforms/Android/AdLoaderClient.cs @@ -84,8 +84,7 @@ public void onCustomClick(AndroidJavaObject ad, string assetName) { CustomNativeTemplateAd nativeAd = new CustomNativeTemplateAd( new CustomNativeTemplateClient(ad)); - MobileAdsEventExecutor.executeInUpdate(() => - this.CustomNativeTemplateCallbacks[nativeAd.GetCustomTemplateId()](nativeAd, assetName)); + this.CustomNativeTemplateCallbacks[nativeAd.GetCustomTemplateId()](nativeAd, assetName); } } } diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/Android/RewardBasedVideoAdClient.cs b/source/plugin/Assets/GoogleMobileAds/Platforms/Android/RewardBasedVideoAdClient.cs index 3fe9e9b2f..66762d56d 100644 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/Android/RewardBasedVideoAdClient.cs +++ b/source/plugin/Assets/GoogleMobileAds/Platforms/Android/RewardBasedVideoAdClient.cs @@ -66,6 +66,11 @@ public void ShowRewardBasedVideoAd() androidRewardBasedVideo.Call("show"); } + public void SetUserId(string userId) + { + androidRewardBasedVideo.Call("setUserId", userId); + } + public void DestroyRewardBasedVideoAd() { androidRewardBasedVideo.Call("destroy"); diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/CustomNativeTemplateClient.cs b/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/CustomNativeTemplateClient.cs index 67d0e9887..862e6c37f 100644 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/CustomNativeTemplateClient.cs +++ b/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/CustomNativeTemplateClient.cs @@ -145,7 +145,7 @@ private static void NativeCustomTemplateDidReceiveClickCallback( if (client.clickHandler != null) { CustomNativeTemplateAd nativeAd = new CustomNativeTemplateAd(client); - MobileAdsEventExecutor.executeInUpdate(() => client.clickHandler(nativeAd, assetName)); + client.clickHandler(nativeAd, assetName); } } diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Externs.cs b/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Externs.cs index 35f650b22..09bfa2c99 100644 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Externs.cs +++ b/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Externs.cs @@ -184,6 +184,9 @@ internal static extern void GADUSetInterstitialCallbacks( [DllImport("__Internal")] internal static extern void GADUShowRewardBasedVideoAd(IntPtr rewardBasedVideo); + [DllImport("__Internal")] + internal static extern void GADUSetRewardBasedVideoAdUserId(IntPtr rewardBasedVideo, string userId); + [DllImport("__Internal")] internal static extern void GADURequestRewardBasedVideoAd( IntPtr bannerView, IntPtr request, string adUnitId); diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/RewardBasedVideoAdClient.cs b/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/RewardBasedVideoAdClient.cs index fed1b46df..f0dafa7b6 100644 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/RewardBasedVideoAdClient.cs +++ b/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/RewardBasedVideoAdClient.cs @@ -115,6 +115,12 @@ public void ShowRewardBasedVideoAd() Externs.GADUShowRewardBasedVideoAd(this.RewardBasedVideoAdPtr); } + // Sets the user ID to be used in server-to-server reward callbacks. + public void SetUserId(string userId) + { + Externs.GADUSetRewardBasedVideoAdUserId(this.RewardBasedVideoAdPtr, userId); + } + public bool IsLoaded() { return Externs.GADURewardBasedVideoAdReady(this.RewardBasedVideoAdPtr); diff --git a/source/plugin/Assets/Plugins/iOS/GADUInterface.m b/source/plugin/Assets/Plugins/iOS/GADUInterface.m index 884e7ecf3..4afa38c79 100644 --- a/source/plugin/Assets/Plugins/iOS/GADUInterface.m +++ b/source/plugin/Assets/Plugins/iOS/GADUInterface.m @@ -353,6 +353,14 @@ BOOL GADURewardBasedVideoAdReady(GADUTypeRewardBasedVideoAdRef rewardBasedVideo) return [internalRewardBasedVideoAd isReady]; } +/// Sets the user ID to be used in server-to-server reward callbacks. +void GADUSetRewardBasedVideoAdUserId(GADUTypeRewardBasedVideoAdRef rewardBasedVideo, + const char *userId) { + GADURewardBasedVideoAd *internalRewardBasedVideoAd = + (__bridge GADURewardBasedVideoAd *)rewardBasedVideo; + [internalRewardBasedVideoAd setUserId:GADUStringFromUTF8String(userId)]; +} + /// Shows the GADRewardBasedVideo. void GADUShowRewardBasedVideoAd(GADUTypeRewardBasedVideoAdRef rewardBasedVideoAd) { GADURewardBasedVideoAd *internalRewardBasedVideoAd = diff --git a/source/plugin/Assets/Plugins/iOS/GADUInterstitial.m b/source/plugin/Assets/Plugins/iOS/GADUInterstitial.m index 5e98a1946..8efa5b840 100644 --- a/source/plugin/Assets/Plugins/iOS/GADUInterstitial.m +++ b/source/plugin/Assets/Plugins/iOS/GADUInterstitial.m @@ -7,6 +7,7 @@ #import "GADUPluginUtil.h" #import "UnityAppController.h" +#import "UnityInterface.h" @interface GADUInterstitial () @end diff --git a/source/plugin/Assets/Plugins/iOS/GADURewardBasedVideoAd.h b/source/plugin/Assets/Plugins/iOS/GADURewardBasedVideoAd.h index 98afeb61b..9449add54 100644 --- a/source/plugin/Assets/Plugins/iOS/GADURewardBasedVideoAd.h +++ b/source/plugin/Assets/Plugins/iOS/GADURewardBasedVideoAd.h @@ -10,7 +10,7 @@ /// Initializes a GADURewardBasedVideoAd. - (instancetype)initWithRewardBasedVideoClientReference: - (GADUTypeRewardBasedVideoAdClientRef *)rewardBasedVideoAdClient; + (GADUTypeRewardBasedVideoAdClientRef *)rewardBasedVideoAdClient; /// The reward based video ad. @property(nonatomic, strong) GADRewardBasedVideoAd *rewardBasedVideo; @@ -52,4 +52,7 @@ /// Shows the reward based video ad. - (void)show; +// Sets the user ID to be used in server-to-server reward callbacks. +- (void)setUserId:(NSString *)userId; + @end diff --git a/source/plugin/Assets/Plugins/iOS/GADURewardBasedVideoAd.m b/source/plugin/Assets/Plugins/iOS/GADURewardBasedVideoAd.m index 418bc8b59..ea540e811 100644 --- a/source/plugin/Assets/Plugins/iOS/GADURewardBasedVideoAd.m +++ b/source/plugin/Assets/Plugins/iOS/GADURewardBasedVideoAd.m @@ -7,6 +7,7 @@ #import "GADUPluginUtil.h" #import "UnityAppController.h" +#import "UnityInterface.h" @interface GADURewardBasedVideoAd () @end @@ -50,6 +51,10 @@ - (void)show { } } +- (void)setUserId:(NSString *)userId { + self.rewardBasedVideo.userIdentifier = userId; +} + - (NSString *)mediationAdapterClassName { return [self.rewardBasedVideo adNetworkClassName]; }