From d9196de16d99d4876beca8606382f08c07bcecb2 Mon Sep 17 00:00:00 2001 From: Ram Parameswaran Date: Wed, 11 Apr 2018 14:29:48 -0700 Subject: [PATCH] Version 3.13.0 of the Google Mobile Ads Unity plugin --- ChangeLog.txt | 24 +- mediation/AdColony/CHANGELOG.md | 9 +- mediation/AdColony/build.gradle | 2 +- .../android-library/adcolony/build.gradle | 2 +- .../adcolony/AdColonyUnityExtrasBuilder.java | 2 +- .../Editor/AdColonyMediationDependencies.xml | 4 +- .../AndroidManifest.xml | 4 +- mediation/AppLovin/CHANGELOG.md | 8 + mediation/AppLovin/build.gradle | 2 +- .../Editor/AppLovinMediationDependencies.xml | 6 +- mediation/Chartboost/CHANGELOG.md | 6 + mediation/Chartboost/README.md | 6 + mediation/Chartboost/build.gradle | 146 ++++++++ .../ChartboostMediationDependencies.xml | 18 + .../AndroidManifest.xml | 14 + .../project.properties | 2 + mediation/MoPub/CHANGELOG.md | 6 + mediation/MoPub/README.md | 6 + mediation/MoPub/build.gradle | 145 ++++++++ .../Editor/MoPubMediationDependencies.xml | 23 ++ .../AndroidManifest.xml | 28 ++ .../project.properties | 2 + mediation/MyTarget/CHANGELOG.md | 13 +- mediation/MyTarget/build.gradle | 2 +- .../Editor/MyTargetMediationDependencies.xml | 6 +- mediation/UnityAds/CHANGELOG.md | 9 +- mediation/UnityAds/build.gradle | 2 +- .../Editor/UnityMediationDependencies.xml | 6 +- .../Scripts/GoogleMobileAdsDemoScript.cs | 92 +---- source/android-library/app/build.gradle | 2 +- .../com/google/unity/ads/NativeExpressAd.java | 328 ------------------ .../google/unity/ads/RewardBasedVideo.java | 5 + .../com/google/unity/ads/UnityAdListener.java | 2 +- .../ads/UnityRewardBasedVideoAdListener.java | 1 + .../Assets/GoogleMobileAds/Api/AdLoader.cs | 1 + .../Assets/GoogleMobileAds/Api/AdRequest.cs | 2 +- .../Assets/GoogleMobileAds/Api/AdSize.cs | 43 ++- .../Api/NativeExpressAdView.cs | 138 -------- .../Api/NativeExpressAdView.cs.meta | 12 - .../GoogleMobileAds/Api/RewardBasedVideoAd.cs | 10 + .../GoogleMobileAds/Common/DummyClient.cs | 29 +- .../Common/INativeExpressAdClient.cs | 59 ---- .../Common/INativeExpressAdClient.cs.meta | 12 - .../Common/IRewardBasedVideoAdClient.cs | 2 + .../Editor/GoogleMobileAdsDependencies.xml | 5 +- .../Android/NativeExpressAdClient.cs | 150 -------- .../Android/NativeExpressAdClient.cs.meta | 12 - .../Android/RewardBasedVideoAdClient.cs | 9 + .../Platforms/Android/Utils.cs | 2 - .../Platforms/GoogleMobileAdsClientFactory.cs | 15 - .../GoogleMobileAds/Platforms/iOS/Externs.cs | 49 +-- .../Platforms/iOS/NativeExpressAdClient.cs | 230 ------------ .../iOS/NativeExpressAdClient.cs.meta | 12 - .../Platforms/iOS/RewardBasedVideoAdClient.cs | 20 +- .../plugin/Assets/Plugins/iOS/GADUAdLoader.h | 3 +- .../plugin/Assets/Plugins/iOS/GADUAdLoader.m | 5 +- .../Assets/Plugins/iOS/GADUAdNetworkExtras.h | 4 +- .../plugin/Assets/Plugins/iOS/GADUInterface.m | 96 +---- .../Plugins/iOS/GADUNativeCustomTemplateAd.m | 2 +- .../Assets/Plugins/iOS/GADUNativeExpressAd.h | 68 ---- .../Plugins/iOS/GADUNativeExpressAd.h.meta | 33 -- .../Assets/Plugins/iOS/GADUNativeExpressAd.m | 172 --------- .../Plugins/iOS/GADUNativeExpressAd.m.meta | 33 -- .../Plugins/iOS/GADURewardBasedVideoAd.h | 3 + .../Plugins/iOS/GADURewardBasedVideoAd.m | 6 + source/plugin/Assets/Plugins/iOS/GADUTypes.h | 34 +- 66 files changed, 604 insertions(+), 1600 deletions(-) create mode 100644 mediation/Chartboost/CHANGELOG.md create mode 100644 mediation/Chartboost/README.md create mode 100644 mediation/Chartboost/build.gradle create mode 100644 mediation/Chartboost/source/plugin/Assets/GoogleMobileAds/Editor/ChartboostMediationDependencies.xml create mode 100644 mediation/Chartboost/source/plugin/Assets/Plugins/Android/GoogleMobileAdsChartboostMediation/AndroidManifest.xml create mode 100644 mediation/Chartboost/source/plugin/Assets/Plugins/Android/GoogleMobileAdsChartboostMediation/project.properties create mode 100644 mediation/MoPub/CHANGELOG.md create mode 100644 mediation/MoPub/README.md create mode 100644 mediation/MoPub/build.gradle create mode 100644 mediation/MoPub/source/plugin/Assets/GoogleMobileAds/Editor/MoPubMediationDependencies.xml create mode 100644 mediation/MoPub/source/plugin/Assets/Plugins/Android/GoogleMobileAdsMoPubMediation/AndroidManifest.xml create mode 100644 mediation/MoPub/source/plugin/Assets/Plugins/Android/GoogleMobileAdsMoPubMediation/project.properties delete mode 100644 source/android-library/app/src/main/java/com/google/unity/ads/NativeExpressAd.java delete mode 100644 source/plugin/Assets/GoogleMobileAds/Api/NativeExpressAdView.cs delete mode 100644 source/plugin/Assets/GoogleMobileAds/Api/NativeExpressAdView.cs.meta delete mode 100644 source/plugin/Assets/GoogleMobileAds/Common/INativeExpressAdClient.cs delete mode 100644 source/plugin/Assets/GoogleMobileAds/Common/INativeExpressAdClient.cs.meta delete mode 100644 source/plugin/Assets/GoogleMobileAds/Platforms/Android/NativeExpressAdClient.cs delete mode 100644 source/plugin/Assets/GoogleMobileAds/Platforms/Android/NativeExpressAdClient.cs.meta delete mode 100644 source/plugin/Assets/GoogleMobileAds/Platforms/iOS/NativeExpressAdClient.cs delete mode 100644 source/plugin/Assets/GoogleMobileAds/Platforms/iOS/NativeExpressAdClient.cs.meta delete mode 100644 source/plugin/Assets/Plugins/iOS/GADUNativeExpressAd.h delete mode 100644 source/plugin/Assets/Plugins/iOS/GADUNativeExpressAd.h.meta delete mode 100644 source/plugin/Assets/Plugins/iOS/GADUNativeExpressAd.m delete mode 100644 source/plugin/Assets/Plugins/iOS/GADUNativeExpressAd.m.meta diff --git a/ChangeLog.txt b/ChangeLog.txt index 46c02695a..49d3270aa 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,13 +1,33 @@ Google Mobile Ads Unity Plugin Change Log +************** +Version 3.13.0 +************** + +Plugin: +- Added `OnAdCompleted` ad event to rewarded video ads. +- Removed support for Native Ads Express. + +Mediation packages: +- Added Chartboost mediation support package. +- Added MoPub mediation support package. +- Updated AppLovin Unity package to v1.2.1. +- Updated AdColony Unity package to v1.0.1. +- Updated myTarget Unity package to v2.0.0. + +Built and tested with: +- Google Play services 12.0.1 +- Google Mobile Ads iOS SDK 7.30.0 +- Unity Jar Resolver 1.2.64.0 + ************** Version 3.12.0 ************** Plugin: -- Add `setUserId` API to rewarded video ads to identify users in +- Added `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 +- Removed functionality that forced ad events to be invoked on the main thread. Mediation packages: diff --git a/mediation/AdColony/CHANGELOG.md b/mediation/AdColony/CHANGELOG.md index bdfbc8b78..9f7c596c7 100644 --- a/mediation/AdColony/CHANGELOG.md +++ b/mediation/AdColony/CHANGELOG.md @@ -1,7 +1,10 @@ # AdColony Adapter plugin for Google Mobile Ads SDK for Unity 3D Changelog -## 1.0.0 +## 1.0.1 +- Supports AdColony Android SDK version 3.3.0-unity. +- Supports AdColony iOS SDK version 3.3.0. +## 1.0.0 - First release! -- Supports Android adapter version 3.3.0.0. -- Supports iOS adapter version 3.3.0.0. +- Supports AdColony Android SDK version 3.3.0. +- Supports AdColony iOS SDK version 3.3.0. diff --git a/mediation/AdColony/build.gradle b/mediation/AdColony/build.gradle index e7158bf58..120aea3bf 100644 --- a/mediation/AdColony/build.gradle +++ b/mediation/AdColony/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 = 'GoogleMobileAdsAdColonyMediation' pluginFileName = "${pluginName}.unitypackage" zipName = "${pluginName}-${versionString}" diff --git a/mediation/AdColony/source/android-library/adcolony/build.gradle b/mediation/AdColony/source/android-library/adcolony/build.gradle index 98f436ae2..631e85e5e 100644 --- a/mediation/AdColony/source/android-library/adcolony/build.gradle +++ b/mediation/AdColony/source/android-library/adcolony/build.gradle @@ -23,7 +23,7 @@ android { dependencies { api project(':app') - api 'com.google.ads.mediation:adcolony:3.3.0.0' + api 'com.google.ads.mediation:adcolony:3.3.2.0' } task clearJar(type: Delete) { diff --git a/mediation/AdColony/source/android-library/adcolony/src/main/java/com/google/unity/mediation/adcolony/AdColonyUnityExtrasBuilder.java b/mediation/AdColony/source/android-library/adcolony/src/main/java/com/google/unity/mediation/adcolony/AdColonyUnityExtrasBuilder.java index f3642f82d..7c9ba2652 100644 --- a/mediation/AdColony/source/android-library/adcolony/src/main/java/com/google/unity/mediation/adcolony/AdColonyUnityExtrasBuilder.java +++ b/mediation/AdColony/source/android-library/adcolony/src/main/java/com/google/unity/mediation/adcolony/AdColonyUnityExtrasBuilder.java @@ -11,7 +11,7 @@ /** * Mediation extras bundle class for the AdColony adapter. */ -public abstract class AdColonyUnityExtrasBuilder implements AdNetworkExtras { +public class AdColonyUnityExtrasBuilder implements AdNetworkExtras { /** * Key to obtain Zone ID. diff --git a/mediation/AdColony/source/plugin/Assets/GoogleMobileAds/Editor/AdColonyMediationDependencies.xml b/mediation/AdColony/source/plugin/Assets/GoogleMobileAds/Editor/AdColonyMediationDependencies.xml index 81fce627a..13863c269 100644 --- a/mediation/AdColony/source/plugin/Assets/GoogleMobileAds/Editor/AdColonyMediationDependencies.xml +++ b/mediation/AdColony/source/plugin/Assets/GoogleMobileAds/Editor/AdColonyMediationDependencies.xml @@ -1,11 +1,11 @@ - + https://adcolony.bintray.com/AdColony - + https://adcolony.bintray.com/AdColony diff --git a/mediation/AdColony/source/plugin/Assets/Plugins/Android/GoogleMobileAdsAdColonyMediation/AndroidManifest.xml b/mediation/AdColony/source/plugin/Assets/Plugins/Android/GoogleMobileAdsAdColonyMediation/AndroidManifest.xml index 1db8ea5b1..b0a5b79a0 100644 --- a/mediation/AdColony/source/plugin/Assets/Plugins/Android/GoogleMobileAdsAdColonyMediation/AndroidManifest.xml +++ b/mediation/AdColony/source/plugin/Assets/Plugins/Android/GoogleMobileAdsAdColonyMediation/AndroidManifest.xml @@ -1,6 +1,6 @@ + package="com.google.unity.mediation.adcolony"> @@ -19,4 +19,4 @@ android:hardwareAccelerated="true" /> - \ No newline at end of file + diff --git a/mediation/AppLovin/CHANGELOG.md b/mediation/AppLovin/CHANGELOG.md index 602790498..344b1b33d 100644 --- a/mediation/AppLovin/CHANGELOG.md +++ b/mediation/AppLovin/CHANGELOG.md @@ -1,5 +1,13 @@ # AppLovin Adapter plugin for Google Mobile Ads SDK for Unity 3D Changelog +## 1.2.1 +- Supports AppLovin Android SDK version 7.8.6. +- Supports AppLovin iOS SDK version 4.8.3. + +## 1.2.0 +- Supports AppLovin Android SDK version 7.8.5. +- Supports AppLovin iOS SDK version 4.8.3. + ## 1.1.0 - Supports AppLovin Android SDK version 7.7.0. - Supports AppLovin iOS SDK version 4.7.0. diff --git a/mediation/AppLovin/build.gradle b/mediation/AppLovin/build.gradle index 0e28180be..801114d4c 100644 --- a/mediation/AppLovin/build.gradle +++ b/mediation/AppLovin/build.gradle @@ -23,7 +23,7 @@ project.ext { 'UNITY_EXE environment variable and point it to your Unity installation.') } - versionString = '1.1.0' + versionString = '1.2.1' pluginName = 'GoogleMobileAdsAppLovinMediation' pluginFileName = "${pluginName}.unitypackage" zipName = "${pluginName}-${versionString}" diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Editor/AppLovinMediationDependencies.xml b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Editor/AppLovinMediationDependencies.xml index 7e46cca41..6ab1df980 100644 --- a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Editor/AppLovinMediationDependencies.xml +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Editor/AppLovinMediationDependencies.xml @@ -1,13 +1,13 @@ - + - + - + https://github.com/CocoaPods/Specs diff --git a/mediation/Chartboost/CHANGELOG.md b/mediation/Chartboost/CHANGELOG.md new file mode 100644 index 000000000..cad1056d8 --- /dev/null +++ b/mediation/Chartboost/CHANGELOG.md @@ -0,0 +1,6 @@ +# Chartboost Adapter plugin for Google Mobile Ads SDK for Unity 3D Changelog + +## 1.0.0 +- First release! +- Supports Chartboost Android SDK version 7.0.1. +- Supports Chartboost iOS SDK version 7.1.2. diff --git a/mediation/Chartboost/README.md b/mediation/Chartboost/README.md new file mode 100644 index 000000000..709642bbd --- /dev/null +++ b/mediation/Chartboost/README.md @@ -0,0 +1,6 @@ +# Chartboost Adapter plugin for Google Mobile Ads SDK for Unity 3D + +This is a plugin to be used in conjunction with the Google Mobile Ads SDK in +Google Play services. For requirements, instructions, and other info, see the +[Chartboost Adapter Integration Guide](https://developers.google.com/admob/unity/mediation/chartboost). + diff --git a/mediation/Chartboost/build.gradle b/mediation/Chartboost/build.gradle new file mode 100644 index 000000000..72d7b173d --- /dev/null +++ b/mediation/Chartboost/build.gradle @@ -0,0 +1,146 @@ +/* +* Gradle file to build a Unity package to add Chartboost mediation support to the Google Mobile +* Ads Unity plugin. +* Usage: ./gradlew exportPackage +*/ +plugins { + id "com.jfrog.bintray" version "1.7.3" +} + +defaultTasks 'exportPackage' + +// Project level variables. +project.ext { + unity_exe = System.getProperty("UNITY_EXE") + if (unity_exe == null || unity_exe.isEmpty()) { + unity_exe = System.getenv("UNITY_EXE") + } + if (unity_exe == null || unity_exe.isEmpty()) { + unity_exe = '/Applications/Unity/Unity.app/Contents/MacOS/Unity' + } + + if (!file(unity_exe).exists()) { + throw new GradleException('Unable to locate installation of Unity. Please create a ' + + 'UNITY_EXE environment variable and point it to your Unity installation.') + } + + versionString = '1.0.0' + pluginName = 'GoogleMobileAdsChartboostMediation' + pluginFileName = "${pluginName}.unitypackage" + zipName = "${pluginName}-${versionString}" + zipFileName = "${zipName}.zip" + pluginSource = file('source/plugin').absolutePath + pluginBuildDir = file('temp/plugin-build-dir').absolutePath + buildPath = file('temp').absolutePath + exportPath = file(pluginFileName).absolutePath +} + +// Build unity package using through command line interface. +// Create new unity project with files in temporary build directory and export files to a unity package. +// Command line usage and arguments documented at http://docs.unity3d.com/Manual/CommandLineArguments.html. +task exportPackage(type: Exec) { + description = "Creates and exports the Plugin unity package" + executable "${unity_exe}" + args "-g.building", + "-batchmode", + "-projectPath", "${pluginBuildDir}", + "-logFile", "temp/unity.log", + "-exportPackage", + "Assets/GoogleMobileAds/Editor", + "Assets/Plugins", + "${exportPath}", + "-quit" + + ignoreExitValue true + + doLast { + if (execResult.getExitValue() != 0) { + copy { + from "temp/" + into "./" + include "unity.log" + } + } + } +} + +task createTempBuildFolder(type: Copy) { + from { "${pluginSource}" } + into { "${pluginBuildDir}" } +} + +task clearTempBuildFolder(type: Delete) { + delete { "${buildPath}" } +} + +exportPackage.dependsOn(createTempBuildFolder) +exportPackage.finalizedBy(clearTempBuildFolder) + +/** + * Delete task to delete any previously generated .zip files by makeZip task. + * makeZip depends on this task. + */ +task clearZip(type: Delete) { + // Targets to be deleted. + delete(zipFileName) +} + +/** + * Zip task to make a zip archive. This task depends on exportPackage and clearZip tasks. + */ +task makeZip(type: Zip) { + // Targets to be added to the zip archive. + from('./' + pluginFileName, './README.md', './CHANGELOG.md') + // Root directory name for the zip archive. + into(zipName) + // Name of the zip archive. + archiveName zipFileName + // Destination directory in which the archive needs to be saved. + destinationDir file('.') +} + +makeZip.dependsOn([clearZip, exportPackage]) +makeZip.mustRunAfter([clearZip, exportPackage]) + +/** + * Bintray closure needed to run the bintrayUpload task. + * + * Usage: + * ./gradlew bintrayUpload -PbintrayUser=YOUR_BINTRAY_USER_ID -PbintrayApiKey=YOUR_BINTRAY_API_KEY + * + * The Bintray User ID and API key can be added to your system environment variables as BINTRAY_USER + * and BINTRAY_API_KEY respectively, and the command can be reduced to: + * ./gradlew bintrayUpload + */ +bintray { + user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') + : System.getenv('BINTRAY_USER') + key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') + : System.getenv('BINTRAY_API_KEY') + + filesSpec { // 'filesSpec' is a standard Gradle CopySpec + from zipFileName + into "${pluginName}/${versionString}" + } + dryRun = false // Deploy after running. + publish = false // Don't auto publish after deploying. + override = false // Don't override existing version artifacts that are already published. + + pkg { + repo = 'mobile-ads-adapters-unity' + name = pluginName + userOrg = 'google' + desc = 'Chartboost plugin for Google Mobile Ads Mediation.' + websiteUrl = 'https://developers.google.com/admob/unity/mediation/chartboost' + issueTrackerUrl = 'https://github.com/googleads/googleads-mobile-unity/issues' + vcsUrl = 'https://github.com/googleads/googleads-mobile-unity' + licenses = ['Apache-2.0'] + + version { + name = versionString + } + } +} + +bintrayUpload.dependsOn(makeZip) +bintrayUpload.mustRunAfter(makeZip) diff --git a/mediation/Chartboost/source/plugin/Assets/GoogleMobileAds/Editor/ChartboostMediationDependencies.xml b/mediation/Chartboost/source/plugin/Assets/GoogleMobileAds/Editor/ChartboostMediationDependencies.xml new file mode 100644 index 000000000..24ea1996f --- /dev/null +++ b/mediation/Chartboost/source/plugin/Assets/GoogleMobileAds/Editor/ChartboostMediationDependencies.xml @@ -0,0 +1,18 @@ + + + + + https://jcenter.bintray.com/ + + + + + + + + https://github.com/CocoaPods/Specs + + + + + diff --git a/mediation/Chartboost/source/plugin/Assets/Plugins/Android/GoogleMobileAdsChartboostMediation/AndroidManifest.xml b/mediation/Chartboost/source/plugin/Assets/Plugins/Android/GoogleMobileAdsChartboostMediation/AndroidManifest.xml new file mode 100644 index 000000000..8dabff5ba --- /dev/null +++ b/mediation/Chartboost/source/plugin/Assets/Plugins/Android/GoogleMobileAdsChartboostMediation/AndroidManifest.xml @@ -0,0 +1,14 @@ + + + + + + + + \ No newline at end of file diff --git a/mediation/Chartboost/source/plugin/Assets/Plugins/Android/GoogleMobileAdsChartboostMediation/project.properties b/mediation/Chartboost/source/plugin/Assets/Plugins/Android/GoogleMobileAdsChartboostMediation/project.properties new file mode 100644 index 000000000..538883e28 --- /dev/null +++ b/mediation/Chartboost/source/plugin/Assets/Plugins/Android/GoogleMobileAdsChartboostMediation/project.properties @@ -0,0 +1,2 @@ +target=android-26 +android.library=true \ No newline at end of file diff --git a/mediation/MoPub/CHANGELOG.md b/mediation/MoPub/CHANGELOG.md new file mode 100644 index 000000000..9984b304b --- /dev/null +++ b/mediation/MoPub/CHANGELOG.md @@ -0,0 +1,6 @@ +# MoPub Adapter plugin for Google Mobile Ads SDK for Unity 3D Changelog + +## 1.0.0 +- First release! +- Supports MoPub Android SDK version 4.20.0. +- Supports MoPub iOS SDK version 4.20.1. diff --git a/mediation/MoPub/README.md b/mediation/MoPub/README.md new file mode 100644 index 000000000..21fbb7c75 --- /dev/null +++ b/mediation/MoPub/README.md @@ -0,0 +1,6 @@ +# MoPub Adapter plugin for Google Mobile Ads SDK for Unity 3D + +This is a plugin to be used in conjunction with the Google Mobile Ads SDK in +Google Play services. For requirements, instructions, and other info, see the +[MoPub Adapter Integration Guide](https://developers.google.com/admob/unity/mediation/mopub). + diff --git a/mediation/MoPub/build.gradle b/mediation/MoPub/build.gradle new file mode 100644 index 000000000..62d74bfc0 --- /dev/null +++ b/mediation/MoPub/build.gradle @@ -0,0 +1,145 @@ +/* +* Gradle file to build a Unity package to add MoPub mediation support to the Google Mobile Ads Unity plugin. +* Usage: ./gradlew exportPackage +*/ +plugins { + id "com.jfrog.bintray" version "1.7.3" +} + +defaultTasks 'exportPackage' + +// Project level variables. +project.ext { + unity_exe = System.getProperty("UNITY_EXE") + if (unity_exe == null || unity_exe.isEmpty()) { + unity_exe = System.getenv("UNITY_EXE") + } + if (unity_exe == null || unity_exe.isEmpty()) { + unity_exe = '/Applications/Unity/Unity.app/Contents/MacOS/Unity' + } + + if (!file(unity_exe).exists()) { + throw new GradleException('Unable to locate installation of Unity. Please create a ' + + 'UNITY_EXE environment variable and point it to your Unity installation.') + } + + versionString = '1.0.0' + pluginName = 'GoogleMobileAdsMoPubMediation' + pluginFileName = "${pluginName}.unitypackage" + zipName = "${pluginName}-${versionString}" + zipFileName = "${zipName}.zip" + pluginSource = file('source/plugin').absolutePath + pluginBuildDir = file('temp/plugin-build-dir').absolutePath + buildPath = file('temp').absolutePath + exportPath = file(pluginFileName).absolutePath +} + +// Build unity package using through command line interface. +// Create new unity project with files in temporary build directory and export files to a unity package. +// Command line usage and arguments documented at http://docs.unity3d.com/Manual/CommandLineArguments.html. +task exportPackage(type: Exec) { + description = "Creates and exports the Plugin unity package" + executable "${unity_exe}" + args "-g.building", + "-batchmode", + "-projectPath", "${pluginBuildDir}", + "-logFile", "temp/unity.log", + "-exportPackage", + "Assets/GoogleMobileAds/Editor", + "Assets/Plugins", + "${exportPath}", + "-quit" + + ignoreExitValue true + + doLast { + if (execResult.getExitValue() != 0) { + copy { + from "temp/" + into "./" + include "unity.log" + } + } + } +} + +task createTempBuildFolder(type: Copy) { + from { "${pluginSource}" } + into { "${pluginBuildDir}" } +} + +task clearTempBuildFolder(type: Delete) { + delete { "${buildPath}" } +} + +exportPackage.dependsOn(createTempBuildFolder) +exportPackage.finalizedBy(clearTempBuildFolder) + +/** + * Delete task to delete any previously generated .zip files by makeZip task. + * makeZip depends on this task. + */ +task clearZip(type: Delete) { + // Targets to be deleted. + delete(zipFileName) +} + +/** + * Zip task to make a zip archive. This task depends on exportPackage and clearZip tasks. + */ +task makeZip(type: Zip) { + // Targets to be added to the zip archive. + from('./' + pluginFileName, './README.md', './CHANGELOG.md') + // Root directory name for the zip archive. + into(zipName) + // Name of the zip archive. + archiveName zipFileName + // Destination directory in which the archive needs to be saved. + destinationDir file('.') +} + +makeZip.dependsOn([clearZip, exportPackage]) +makeZip.mustRunAfter([clearZip, exportPackage]) + +/** + * Bintray closure needed to run the bintrayUpload task. + * + * Usage: + * ./gradlew bintrayUpload -PbintrayUser=YOUR_BINTRAY_USER_ID -PbintrayApiKey=YOUR_BINTRAY_API_KEY + * + * The Bintray User ID and API key can be added to your system environment variables as BINTRAY_USER + * and BINTRAY_API_KEY respectively, and the command can be reduced to: + * ./gradlew bintrayUpload + */ +bintray { + user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') + : System.getenv('BINTRAY_USER') + key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') + : System.getenv('BINTRAY_API_KEY') + + filesSpec { // 'filesSpec' is a standard Gradle CopySpec + from zipFileName + into "${pluginName}/${versionString}" + } + dryRun = false // Deploy after running. + publish = false // Don't auto publish after deploying. + override = false // Don't override existing version artifacts that are already published. + + pkg { + repo = 'mobile-ads-adapters-unity' + name = pluginName + userOrg = 'google' + desc = 'MoPub plugin for Google Mobile Ads Mediation.' + websiteUrl = 'https://developers.google.com/admob/unity/mediation/mopub' + issueTrackerUrl = 'https://github.com/googleads/googleads-mobile-unity/issues' + vcsUrl = 'https://github.com/googleads/googleads-mobile-unity' + licenses = ['Apache-2.0'] + + version { + name = versionString + } + } +} + +bintrayUpload.dependsOn(makeZip) +bintrayUpload.mustRunAfter(makeZip) diff --git a/mediation/MoPub/source/plugin/Assets/GoogleMobileAds/Editor/MoPubMediationDependencies.xml b/mediation/MoPub/source/plugin/Assets/GoogleMobileAds/Editor/MoPubMediationDependencies.xml new file mode 100644 index 000000000..9a17ff7dd --- /dev/null +++ b/mediation/MoPub/source/plugin/Assets/GoogleMobileAds/Editor/MoPubMediationDependencies.xml @@ -0,0 +1,23 @@ + + + + + https://jcenter.bintray.com/ + + + + + https://jcenter.bintray.com/ + + + + + + + + https://github.com/CocoaPods/Specs + + + + + diff --git a/mediation/MoPub/source/plugin/Assets/Plugins/Android/GoogleMobileAdsMoPubMediation/AndroidManifest.xml b/mediation/MoPub/source/plugin/Assets/Plugins/Android/GoogleMobileAdsMoPubMediation/AndroidManifest.xml new file mode 100644 index 000000000..0ae8a7e76 --- /dev/null +++ b/mediation/MoPub/source/plugin/Assets/Plugins/Android/GoogleMobileAdsMoPubMediation/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + diff --git a/mediation/MoPub/source/plugin/Assets/Plugins/Android/GoogleMobileAdsMoPubMediation/project.properties b/mediation/MoPub/source/plugin/Assets/Plugins/Android/GoogleMobileAdsMoPubMediation/project.properties new file mode 100644 index 000000000..3a387fb86 --- /dev/null +++ b/mediation/MoPub/source/plugin/Assets/Plugins/Android/GoogleMobileAdsMoPubMediation/project.properties @@ -0,0 +1,2 @@ +target=android-26 +android.library=true diff --git a/mediation/MyTarget/CHANGELOG.md b/mediation/MyTarget/CHANGELOG.md index aa0517748..76b799946 100644 --- a/mediation/MyTarget/CHANGELOG.md +++ b/mediation/MyTarget/CHANGELOG.md @@ -1,7 +1,14 @@ # myTarget Adapter plugin for Google Mobile Ads SDK for Unity 3D Changelog -## 1.0.0 +## 2.0.0 +- Supports myTarget Android SDK version 5.0.0. +- Supports myTarget iOS SDK version 4.7.7. + +## 1.1.0 +- Supports myTarget Android SDK version 4.7.2. +- Supports myTarget iOS SDK version 4.7.6. +## 1.0.0 - First release! -- Supports Android adapter version 4.6.27.0. -- Supports iOS adapter version 4.6.24.0. +- Supports myTarget Android SDK version 4.6.27. +- Supports myTarget iOS SDK version 4.6.24. diff --git a/mediation/MyTarget/build.gradle b/mediation/MyTarget/build.gradle index f2c754cf3..cca9ef16b 100644 --- a/mediation/MyTarget/build.gradle +++ b/mediation/MyTarget/build.gradle @@ -23,7 +23,7 @@ project.ext { 'UNITY_EXE environment variable and point it to your Unity installation.') } - versionString = '1.0.0' + versionString = '2.0.0' pluginName = 'GoogleMobileAdsMyTargetMediation' pluginFileName = "${pluginName}.unitypackage" zipName = "${pluginName}-${versionString}" diff --git a/mediation/MyTarget/source/plugin/Assets/GoogleMobileAds/Editor/MyTargetMediationDependencies.xml b/mediation/MyTarget/source/plugin/Assets/GoogleMobileAds/Editor/MyTargetMediationDependencies.xml index 88c65b181..31e8a9fec 100644 --- a/mediation/MyTarget/source/plugin/Assets/GoogleMobileAds/Editor/MyTargetMediationDependencies.xml +++ b/mediation/MyTarget/source/plugin/Assets/GoogleMobileAds/Editor/MyTargetMediationDependencies.xml @@ -1,11 +1,11 @@ - + https://google.bintray.com/mobile-ads-adapters-android - + https://dl.bintray.com/mytarget/maven/ @@ -13,7 +13,7 @@ - + https://github.com/CocoaPods/Specs diff --git a/mediation/UnityAds/CHANGELOG.md b/mediation/UnityAds/CHANGELOG.md index 01195a33b..348ea5f1e 100644 --- a/mediation/UnityAds/CHANGELOG.md +++ b/mediation/UnityAds/CHANGELOG.md @@ -1,7 +1,10 @@ # Unity Ads Adapter plugin for Google Mobile Ads SDK for Unity 3D Changelog -## 1.0.0 +## 1.1.0 +- Supports Unity Ads Android SDK version 2.2.0. +- Supports Unity Ads iOS SDK version 2.2.0. +## 1.0.0 - First release! -- Supports Android adapter version 2.1.2.0. -- Supports iOS adapter version 2.1.2.0. +- Supports Unity Ads Android SDK version 2.1.2. +- Supports Unity Ads iOS SDK version 2.1.2. diff --git a/mediation/UnityAds/build.gradle b/mediation/UnityAds/build.gradle index 105c11185..0d9078902 100644 --- a/mediation/UnityAds/build.gradle +++ b/mediation/UnityAds/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.1.0' pluginName = 'GoogleMobileAdsUnityAdsMediation' pluginFileName = "${pluginName}.unitypackage" zipName = "${pluginName}-${versionString}" diff --git a/mediation/UnityAds/source/plugin/Assets/GoogleMobileAds/Editor/UnityMediationDependencies.xml b/mediation/UnityAds/source/plugin/Assets/GoogleMobileAds/Editor/UnityMediationDependencies.xml index 77f1fda31..fe859327c 100644 --- a/mediation/UnityAds/source/plugin/Assets/GoogleMobileAds/Editor/UnityMediationDependencies.xml +++ b/mediation/UnityAds/source/plugin/Assets/GoogleMobileAds/Editor/UnityMediationDependencies.xml @@ -1,11 +1,11 @@ - + https://jcenter.bintray.com/ - + https://jcenter.bintray.com/ @@ -13,7 +13,7 @@ - + https://github.com/CocoaPods/Specs diff --git a/samples/HelloWorld/Assets/Scripts/GoogleMobileAdsDemoScript.cs b/samples/HelloWorld/Assets/Scripts/GoogleMobileAdsDemoScript.cs index 115b8f48b..784a5bc13 100644 --- a/samples/HelloWorld/Assets/Scripts/GoogleMobileAdsDemoScript.cs +++ b/samples/HelloWorld/Assets/Scripts/GoogleMobileAdsDemoScript.cs @@ -1,6 +1,5 @@ using System; using UnityEngine; -using GoogleMobileAds; using GoogleMobileAds.Api; // Example script showing how to invoke the Google Mobile Ads Unity plugin. @@ -8,7 +7,6 @@ public class GoogleMobileAdsDemoScript : MonoBehaviour { private BannerView bannerView; private InterstitialAd interstitial; - private NativeExpressAdView nativeExpressAdView; private RewardBasedVideoAd rewardBasedVideo; private float deltaTime = 0.0f; private static string outputMessage = string.Empty; @@ -123,29 +121,9 @@ public void OnGUI() this.interstitial.Destroy(); } - Rect requestNativeExpressAdRect = new Rect( - columnTwoPosition, - 0.05f * Screen.height, - buttonWidth, - buttonHeight); - if (GUI.Button(requestNativeExpressAdRect, "Request Native\nExpress Ad")) - { - this.RequestNativeExpressAdView(); - } - - Rect destroyNativeExpressAdRect = new Rect( - columnTwoPosition, - 0.225f * Screen.height, - buttonWidth, - buttonHeight); - if (GUI.Button(destroyNativeExpressAdRect, "Destroy Native\nExpress Ad")) - { - this.nativeExpressAdView.Destroy(); - } - Rect requestRewardedRect = new Rect( columnTwoPosition, - 0.4f * Screen.height, + 0.05f * Screen.height, buttonWidth, buttonHeight); if (GUI.Button(requestRewardedRect, "Request\nRewarded Video")) @@ -155,7 +133,7 @@ public void OnGUI() Rect showRewardedRect = new Rect( columnTwoPosition, - 0.575f * Screen.height, + 0.225f * Screen.height, buttonWidth, buttonHeight); if (GUI.Button(showRewardedRect, "Show\nRewarded Video")) @@ -251,42 +229,6 @@ private void RequestInterstitial() this.interstitial.LoadAd(this.CreateAdRequest()); } - private void RequestNativeExpressAdView() - { - // These ad units are configured to always serve test ads. -#if UNITY_EDITOR - string adUnitId = "unused"; -#elif UNITY_ANDROID - string adUnitId = "ca-app-pub-3940256099942544/1072772517"; -#elif UNITY_IPHONE - string adUnitId = "ca-app-pub-3940256099942544/2562852117"; -#else - string adUnitId = "unexpected_platform"; -#endif - - // Clean up native express ad before creating a new one. - if (this.nativeExpressAdView != null) - { - this.nativeExpressAdView.Destroy(); - } - - // Create a 320x150 native express ad at the top of the screen. - this.nativeExpressAdView = new NativeExpressAdView( - adUnitId, - new AdSize(320, 150), - AdPosition.Top); - - // Register for ad events. - this.nativeExpressAdView.OnAdLoaded += this.HandleNativeExpressAdLoaded; - this.nativeExpressAdView.OnAdFailedToLoad += this.HandleNativeExpresseAdFailedToLoad; - this.nativeExpressAdView.OnAdOpening += this.HandleNativeExpressAdOpened; - this.nativeExpressAdView.OnAdClosed += this.HandleNativeExpressAdClosed; - this.nativeExpressAdView.OnAdLeavingApplication += this.HandleNativeExpressAdLeftApplication; - - // Load a native express ad. - this.nativeExpressAdView.LoadAd(this.CreateAdRequest()); - } - private void RequestRewardBasedVideo() { #if UNITY_EDITOR @@ -385,36 +327,6 @@ public void HandleInterstitialLeftApplication(object sender, EventArgs args) #endregion - #region Native express ad callback handlers - - public void HandleNativeExpressAdLoaded(object sender, EventArgs args) - { - MonoBehaviour.print("HandleNativeExpressAdAdLoaded event received"); - } - - public void HandleNativeExpresseAdFailedToLoad(object sender, AdFailedToLoadEventArgs args) - { - MonoBehaviour.print( - "HandleNativeExpressAdFailedToReceiveAd event received with message: " + args.Message); - } - - public void HandleNativeExpressAdOpened(object sender, EventArgs args) - { - MonoBehaviour.print("HandleNativeExpressAdAdOpened event received"); - } - - public void HandleNativeExpressAdClosed(object sender, EventArgs args) - { - MonoBehaviour.print("HandleNativeExpressAdAdClosed event received"); - } - - public void HandleNativeExpressAdLeftApplication(object sender, EventArgs args) - { - MonoBehaviour.print("HandleNativeExpressAdAdLeftApplication event received"); - } - - #endregion - #region RewardBasedVideo callback handlers public void HandleRewardBasedVideoLoaded(object sender, EventArgs args) diff --git a/source/android-library/app/build.gradle b/source/android-library/app/build.gradle index 681be6ed2..21e0b2220 100644 --- a/source/android-library/app/build.gradle +++ b/source/android-library/app/build.gradle @@ -24,7 +24,7 @@ android { dependencies { api fileTree(dir: 'libs', include: ['*.jar']) api 'com.android.support:appcompat-v7:26.1.0' - api 'com.google.android.gms:play-services-ads:11.8.0' + api 'com.google.android.gms:play-services-ads:12.0.1' } task clearJar(type: Delete) { diff --git a/source/android-library/app/src/main/java/com/google/unity/ads/NativeExpressAd.java b/source/android-library/app/src/main/java/com/google/unity/ads/NativeExpressAd.java deleted file mode 100644 index 852a8a253..000000000 --- a/source/android-library/app/src/main/java/com/google/unity/ads/NativeExpressAd.java +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Copyright (C) 2015 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. - */ -package com.google.unity.ads; - -import android.app.Activity; -import android.graphics.Color; -import android.os.Build; -import android.util.Log; -import android.view.Gravity; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewParent; -import android.view.WindowManager; -import android.widget.PopupWindow; -import com.google.android.gms.ads.AdListener; -import com.google.android.gms.ads.AdRequest; -import com.google.android.gms.ads.AdSize; -import com.google.android.gms.ads.NativeExpressAdView; - -/** - * Native express ad implementation for the Google Mobile Ads Unity plugin. - */ -public class NativeExpressAd { - - /** - * The {@link NativeExpressAdView} to display to the user. - */ - private NativeExpressAdView mAdView; - - /** - * The {@link Activity} that the native express ad will be displayed in. - */ - private Activity mUnityPlayerActivity; - - /** - * The {@code PopupWindow} that the banner ad be displayed in to ensure banner ads will be - * presented over a {@code SurfaceView}. - */ - private PopupWindow mPopupWindow; - - /** - * A code indicating where to place the ad. - */ - private int mPositionCode; - - /** - * Offset for the ad in the x-axis when a custom position is used. Value will be 0 for - * non-custom positions. - */ - private int mHorizontalOffset; - - /** - * Offset for the ad in the y-axis when a custom position is used. Value will be 0 for - * non-custom positions. - */ - private int mVerticalOffset; - - /** - * A boolean indicating whether the ad has been hidden. - */ - private boolean mHidden; - - /** - * A listener implemented in Unity via {@code AndroidJavaProxy} to receive ad events. - */ - private UnityAdListener mUnityListener; - - /** - * Creates an instance of {@code NativeExpressAd}. - * - * @param activity The {@link Activity} that will contain an ad. - * @param listener The {@link UnityAdListener} used to receive ad events in Unity. - */ - public NativeExpressAd(Activity activity, UnityAdListener listener) { - this.mUnityPlayerActivity = activity; - this.mUnityListener = listener; - } - - /** - * Creates a {@link NativeExpressAdView} to hold native express ads. - * - * @param publisherId Your ad unit ID. - * @param adSize The size of the native express ad. - * @param positionCode A code indicating where to place the ad. - */ - public void create(final String publisherId, final AdSize adSize, final int positionCode) { - mUnityPlayerActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - createNativeExpressAdView(publisherId, adSize); - createPopupWindow(); - mPositionCode = positionCode; - mHorizontalOffset = 0; - mVerticalOffset = 0; - mHidden = false; - } - }); - } - - /** - * Creates a {@link NativeExpressAdView} to hold native express ads with a custom position. - * - * @param publisherId Your ad unit ID. - * @param adSize The size of the native express ad. - * @param positionX Position of native express ad on the x axis. - * @param positionY Position of native express ad on the y axis. - */ - public void create(final String publisherId, final AdSize adSize, final int positionX, final - int positionY) { - mUnityPlayerActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - createNativeExpressAdView(publisherId, adSize); - createPopupWindow(); - mPositionCode = PluginUtils.POSITION_CUSTOM; - mHorizontalOffset = positionX; - mVerticalOffset = positionY; - mHidden = false; - } - }); - } - - public void createNativeExpressAdView(final String publisherId, final AdSize adSize) { - mAdView = new NativeExpressAdView(mUnityPlayerActivity); - // Setting the background color works around an issue where the first ad isn't - // visible. - mAdView.setBackgroundColor(Color.TRANSPARENT); - mAdView.setAdUnitId(publisherId); - mAdView.setAdSize(adSize); - mAdView.setAdListener(new AdListener() { - @Override - public void onAdLoaded() { - if (mUnityListener != null) { - if (!mPopupWindow.isShowing() && !mHidden) { - showPopUpWindow(); - } - mUnityListener.onAdLoaded(); - } - } - - @Override - public void onAdFailedToLoad(int errorCode) { - if (mUnityListener != null) { - mUnityListener.onAdFailedToLoad(PluginUtils.getErrorReason(errorCode)); - } - } - - @Override - public void onAdOpened() { - if (mUnityListener != null) { - mUnityListener.onAdOpened(); - } - } - - @Override - public void onAdClosed() { - if (mUnityListener != null) { - mUnityListener.onAdClosed(); - } - } - - @Override - public void onAdLeftApplication() { - if (mUnityListener != null) { - mUnityListener.onAdLeftApplication(); - } - } - }); - - } - - public void createPopupWindow() { - int popUpWindowWidth = mAdView.getAdSize().getWidthInPixels(mUnityPlayerActivity); - int popUpWindowHeight = mAdView.getAdSize().getHeightInPixels(mUnityPlayerActivity); - mPopupWindow = new PopupWindow(mAdView, popUpWindowWidth, popUpWindowHeight); - - // Copy system UI visibility flags set on Unity player window to newly created PopUpWindow. - int visibilityFlags = mUnityPlayerActivity.getWindow().getAttributes().flags; - mPopupWindow.getContentView().setSystemUiVisibility(visibilityFlags); - - // Workaround to prevent ad views from losing visibility on activity changes for certain - // devices (eg. Huawei devices). - PluginUtils.setPopUpWindowLayoutType(mPopupWindow, - WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL); - - } - - private void showPopUpWindow() { - View anchorView = mUnityPlayerActivity.getWindow().getDecorView().getRootView(); - - if (this.mPositionCode == PluginUtils.POSITION_CUSTOM) { - // Android Nougat has a PopUpWindow bug gravity doesn't position views as expected. - // Using offset values as a workaround. On certain devices (ie. Samsung S8) calls to - // update() cause the PopUpWindow to be rendered at the top of the screen. Using - // showAsDropDown() instead of showAtLocation() (when possible) avoids this issue. - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - mPopupWindow.showAsDropDown(anchorView, - (int) PluginUtils.convertDpToPixel(mHorizontalOffset), - -anchorView.getHeight() - + (int) PluginUtils.convertDpToPixel(mVerticalOffset)); - } else { - mPopupWindow.showAtLocation( - anchorView, Gravity.NO_GRAVITY, - (int) PluginUtils.convertDpToPixel(mHorizontalOffset), - (int) PluginUtils.convertDpToPixel(mVerticalOffset)); - } - } else { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - int adViewWidth = mAdView.getAdSize().getWidthInPixels(mUnityPlayerActivity); - int adViewHeight = mAdView.getAdSize().getHeightInPixels(mUnityPlayerActivity); - - mPopupWindow.showAsDropDown(anchorView, - PluginUtils.getHorizontalOffsetForPositionCode(mPositionCode, adViewWidth, - anchorView.getWidth()), - PluginUtils.getVerticalOffsetForPositionCode(mPositionCode, adViewHeight, - anchorView.getHeight())); - } else { - mPopupWindow.showAtLocation(anchorView, - PluginUtils.getLayoutGravityForPositionCode(mPositionCode), 0, 0); - } - } - } - - /** - * Loads an ad on a background thread. - * - * @param request The {@link AdRequest} object with targeting parameters. - */ - public void loadAd(final AdRequest request) { - mUnityPlayerActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - Log.d(PluginUtils.LOGTAG, "Calling loadAd() on NativeExpressAdView"); - mAdView.loadAd(request); - } - }); - } - - /** - * Returns the mediation adapter class name. In the case of a mediated ad response, this is the - * name of the class that was responsible for performing the ad request and rendering the ad. - * For non-mediated responses, this value will be {@code null}. - */ - public String getMediationAdapterClassName() { - return mAdView != null ? mAdView.getMediationAdapterClassName() : null; - } - - /** - * Sets the ad size for the {@link NativeExpressAdView}. - */ - public void setAdSize(final AdSize adSize) { - mUnityPlayerActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - mAdView.setAdSize(adSize); - } - }); - } - - /** - * Sets the {@link NativeExpressAdView} to be visible. - */ - public void show() { - mUnityPlayerActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - Log.d(PluginUtils.LOGTAG, "Calling show() on NativeExpressAdView"); - mHidden = false; - mAdView.setVisibility(View.VISIBLE); - mPopupWindow.setTouchable(true); - mPopupWindow.update(); - if (!mPopupWindow.isShowing()) { - showPopUpWindow(); - } - mAdView.resume(); - } - }); - } - - /** - * Sets the {@link NativeExpressAdView} to be gone. - */ - public void hide() { - mUnityPlayerActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - Log.d(PluginUtils.LOGTAG, "Calling hide() on NativeExpressAdView"); - mHidden = true; - mAdView.setVisibility(View.GONE); - mPopupWindow.setTouchable(false); - mPopupWindow.update(); - mAdView.pause(); - } - }); - } - - /** - * Destroys the {@link NativeExpressAdView}. - */ - public void destroy() { - mUnityPlayerActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - Log.d(PluginUtils.LOGTAG, "Calling destroy() on NativeExpressAdView"); - mAdView.destroy(); - mPopupWindow.dismiss(); - ViewParent parentView = mAdView.getParent(); - if (parentView != null && parentView instanceof ViewGroup) { - ((ViewGroup) parentView).removeView(mAdView); - } - } - }); - } -} - 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 f39b59fd0..8d938ff45 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 @@ -99,6 +99,11 @@ public void onRewarded(RewardItem reward) { public void onRewardedVideoAdLeftApplication() { adListener.onAdLeftApplication(); } + + @Override + public void onRewardedVideoCompleted() { + adListener.onAdCompleted(); + } }); } }); diff --git a/source/android-library/app/src/main/java/com/google/unity/ads/UnityAdListener.java b/source/android-library/app/src/main/java/com/google/unity/ads/UnityAdListener.java index d4cc562b3..0c0c1e4f0 100644 --- a/source/android-library/app/src/main/java/com/google/unity/ads/UnityAdListener.java +++ b/source/android-library/app/src/main/java/com/google/unity/ads/UnityAdListener.java @@ -16,7 +16,7 @@ package com.google.unity.ads; /** - * An interface form of {@link UnityBannerAdListener} that can be implemented via + * An interface form of {@link UnityAdListener} that can be implemented via * {@code AndroidJavaProxy} in Unity to receive ad events synchronously. */ public interface UnityAdListener { diff --git a/source/android-library/app/src/main/java/com/google/unity/ads/UnityRewardBasedVideoAdListener.java b/source/android-library/app/src/main/java/com/google/unity/ads/UnityRewardBasedVideoAdListener.java index 23aa5e974..2c5907880 100644 --- a/source/android-library/app/src/main/java/com/google/unity/ads/UnityRewardBasedVideoAdListener.java +++ b/source/android-library/app/src/main/java/com/google/unity/ads/UnityRewardBasedVideoAdListener.java @@ -27,4 +27,5 @@ public interface UnityRewardBasedVideoAdListener { void onAdClosed(); void onAdRewarded(String type, float amount); void onAdLeftApplication(); + void onAdCompleted(); } diff --git a/source/plugin/Assets/GoogleMobileAds/Api/AdLoader.cs b/source/plugin/Assets/GoogleMobileAds/Api/AdLoader.cs index f446dc1a8..2021daef1 100644 --- a/source/plugin/Assets/GoogleMobileAds/Api/AdLoader.cs +++ b/source/plugin/Assets/GoogleMobileAds/Api/AdLoader.cs @@ -104,6 +104,7 @@ internal Dictionary> get; private set; } + public Builder ForCustomNativeAd(string templateId) { this.TemplateIds.Add(templateId); diff --git a/source/plugin/Assets/GoogleMobileAds/Api/AdRequest.cs b/source/plugin/Assets/GoogleMobileAds/Api/AdRequest.cs index 754a52b88..394d6b83d 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.12.0"; + public const string Version = "3.13.0"; public const string TestDeviceSimulator = "SIMULATOR"; private AdRequest(Builder builder) diff --git a/source/plugin/Assets/GoogleMobileAds/Api/AdSize.cs b/source/plugin/Assets/GoogleMobileAds/Api/AdSize.cs index 1e16e5683..b7f3954d9 100644 --- a/source/plugin/Assets/GoogleMobileAds/Api/AdSize.cs +++ b/source/plugin/Assets/GoogleMobileAds/Api/AdSize.cs @@ -12,8 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace GoogleMobileAds.Api { - public class AdSize { +namespace GoogleMobileAds.Api +{ + public class AdSize + { private bool isSmartBanner; private int width; private int height; @@ -25,13 +27,15 @@ public class AdSize { public static readonly AdSize SmartBanner = new AdSize(true); public static readonly int FullWidth = -1; - public AdSize(int width, int height) { + public AdSize(int width, int height) + { isSmartBanner = false; this.width = width; this.height = height; } - private AdSize(bool isSmartBanner) : this(0, 0) { + private AdSize(bool isSmartBanner) : this(0, 0) + { this.isSmartBanner = isSmartBanner; } @@ -58,5 +62,36 @@ public bool IsSmartBanner return isSmartBanner; } } + + public override bool Equals(object obj) + { + if (obj == null || GetType() != obj.GetType()) + return false; + + AdSize other = (AdSize)obj; + return (width == other.width) && (height == other.height) && (isSmartBanner == other.isSmartBanner); + } + + public static bool operator ==(AdSize a, AdSize b) + { + return a.Equals(b); + } + + public static bool operator !=(AdSize a, AdSize b) + { + return !a.Equals(b); + } + + public override int GetHashCode() + { + int hashBase = 71; + int hashMultiplier = 11; + + int hash = hashBase; + hash = (hash * hashMultiplier) ^ width.GetHashCode(); + hash = (hash * hashMultiplier) ^ height.GetHashCode(); + hash = (hash * hashMultiplier) ^ isSmartBanner.GetHashCode(); + return hash; + } } } diff --git a/source/plugin/Assets/GoogleMobileAds/Api/NativeExpressAdView.cs b/source/plugin/Assets/GoogleMobileAds/Api/NativeExpressAdView.cs deleted file mode 100644 index 548b9aa1d..000000000 --- a/source/plugin/Assets/GoogleMobileAds/Api/NativeExpressAdView.cs +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (C) 2016 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.Reflection; - -using GoogleMobileAds.Common; - -namespace GoogleMobileAds.Api -{ - public class NativeExpressAdView - { - private INativeExpressAdClient client; - - // Creates a NativeExpressAd and adds it to the view hierarchy. - public NativeExpressAdView(string adUnitId, AdSize adSize, AdPosition position) - { - Type googleMobileAdsClientFactory = Type.GetType( - "GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp"); - MethodInfo method = googleMobileAdsClientFactory.GetMethod( - "BuildNativeExpressAdClient", - BindingFlags.Static | BindingFlags.Public); - this.client = (INativeExpressAdClient)method.Invoke(null, null); - this.client.CreateNativeExpressAdView(adUnitId, adSize, position); - - ConfigureNativeExpressAdEvents(); - } - - // Creates a NativeExpressAd with a custom position. - public NativeExpressAdView(string adUnitId, AdSize adSize, int x, int y) - { - Type googleMobileAdsClientFactory = Type.GetType( - "GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp"); - MethodInfo method = googleMobileAdsClientFactory.GetMethod( - "BuildNativeExpressAdClient", - BindingFlags.Static | BindingFlags.Public); - this.client = (INativeExpressAdClient)method.Invoke(null, null); - this.client.CreateNativeExpressAdView(adUnitId, adSize, x, y); - - ConfigureNativeExpressAdEvents(); - } - - // These are the ad callback events that can be hooked into. - public event EventHandler OnAdLoaded; - - public event EventHandler OnAdFailedToLoad; - - public event EventHandler OnAdOpening; - - public event EventHandler OnAdClosed; - - public event EventHandler OnAdLeavingApplication; - - // Loads a native express ad. - public void LoadAd(AdRequest request) - { - this.client.LoadAd(request); - } - - // Hides the NativeExpressAdView from the screen. - public void Hide() - { - this.client.HideNativeExpressAdView(); - } - - // Shows the NativeExpressAdView on the screen. - public void Show() - { - this.client.ShowNativeExpressAdView(); - } - - // Destroys the NativeExpressAdView. - public void Destroy() - { - this.client.DestroyNativeExpressAdView(); - } - - private void ConfigureNativeExpressAdEvents() - { - this.client.OnAdLoaded += (sender, args) => - { - if (this.OnAdLoaded != null) - { - this.OnAdLoaded(this, args); - } - }; - - this.client.OnAdFailedToLoad += (sender, args) => - { - if (this.OnAdFailedToLoad != null) - { - this.OnAdFailedToLoad(this, args); - } - }; - - this.client.OnAdOpening += (sender, args) => - { - if (this.OnAdOpening != null) - { - this.OnAdOpening(this, args); - } - }; - - this.client.OnAdClosed += (sender, args) => - { - if (this.OnAdClosed != null) - { - this.OnAdClosed(this, args); - } - }; - - this.client.OnAdLeavingApplication += (sender, args) => - { - if (this.OnAdLeavingApplication != null) - { - this.OnAdLeavingApplication(this, args); - } - }; - } - - // Returns the mediation adapter class name. - public string MediationAdapterClassName() - { - return this.client.MediationAdapterClassName(); - } - } -} diff --git a/source/plugin/Assets/GoogleMobileAds/Api/NativeExpressAdView.cs.meta b/source/plugin/Assets/GoogleMobileAds/Api/NativeExpressAdView.cs.meta deleted file mode 100644 index 2e9463ec1..000000000 --- a/source/plugin/Assets/GoogleMobileAds/Api/NativeExpressAdView.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 92d8da4994b504efebe2dd8d27be7f91 -timeCreated: 1468967775 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/source/plugin/Assets/GoogleMobileAds/Api/RewardBasedVideoAd.cs b/source/plugin/Assets/GoogleMobileAds/Api/RewardBasedVideoAd.cs index 6bdf8ebaa..27f3e26e6 100644 --- a/source/plugin/Assets/GoogleMobileAds/Api/RewardBasedVideoAd.cs +++ b/source/plugin/Assets/GoogleMobileAds/Api/RewardBasedVideoAd.cs @@ -98,6 +98,14 @@ private RewardBasedVideoAd() this.OnAdRewarded(this, args); } }; + + this.client.OnAdCompleted += (sender, args) => + { + if (this.OnAdCompleted != null) + { + this.OnAdCompleted(this, args); + } + }; } // These are the ad callback events that can be hooked into. @@ -115,6 +123,8 @@ private RewardBasedVideoAd() public event EventHandler OnAdLeavingApplication; + public event EventHandler OnAdCompleted; + // Loads a new reward based video ad request public void LoadAd(AdRequest request, string adUnitId) { diff --git a/source/plugin/Assets/GoogleMobileAds/Common/DummyClient.cs b/source/plugin/Assets/GoogleMobileAds/Common/DummyClient.cs index b1d084354..b38e79c02 100644 --- a/source/plugin/Assets/GoogleMobileAds/Common/DummyClient.cs +++ b/source/plugin/Assets/GoogleMobileAds/Common/DummyClient.cs @@ -21,7 +21,7 @@ namespace GoogleMobileAds.Common { public class DummyClient : IBannerClient, IInterstitialClient, IRewardBasedVideoAdClient, - IAdLoaderClient, INativeExpressAdClient, IMobileAdsClient + IAdLoaderClient, IMobileAdsClient { public DummyClient() { @@ -45,6 +45,8 @@ public DummyClient() public event EventHandler OnAdLeavingApplication; + public event EventHandler OnAdCompleted; + public event EventHandler OnCustomNativeTemplateAdLoaded; #pragma warning restore 67 @@ -191,36 +193,11 @@ public void Load(AdRequest request) Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); } - public void CreateNativeExpressAdView(string adUnitId, AdSize adSize, AdPosition position) - { - Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); - } - - public void CreateNativeExpressAdView(string adUnitId, AdSize adSize, int positionX, int positionY) - { - Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); - } - public void SetAdSize(AdSize adSize) { Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); } - public void ShowNativeExpressAdView() - { - Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); - } - - public void HideNativeExpressAdView() - { - Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); - } - - public void DestroyNativeExpressAdView() - { - Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); - } - public string MediationAdapterClassName() { Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); diff --git a/source/plugin/Assets/GoogleMobileAds/Common/INativeExpressAdClient.cs b/source/plugin/Assets/GoogleMobileAds/Common/INativeExpressAdClient.cs deleted file mode 100644 index 7715e76f2..000000000 --- a/source/plugin/Assets/GoogleMobileAds/Common/INativeExpressAdClient.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2016 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 GoogleMobileAds.Api; - -namespace GoogleMobileAds.Common -{ - public interface INativeExpressAdClient - { - // Fired when the native express ad has been received. - event EventHandler OnAdLoaded; - - // Fired when the native express ad has failed to load. - event EventHandler OnAdFailedToLoad; - - // Fired when the native express ad is opened. - event EventHandler OnAdOpening; - - // Fired when the native express ad is closed. - event EventHandler OnAdClosed; - - // Fired when the native express ad is leaving the application. - event EventHandler OnAdLeavingApplication; - - // Creates a native express ad view and adds it to the view hierarchy. - void CreateNativeExpressAdView(string adUnitId, AdSize adSize, AdPosition position); - - // Creates a native express ad view and adds it to the view hierarchy with a custom position. - void CreateNativeExpressAdView(string adUnitId, AdSize adSize, int x, int y); - - // Requests a new ad for the native express ad view. - void LoadAd(AdRequest request); - - // Shows the native express ad view on the screen. - void ShowNativeExpressAdView(); - - // Hides the native express ad view from the screen. - void HideNativeExpressAdView(); - - // Destroys a native express ad view. - void DestroyNativeExpressAdView(); - - // Returns the mediation adapter class name. - string MediationAdapterClassName(); - } -} diff --git a/source/plugin/Assets/GoogleMobileAds/Common/INativeExpressAdClient.cs.meta b/source/plugin/Assets/GoogleMobileAds/Common/INativeExpressAdClient.cs.meta deleted file mode 100644 index cda369e74..000000000 --- a/source/plugin/Assets/GoogleMobileAds/Common/INativeExpressAdClient.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c308cd3fb69524349a551e477b3bbf37 -timeCreated: 1468967775 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/source/plugin/Assets/GoogleMobileAds/Common/IRewardBasedVideoAdClient.cs b/source/plugin/Assets/GoogleMobileAds/Common/IRewardBasedVideoAdClient.cs index 584e30864..b72fc23e1 100644 --- a/source/plugin/Assets/GoogleMobileAds/Common/IRewardBasedVideoAdClient.cs +++ b/source/plugin/Assets/GoogleMobileAds/Common/IRewardBasedVideoAdClient.cs @@ -34,6 +34,8 @@ public interface IRewardBasedVideoAdClient event EventHandler OnAdClosed; // Ad event fired when the reward based video ad is leaving the application. event EventHandler OnAdLeavingApplication; + // Ad event fired when the reward based video ad completes playing. + event EventHandler OnAdCompleted; // Creates a reward based video ad and adds it to the view hierarchy. void CreateRewardBasedVideoAd(); diff --git a/source/plugin/Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml b/source/plugin/Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml index 97438d585..ee7d5d24c 100644 --- a/source/plugin/Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml +++ b/source/plugin/Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml @@ -1,8 +1,8 @@ - + - https://maven.google.com + https://maven.google.com/ @@ -15,4 +15,3 @@ - diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/Android/NativeExpressAdClient.cs b/source/plugin/Assets/GoogleMobileAds/Platforms/Android/NativeExpressAdClient.cs deleted file mode 100644 index 66d4288aa..000000000 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/Android/NativeExpressAdClient.cs +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (C) 2016 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. - -#if UNITY_ANDROID - -using System; - -using GoogleMobileAds.Api; -using GoogleMobileAds.Common; -using UnityEngine; - -namespace GoogleMobileAds.Android -{ - public class NativeExpressAdClient : AndroidJavaProxy, INativeExpressAdClient - { - private AndroidJavaObject nativeExpressAdView; - - public NativeExpressAdClient() : base(Utils.UnityAdListenerClassName) - { - AndroidJavaClass playerClass = new AndroidJavaClass(Utils.UnityActivityClassName); - AndroidJavaObject activity = - playerClass.GetStatic("currentActivity"); - this.nativeExpressAdView = new AndroidJavaObject( - Utils.NativeExpressAdViewClassName, activity, this); - } - - public event EventHandler OnAdLoaded; - - public event EventHandler OnAdFailedToLoad; - - public event EventHandler OnAdOpening; - - public event EventHandler OnAdClosed; - - public event EventHandler OnAdLeavingApplication; - - // Creates a native express ad view. - public void CreateNativeExpressAdView(string adUnitId, AdSize adSize, AdPosition position) - { - this.nativeExpressAdView.Call( - "create", - new object[3] { adUnitId, Utils.GetAdSizeJavaObject(adSize), (int)position }); - } - - // Creates a native express ad view with a custom position - public void CreateNativeExpressAdView(string adUnitId, AdSize adSize, int x, int y) - { - this.nativeExpressAdView.Call( - "create", - new object[4] { adUnitId, Utils.GetAdSizeJavaObject(adSize), x, y }); - } - - // Loads an ad. - public void LoadAd(AdRequest request) - { - this.nativeExpressAdView.Call("loadAd", Utils.GetAdRequestJavaObject(request)); - } - - // Set the ad size for the native express ad view. - public void SetAdSize(AdSize adSize) - { - this.nativeExpressAdView.Call("setAdSize", Utils.GetAdSizeJavaObject(adSize)); - } - - // Displays the native express ad view on the screen. - public void ShowNativeExpressAdView() - { - this.nativeExpressAdView.Call("show"); - } - - // Hides the native express ad view from the screen. - public void HideNativeExpressAdView() - { - this.nativeExpressAdView.Call("hide"); - } - - // Destroys the native express ad view. - public void DestroyNativeExpressAdView() - { - this.nativeExpressAdView.Call("destroy"); - } - - // Returns the mediation adapter class name. - public string MediationAdapterClassName() - { - return this.nativeExpressAdView.Call("getMediationAdapterClassName"); - } - -#region Callbacks from UnityAdListener. - - public void onAdLoaded() - { - if (this.OnAdLoaded != null) - { - this.OnAdLoaded(this, EventArgs.Empty); - } - } - - public void onAdFailedToLoad(string errorReason) - { - if (this.OnAdFailedToLoad != null) - { - AdFailedToLoadEventArgs args = new AdFailedToLoadEventArgs() - { - Message = errorReason - }; - this.OnAdFailedToLoad(this, args); - } - } - - public void onAdOpened() - { - if (this.OnAdOpening != null) - { - this.OnAdOpening(this, EventArgs.Empty); - } - } - - public void onAdClosed() - { - if (this.OnAdClosed != null) - { - this.OnAdClosed(this, EventArgs.Empty); - } - } - - public void onAdLeftApplication() - { - if (this.OnAdLeavingApplication != null) - { - this.OnAdLeavingApplication(this, EventArgs.Empty); - } - } - -#endregion - } -} - -#endif diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/Android/NativeExpressAdClient.cs.meta b/source/plugin/Assets/GoogleMobileAds/Platforms/Android/NativeExpressAdClient.cs.meta deleted file mode 100644 index 051a9373f..000000000 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/Android/NativeExpressAdClient.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: da0c9216600c944caba37e742f0b0c38 -timeCreated: 1468969122 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/Android/RewardBasedVideoAdClient.cs b/source/plugin/Assets/GoogleMobileAds/Platforms/Android/RewardBasedVideoAdClient.cs index 66762d56d..1e5e12bc5 100644 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/Android/RewardBasedVideoAdClient.cs +++ b/source/plugin/Assets/GoogleMobileAds/Platforms/Android/RewardBasedVideoAdClient.cs @@ -33,6 +33,7 @@ public class RewardBasedVideoAdClient : AndroidJavaProxy, IRewardBasedVideoAdCli public event EventHandler OnAdClosed = delegate { }; public event EventHandler OnAdRewarded = delegate { }; public event EventHandler OnAdLeavingApplication = delegate { }; + public event EventHandler OnAdCompleted = delegate { }; public RewardBasedVideoAdClient() : base(Utils.UnityRewardBasedVideoAdListenerClassName) @@ -151,6 +152,14 @@ void onAdLeftApplication() } } + void onAdCompleted() + { + if (this.OnAdCompleted != null) + { + this.OnAdCompleted(this, EventArgs.Empty); + } + } + #endregion } } diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/Android/Utils.cs b/source/plugin/Assets/GoogleMobileAds/Platforms/Android/Utils.cs index 767ebf866..f0e748ddb 100644 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/Android/Utils.cs +++ b/source/plugin/Assets/GoogleMobileAds/Platforms/Android/Utils.cs @@ -57,8 +57,6 @@ internal class Utils public const string RewardBasedVideoClassName = "com.google.unity.ads.RewardBasedVideo"; - public const string NativeExpressAdViewClassName = "com.google.unity.ads.NativeExpressAd"; - public const string NativeAdLoaderClassName = "com.google.unity.ads.NativeAdLoader"; public const string UnityAdListenerClassName = "com.google.unity.ads.UnityAdListener"; diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/GoogleMobileAdsClientFactory.cs b/source/plugin/Assets/GoogleMobileAds/Platforms/GoogleMobileAdsClientFactory.cs index eafd5e5b4..ffd418b77 100644 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/GoogleMobileAdsClientFactory.cs +++ b/source/plugin/Assets/GoogleMobileAds/Platforms/GoogleMobileAdsClientFactory.cs @@ -79,21 +79,6 @@ public static IAdLoaderClient BuildAdLoaderClient(AdLoader adLoader) #endif } - public static INativeExpressAdClient BuildNativeExpressAdClient() - { - #if UNITY_EDITOR - // Testing UNITY_EDITOR first because the editor also responds to the currently - // selected platform. - return new GoogleMobileAds.Common.DummyClient(); - #elif UNITY_ANDROID - return new GoogleMobileAds.Android.NativeExpressAdClient(); - #elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE - return new GoogleMobileAds.iOS.NativeExpressAdClient(); - #else - return new GoogleMobileAds.Common.DummyClient(); - #endif - } - public static IMobileAdsClient MobileAdsInstance() { #if UNITY_EDITOR diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Externs.cs b/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Externs.cs index 09bfa2c99..b9029af34 100644 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Externs.cs +++ b/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Externs.cs @@ -203,7 +203,8 @@ internal static extern void GADUSetRewardBasedVideoAdCallbacks( RewardBasedVideoAdClient.GADURewardBasedVideoAdDidCloseCallback didCloseCallback, RewardBasedVideoAdClient.GADURewardBasedVideoAdDidRewardCallback didRewardcallback, RewardBasedVideoAdClient.GADURewardBasedVideoAdWillLeaveApplicationCallback - willLeaveCallback); + willLeaveCallback, + RewardBasedVideoAdClient.GADURewardBasedVideoAdDidCompleteCallback didCompleteCallback); [DllImport("__Internal")] internal static extern string GADUMediationAdapterClassNameForRewardedVideo(IntPtr rewardedVideo); @@ -214,7 +215,10 @@ internal static extern void GADUSetRewardBasedVideoAdCallbacks( [DllImport("__Internal")] internal static extern IntPtr GADUCreateAdLoader( - IntPtr adLoader, string adUnitId, string[] templateIds, int templateIdsCount, + IntPtr adLoader, + string adUnitId, + string[] templateIds, + int templateIdsCount, ref NativeAdTypes types); [DllImport("__Internal")] @@ -270,47 +274,6 @@ internal static extern void GADUSetNativeCustomTemplateAdCallbacks( #endregion - #region Native Express externs - - [DllImport("__Internal")] - internal static extern IntPtr GADUCreateNativeExpressAdView( - IntPtr nativeExpressClient, string adUnitId, int width, int height, int positionAtTop); - - [DllImport("__Internal")] - internal static extern IntPtr GADUCreateNativeExpressAdViewWithCustomPosition( - IntPtr bannerClient, - string adUnitId, - int width, - int height, - int x, - int y); - - [DllImport("__Internal")] - internal static extern void GADUSetNativeExpressAdCallbacks( - IntPtr bannerView, - NativeExpressAdClient.GADUNativeExpressAdViewDidReceiveAdCallback adReceivedCallback, - NativeExpressAdClient.GADUNativeExpressAdViewDidFailToReceiveAdWithErrorCallback adFailedCallback, - NativeExpressAdClient.GADUNativeExpressAdViewWillPresentScreenCallback willPresentCallback, - NativeExpressAdClient.GADUNativeExpressAdViewDidDismissScreenCallback didDismissCallback, - NativeExpressAdClient.GADUNativeExpressAdViewWillLeaveApplicationCallback willLeaveCallback); - - [DllImport("__Internal")] - internal static extern void GADUHideNativeExpressAdView(IntPtr nativeExpresAdView); - - [DllImport("__Internal")] - internal static extern void GADUShowNativeExpressAdView(IntPtr nativeExpresAdView); - - [DllImport("__Internal")] - internal static extern void GADURemoveNativeExpressAdView(IntPtr nativeExpresAdView); - - [DllImport("__Internal")] - internal static extern void GADURequestNativeExpressAd(IntPtr nativeExpresAdView, IntPtr request); - - [DllImport("__Internal")] - internal static extern string GADUMediationAdapterClassNameForNativeExpressAdView(IntPtr nativeExpressAdView); - - #endregion - } } diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/NativeExpressAdClient.cs b/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/NativeExpressAdClient.cs deleted file mode 100644 index 194d5ab8f..000000000 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/NativeExpressAdClient.cs +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright (C) 2015 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. - -#if UNITY_IOS - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; - -using GoogleMobileAds.Api; -using GoogleMobileAds.Common; - -namespace GoogleMobileAds.iOS -{ - public class NativeExpressAdClient : IDisposable, INativeExpressAdClient - { - private IntPtr nativeExpressAdViewPtr; - private IntPtr nativeExpressAdClientPtr; - - #region Native Express Ad callback types - - internal delegate void GADUNativeExpressAdViewDidReceiveAdCallback( - IntPtr nativeExpressAdClient); - - internal delegate void GADUNativeExpressAdViewDidFailToReceiveAdWithErrorCallback( - IntPtr nativeExpressAdClient, string error); - - internal delegate void GADUNativeExpressAdViewWillPresentScreenCallback( - IntPtr nativeExpressAdClient); - - internal delegate void GADUNativeExpressAdViewDidDismissScreenCallback( - IntPtr nativeExpressAdClient); - - internal delegate void GADUNativeExpressAdViewWillLeaveApplicationCallback( - IntPtr nativeExpressAdClient); - - #endregion - - public event EventHandler OnAdLoaded; - - public event EventHandler OnAdFailedToLoad; - - public event EventHandler OnAdOpening; - - public event EventHandler OnAdClosed; - - public event EventHandler OnAdLeavingApplication; - - // This property should be used when setting the nativeExpressAdViewPtr. - private IntPtr NativeExpressAdViewPtr - { - get - { - return this.nativeExpressAdViewPtr; - } - - set - { - Externs.GADURelease(this.nativeExpressAdViewPtr); - this.nativeExpressAdViewPtr = value; - } - } - - #region INativeExpressAdClient implementation - - // Creates a native express ad view. - public void CreateNativeExpressAdView(string adUnitId, AdSize adSize, AdPosition position) - { - nativeExpressAdClientPtr = (IntPtr)GCHandle.Alloc(this); - this.NativeExpressAdViewPtr = Externs.GADUCreateNativeExpressAdView( - nativeExpressAdClientPtr, adUnitId, adSize.Width, adSize.Height, (int)position); - - Externs.GADUSetNativeExpressAdCallbacks( - this.NativeExpressAdViewPtr, - NativeExpressAdViewDidReceiveAdCallback, - NativeExpressAdViewDidFailToReceiveAdWithErrorCallback, - NativeExpressAdViewWillPresentScreenCallback, - NativeExpressAdViewDidDismissScreenCallback, - NativeExpressAdViewWillLeaveApplicationCallback); - } - - public void CreateNativeExpressAdView( - string adUnitId, - AdSize adSize, - int x, - int y) - { - nativeExpressAdClientPtr = (IntPtr)GCHandle.Alloc(this); - this.NativeExpressAdViewPtr = Externs.GADUCreateNativeExpressAdViewWithCustomPosition( - nativeExpressAdClientPtr, - adUnitId, - adSize.Width, - adSize.Height, - x, - y); - - Externs.GADUSetNativeExpressAdCallbacks( - this.NativeExpressAdViewPtr, - NativeExpressAdViewDidReceiveAdCallback, - NativeExpressAdViewDidFailToReceiveAdWithErrorCallback, - NativeExpressAdViewWillPresentScreenCallback, - NativeExpressAdViewDidDismissScreenCallback, - NativeExpressAdViewWillLeaveApplicationCallback); - } - - // Loads an ad. - public void LoadAd(AdRequest request) - { - IntPtr requestPtr = Utils.BuildAdRequest(request); - Externs.GADURequestNativeExpressAd(this.NativeExpressAdViewPtr, requestPtr); - Externs.GADURelease(requestPtr); - } - - // Displays the native express ad view on the screen. - public void ShowNativeExpressAdView() - { - Externs.GADUShowNativeExpressAdView(this.NativeExpressAdViewPtr); - } - - // Hides the native express ad view from the screen. - public void HideNativeExpressAdView() - { - Externs.GADUHideNativeExpressAdView(this.NativeExpressAdViewPtr); - } - - // Destroys the native express ad view. - public void DestroyNativeExpressAdView() - { - Externs.GADURemoveNativeExpressAdView(this.NativeExpressAdViewPtr); - this.NativeExpressAdViewPtr = IntPtr.Zero; - } - - // Returns the mediation adapter class name. - public string MediationAdapterClassName() - { - return Externs.GADUMediationAdapterClassNameForNativeExpressAdView(this.NativeExpressAdViewPtr); - } - - public void Dispose() - { - this.DestroyNativeExpressAdView(); - ((GCHandle)this.nativeExpressAdClientPtr).Free(); - } - - ~NativeExpressAdClient() - { - this.Dispose(); - } - - #endregion - - #region Native Express Ad callback methods - - [MonoPInvokeCallback(typeof(GADUNativeExpressAdViewDidReceiveAdCallback))] - private static void NativeExpressAdViewDidReceiveAdCallback(IntPtr nativeExpressClient) - { - NativeExpressAdClient client = IntPtrToNativeExpressAdClient(nativeExpressClient); - if(client.OnAdLoaded != null) - { - client.OnAdLoaded(client, EventArgs.Empty); - } - } - - [MonoPInvokeCallback(typeof(GADUNativeExpressAdViewDidFailToReceiveAdWithErrorCallback))] - private static void NativeExpressAdViewDidFailToReceiveAdWithErrorCallback( - IntPtr nativeExpressClient, string error) - { - NativeExpressAdClient client = IntPtrToNativeExpressAdClient(nativeExpressClient); - if(client.OnAdFailedToLoad != null) - { - AdFailedToLoadEventArgs args = new AdFailedToLoadEventArgs() - { - Message = error - }; - client.OnAdFailedToLoad(client, args); - } - } - - [MonoPInvokeCallback(typeof(GADUNativeExpressAdViewWillPresentScreenCallback))] - private static void NativeExpressAdViewWillPresentScreenCallback(IntPtr nativeExpressClient) - { - NativeExpressAdClient client = IntPtrToNativeExpressAdClient(nativeExpressClient); - if(client.OnAdOpening != null) - { - client.OnAdOpening(client, EventArgs.Empty); - } - } - - [MonoPInvokeCallback(typeof(GADUNativeExpressAdViewDidDismissScreenCallback))] - private static void NativeExpressAdViewDidDismissScreenCallback(IntPtr nativeExpressClient) - { - NativeExpressAdClient client = IntPtrToNativeExpressAdClient(nativeExpressClient); - if(client.OnAdClosed != null) - { - client.OnAdClosed(client, EventArgs.Empty); - } - } - - [MonoPInvokeCallback(typeof(GADUNativeExpressAdViewWillLeaveApplicationCallback))] - private static void NativeExpressAdViewWillLeaveApplicationCallback(IntPtr nativeExpressClient) - { - NativeExpressAdClient client = IntPtrToNativeExpressAdClient(nativeExpressClient); - if(client.OnAdLeavingApplication != null) - { - client.OnAdLeavingApplication(client, EventArgs.Empty); - } - } - - private static NativeExpressAdClient IntPtrToNativeExpressAdClient(IntPtr nativeExpressAdClient) - { - GCHandle handle = (GCHandle)nativeExpressAdClient; - return handle.Target as NativeExpressAdClient; - } - - #endregion - } -} - -#endif diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/NativeExpressAdClient.cs.meta b/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/NativeExpressAdClient.cs.meta deleted file mode 100644 index 4b6dbd1b0..000000000 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/NativeExpressAdClient.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e9766ea9daf5a4ceea119e6ad4fb3b81 -timeCreated: 1471025142 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/RewardBasedVideoAdClient.cs b/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/RewardBasedVideoAdClient.cs index f0dafa7b6..feb88cc70 100644 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/RewardBasedVideoAdClient.cs +++ b/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/RewardBasedVideoAdClient.cs @@ -52,6 +52,9 @@ internal delegate void GADURewardBasedVideoAdDidRewardCallback( internal delegate void GADURewardBasedVideoAdWillLeaveApplicationCallback( IntPtr rewardBasedVideoAdClient); + internal delegate void GADURewardBasedVideoAdDidCompleteCallback( + IntPtr rewardBasedVideoAdClient); + #endregion public event EventHandler OnAdLoaded; @@ -68,6 +71,8 @@ internal delegate void GADURewardBasedVideoAdWillLeaveApplicationCallback( public event EventHandler OnAdLeavingApplication; + public event EventHandler OnAdCompleted; + // This property should be used when setting the rewardBasedVideoPtr. private IntPtr RewardBasedVideoAdPtr { @@ -97,7 +102,8 @@ public void CreateRewardBasedVideoAd() RewardBasedVideoAdDidStartCallback, RewardBasedVideoAdDidCloseCallback, RewardBasedVideoAdDidRewardUserCallback, - RewardBasedVideoAdWillLeaveApplicationCallback); + RewardBasedVideoAdWillLeaveApplicationCallback, + RewardBasedVideoAdDidCompleteCallback); } // Load an ad. @@ -242,6 +248,18 @@ private static void RewardBasedVideoAdWillLeaveApplicationCallback( } } + [MonoPInvokeCallback(typeof(GADURewardBasedVideoAdDidCompleteCallback))] + private static void RewardBasedVideoAdDidCompleteCallback( + IntPtr rewardBasedVideoAdClient) + { + RewardBasedVideoAdClient client = IntPtrToRewardBasedVideoClient( + rewardBasedVideoAdClient); + if (client.OnAdCompleted != null) + { + client.OnAdCompleted(client, EventArgs.Empty); + } + } + private static RewardBasedVideoAdClient IntPtrToRewardBasedVideoClient( IntPtr rewardBasedVideoAdClient) { diff --git a/source/plugin/Assets/Plugins/iOS/GADUAdLoader.h b/source/plugin/Assets/Plugins/iOS/GADUAdLoader.h index b111d821e..c3edf26cd 100644 --- a/source/plugin/Assets/Plugins/iOS/GADUAdLoader.h +++ b/source/plugin/Assets/Plugins/iOS/GADUAdLoader.h @@ -31,7 +31,8 @@ - (instancetype)initWithAdLoaderClientReference:(GADUTypeAdLoaderClientRef *)adLoaderClient adUnitID:(NSString *)adUnitID templateIDs:(NSArray *)templateIDs - adTypes:(NSArray *)adTypes; + adTypes:(NSArray *)adTypes + options:(NSArray *)options; /// Makes an ad request. Additional targeting options can be supplied with a request object. - (void)loadRequest:(GADRequest *)request; diff --git a/source/plugin/Assets/Plugins/iOS/GADUAdLoader.m b/source/plugin/Assets/Plugins/iOS/GADUAdLoader.m index b2075da5c..8a31078f0 100644 --- a/source/plugin/Assets/Plugins/iOS/GADUAdLoader.m +++ b/source/plugin/Assets/Plugins/iOS/GADUAdLoader.m @@ -15,14 +15,15 @@ @implementation GADUAdLoader - (instancetype)initWithAdLoaderClientReference:(GADUTypeAdLoaderClientRef *)adLoaderClient adUnitID:(NSString *)adUnitID templateIDs:(NSArray *)templateIDs - adTypes:(NSArray *)adTypes { + adTypes:(NSArray *)adTypes + options:(NSArray *)options { self = [super init]; if (self) { _adLoaderClient = adLoaderClient; _adLoader = [[GADAdLoader alloc] initWithAdUnitID:adUnitID rootViewController:[GADUPluginUtil unityGLViewController] adTypes:adTypes - options:nil]; + options:options]; _adLoader.delegate = self; _templateIDs = [NSArray arrayWithArray:templateIDs]; _adTypes = [NSArray arrayWithArray:adTypes]; diff --git a/source/plugin/Assets/Plugins/iOS/GADUAdNetworkExtras.h b/source/plugin/Assets/Plugins/iOS/GADUAdNetworkExtras.h index cb179753e..254f93800 100644 --- a/source/plugin/Assets/Plugins/iOS/GADUAdNetworkExtras.h +++ b/source/plugin/Assets/Plugins/iOS/GADUAdNetworkExtras.h @@ -2,9 +2,9 @@ #import -@protocol GADUAdNetworkExtras +@protocol GADUAdNetworkExtras - (id)adNetworkExtrasWithDictionary: - (NSDictionary *)extras; + (NSDictionary *)extras; @end diff --git a/source/plugin/Assets/Plugins/iOS/GADUInterface.m b/source/plugin/Assets/Plugins/iOS/GADUInterface.m index 4afa38c79..f95235f9d 100644 --- a/source/plugin/Assets/Plugins/iOS/GADUInterface.m +++ b/source/plugin/Assets/Plugins/iOS/GADUInterface.m @@ -6,7 +6,6 @@ #import "GADUNativeCustomTemplateAd.h" #import "GADUPluginUtil.h" #import "GADUAdNetworkExtras.h" -#import "GADUNativeExpressAd.h" #import "GADUObjectCache.h" #import "GADURequest.h" #import "GADURewardBasedVideoAd.h" @@ -156,8 +155,9 @@ GADUTypeRewardBasedVideoAdRef GADUCreateRewardBasedVideoAd( /// Creates a GADUAdLoader and returns its reference. GADUTypeAdLoaderRef GADUCreateAdLoader(GADUTypeAdLoaderClientRef *adLoaderClient, - const char *adUnitID, const char **templateIDs, - NSInteger templateIDLength, struct AdTypes *types) { + const char *adUnitID, + const char **templateIDs, NSInteger templateIDLength, + struct AdTypes *types) { NSMutableArray *templateIDsArray = [[NSMutableArray alloc] init]; for (int i = 0; i < templateIDLength; i++) { [templateIDsArray addObject:GADUStringFromUTF8String(templateIDs[i])]; @@ -166,12 +166,14 @@ GADUTypeAdLoaderRef GADUCreateAdLoader(GADUTypeAdLoaderClientRef *adLoaderClient if (types->CustomTemplateAd) { [adTypesArray addObject:kGADAdLoaderAdTypeNativeCustomTemplate]; } + NSArray *options = nil; GADUAdLoader *adLoader = [[GADUAdLoader alloc] initWithAdLoaderClientReference:adLoaderClient adUnitID:GADUStringFromUTF8String(adUnitID) templateIDs:templateIDsArray - adTypes:adTypesArray]; + adTypes:adTypesArray + options:options]; GADUObjectCache *cache = [GADUObjectCache sharedInstance]; [cache.references setObject:adLoader forKey:[adLoader gadu_referenceKey]]; return (__bridge GADUTypeAdLoaderRef)adLoader; @@ -216,7 +218,8 @@ void GADUSetRewardBasedVideoAdCallbacks( GADURewardBasedVideoAdDidStartPlayingCallback didStartCallback, GADURewardBasedVideoAdDidCloseCallback didCloseCallback, GADURewardBasedVideoAdDidRewardCallback didRewardCallback, - GADURewardBasedVideoAdWillLeaveApplicationCallback willLeaveCallback) { + GADURewardBasedVideoAdWillLeaveApplicationCallback willLeaveCallback, + GADURewardBasedVideoAdDidCompleteCallback didCompleteCallback) { GADURewardBasedVideoAd *internalRewardBasedVideoAd = (__bridge GADURewardBasedVideoAd *)rewardBasedVideoAd; internalRewardBasedVideoAd.adReceivedCallback = adReceivedCallback; @@ -226,56 +229,7 @@ void GADUSetRewardBasedVideoAdCallbacks( internalRewardBasedVideoAd.didCloseCallback = didCloseCallback; internalRewardBasedVideoAd.didRewardCallback = didRewardCallback; internalRewardBasedVideoAd.willLeaveCallback = willLeaveCallback; -} - -/// Sets the native express callback methods to be invoked during native express ad events. -void GADUSetNativeExpressAdCallbacks( - GADUTypeNativeExpressAdRef nativeExpressAd, - GADUNativeExpressAdViewDidReceiveAdCallback adReceivedCallback, - GADUNativeExpressAdViewDidFailToReceiveAdWithErrorCallback adFailedCallback, - GADUNativeExpressAdViewWillPresentScreenCallback willPresentScreenCallback, - GADUNativeExpressAdViewDidDismissScreenCallback didDismissScreenCallback, - GADUNativeExpressAdViewWillLeaveApplicationCallback willLeaveAppCallback) { - GADUNativeExpressAd *internalNativeExpressAd = (__bridge GADUNativeExpressAd *)nativeExpressAd; - internalNativeExpressAd.adReceivedCallback = adReceivedCallback; - internalNativeExpressAd.adFailedCallback = adFailedCallback; - internalNativeExpressAd.willPresentScreenCallback = willPresentScreenCallback; - internalNativeExpressAd.didDismissScreenCallback = didDismissScreenCallback; - internalNativeExpressAd.willLeaveAppCallback = willLeaveAppCallback; -} - -/// Creates a GADNativeExpressAdView with the specified width, height, and position. Returns -/// a reference to the GADUNativeExpressAdView. -GADUTypeNativeExpressAdRef GADUCreateNativeExpressAdView( - GADUTypeNativeExpressAdClientRef *nativeExpressAdClient, const char *adUnitID, NSInteger width, - NSInteger height, GADAdPosition adPosition) { - GADUNativeExpressAd *nativeExpressAd = [[GADUNativeExpressAd alloc] - initWithNativeExpressAdClientReference:nativeExpressAdClient - adUnitID:GADUStringFromUTF8String(adUnitID) - width:width - height:height - adPosition:adPosition]; - - GADUObjectCache *cache = [GADUObjectCache sharedInstance]; - [cache.references setObject:nativeExpressAd forKey:[nativeExpressAd gadu_referenceKey]]; - return (__bridge GADUTypeNativeExpressAdRef)nativeExpressAd; -} - -/// Creates a GADNativeExpressAdView with the specified width, height, and custom position. Returns -/// a reference to the GADUNativeExpressAdView. -GADUTypeNativeExpressAdRef GADUCreateNativeExpressAdViewWithCustomPosition( - GADUTypeNativeExpressAdClientRef *nativeExpressAdClient, const char *adUnitID, NSInteger width, - NSInteger height, NSInteger x, NSInteger y) { - CGPoint adPosition = CGPointMake(x, y); - GADUNativeExpressAd *nativeExpressAd = [[GADUNativeExpressAd alloc] - initWithNativeExpressAdClientReference:nativeExpressAdClient - adUnitID:GADUStringFromUTF8String(adUnitID) - width:width - height:height - customAdPosition:adPosition]; - GADUObjectCache *cache = [GADUObjectCache sharedInstance]; - [cache.references setObject:nativeExpressAd forKey:[nativeExpressAd gadu_referenceKey]]; - return (__bridge GADUTypeNativeExpressAdRef)nativeExpressAd; + internalRewardBasedVideoAd.didCompleteCallback = didCompleteCallback; } /// Sets the banner callback methods to be invoked during native ad events. @@ -316,24 +270,6 @@ float GADUGetBannerViewWidthInPixels(GADUTypeBannerRef banner) { return internalBanner.widthInPixels; } -/// Hides the GADNativeExpressAdView. -void GADUHideNativeExpressAdView(GADUTypeNativeExpressAdRef nativeExpressAd) { - GADUNativeExpressAd *internalNativeExpressAd = (__bridge GADUNativeExpressAd *)nativeExpressAd; - [internalNativeExpressAd hideNativeExpressAdView]; -} - -/// Shows the GADNativeExpressAdView. -void GADUShowNativeExpressAdView(GADUTypeBannerRef nativeExpressAd) { - GADUNativeExpressAd *internalNativeExpressAd = (__bridge GADUNativeExpressAd *)nativeExpressAd; - [internalNativeExpressAd showNativeExpressAdView]; -} - -/// Removes the GADNativeExpressAdView from the view hierarchy. -void GADURemoveNativeExpressAdView(GADUTypeNativeExpressAdRef nativeExpressAd) { - GADUNativeExpressAd *internalNativeExpressAd = (__bridge GADUNativeExpressAd *)nativeExpressAd; - [internalNativeExpressAd removeNativeExpressAdView]; -} - /// Returns YES if the GADInterstitial is ready to be shown. BOOL GADUInterstitialReady(GADUTypeInterstitialRef interstitial) { GADUInterstitial *internalInterstitial = (__bridge GADUInterstitial *)interstitial; @@ -493,14 +429,6 @@ void GADURequestRewardBasedVideoAd(GADUTypeRewardBasedVideoAdRef rewardBasedVide withAdUnitID:GADUStringFromUTF8String(adUnitID)]; } -/// Makes a native express ad request. -void GADURequestNativeExpressAd(GADUTypeNativeExpressAdRef nativeExpressAd, - GADUTypeRequestRef request) { - GADUNativeExpressAd *internalNativeExpressAd = (__bridge GADUNativeExpressAd *)nativeExpressAd; - GADURequest *internalRequest = (__bridge GADURequest *)request; - [internalNativeExpressAd loadRequest:[internalRequest request]]; -} - /// Makes a native ad request. void GADURequestNativeAd(GADUTypeAdLoaderRef adLoader, GADUTypeRequestRef request) { GADUAdLoader *internalAdLoader = (__bridge GADUAdLoader *)adLoader; @@ -602,12 +530,6 @@ void GADURelease(GADUTypeRef ref) { return cStringCopy(banner.mediationAdapterClassName.UTF8String); } -const char *GADUMediationAdapterClassNameForNativeExpressAdView( - GADUTypeNativeExpressAdRef nativeExpressAdView) { - GADUNativeExpressAd *nativeAd = (__bridge GADUNativeExpressAd *)nativeExpressAdView; - return cStringCopy(nativeAd.mediationAdapterClassName.UTF8String); -} - const char *GADUMediationAdapterClassNameForRewardedVideo( GADUTypeRewardBasedVideoAdRef rewardedVideo) { GADURewardBasedVideoAd *rewarded = (__bridge GADURewardBasedVideoAd *)rewardedVideo; diff --git a/source/plugin/Assets/Plugins/iOS/GADUNativeCustomTemplateAd.m b/source/plugin/Assets/Plugins/iOS/GADUNativeCustomTemplateAd.m index 2b2cbdd0e..7cfdd8269 100644 --- a/source/plugin/Assets/Plugins/iOS/GADUNativeCustomTemplateAd.m +++ b/source/plugin/Assets/Plugins/iOS/GADUNativeCustomTemplateAd.m @@ -27,7 +27,7 @@ - (UIImage *)imageForKey:(NSString *)key { - (void)performClickOnAssetWithKey:(NSString *)key withCustomClickAction:(bool)customClickAction { if (customClickAction) { __weak GADUNativeCustomTemplateAd *weakSelf = self; - [self.nativeCustomTemplateAd setCustomClickHandler:^(NSString *assetID){ + [self.nativeCustomTemplateAd setCustomClickHandler:^(NSString *assetID) { [weakSelf didReceiveClickForAsset:key]; }]; } diff --git a/source/plugin/Assets/Plugins/iOS/GADUNativeExpressAd.h b/source/plugin/Assets/Plugins/iOS/GADUNativeExpressAd.h deleted file mode 100644 index 4109fcd21..000000000 --- a/source/plugin/Assets/Plugins/iOS/GADUNativeExpressAd.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2016 Google Inc. All Rights Reserved. - -#import - -#import - -#import "GADUTypes.h" - -/// A wrapper around GADNativeExpressAdView. Handles creating GADNativeExpressAdView -/// objects, loading them with ads, and listening for ad events. -@interface GADUNativeExpressAd : NSObject - -/// Returns an initialized GADNativeExpressAdView object with specified width and height, positioned -/// at either the top or bottom of the screen. -- (instancetype)initWithNativeExpressAdClientReference: - (GADUTypeNativeExpressAdClientRef *)nativeExpressAdClient - adUnitID:(NSString *)adUnitID - width:(CGFloat)width - height:(CGFloat)height - adPosition:(GADAdPosition)adPosition; - -/// Returns an initialized GADNativeExpressAdView object with specified width and height, positioned -/// at the specified CGPoint. -- (instancetype)initWithNativeExpressAdClientReference: - (GADUTypeNativeExpressAdClientRef *)nativeExpressAdClient - adUnitID:(NSString *)adUnitID - width:(CGFloat)width - height:(CGFloat)height - customAdPosition:(CGPoint)customAdPosition; - -/// A reference to the Unity native express ad client. -@property(nonatomic, assign) GADUTypeNativeExpressAdClientRef *nativeExpressAdClient; - -/// A GADNativeExpressAdView which contains the ad. -@property(nonatomic, strong) GADNativeExpressAdView *nativeExpressAdView; - -/// The ad received callback into Unity. -@property(nonatomic, assign) GADUAdViewDidReceiveAdCallback adReceivedCallback; - -/// The ad failed callback into Unity. -@property(nonatomic, assign) GADUAdViewDidFailToReceiveAdWithErrorCallback adFailedCallback; - -/// The will present screen callback into Unity. -@property(nonatomic, assign) GADUAdViewWillPresentScreenCallback willPresentScreenCallback; - -/// The did dismiss screen callback into Unity. -@property(nonatomic, assign) GADUAdViewDidDismissScreenCallback didDismissScreenCallback; - -/// The will leave application callback into Unity. -@property(nonatomic, assign) GADUAdViewWillLeaveApplicationCallback willLeaveAppCallback; - -// Returns the mediation adapter class name. -@property(nonatomic, readonly, copy) NSString *mediationAdapterClassName; - -/// Requests a native express ad. Additional targeting options can be supplied with a request -/// object. -- (void)loadRequest:(GADRequest *)request; - -/// Hides the GADNativeExpressAdView. -- (void)hideNativeExpressAdView; - -/// Shows the GADNativeExpressAdView. -- (void)showNativeExpressAdView; - -/// Removes the GADNativeExpressAdView from the view hierarchy. -- (void)removeNativeExpressAdView; - -@end diff --git a/source/plugin/Assets/Plugins/iOS/GADUNativeExpressAd.h.meta b/source/plugin/Assets/Plugins/iOS/GADUNativeExpressAd.h.meta deleted file mode 100644 index 766908fe0..000000000 --- a/source/plugin/Assets/Plugins/iOS/GADUNativeExpressAd.h.meta +++ /dev/null @@ -1,33 +0,0 @@ -fileFormatVersion: 2 -guid: 6432657d87e6d426b8bab8def080b36b -timeCreated: 1471829018 -licenseType: Free -PluginImporter: - serializedVersion: 2 - iconMap: {} - executionOrder: {} - isPreloaded: 0 - isOverridable: 0 - platformData: - data: - first: - Any: - second: - enabled: 0 - settings: {} - data: - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - data: - first: - iPhone: iOS - second: - enabled: 1 - settings: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/source/plugin/Assets/Plugins/iOS/GADUNativeExpressAd.m b/source/plugin/Assets/Plugins/iOS/GADUNativeExpressAd.m deleted file mode 100644 index 624b76765..000000000 --- a/source/plugin/Assets/Plugins/iOS/GADUNativeExpressAd.m +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright 2016 Google Inc. All Rights Reserved. - -#import "GADUNativeExpressAd.h" - -#import "GADUPluginUtil.h" -#import "UnityAppController.h" - -@interface GADUNativeExpressAd () - -/// Defines where the ad should be positioned on the screen with a GADAdPosition. -@property(nonatomic, assign) GADAdPosition adPosition; - -/// Defines where the ad should be positioned on the screen with a CGPoint. -@property(nonatomic, assign) CGPoint customAdPosition; - -@end - -@implementation GADUNativeExpressAd - -- (instancetype)initWithNativeExpressAdClientReference: - (GADUTypeNativeExpressAdClientRef *)nativeExpressAdClient - adUnitID:(NSString *)adUnitID - width:(CGFloat)width - height:(CGFloat)height - adPosition:(GADAdPosition)adPosition { - return [self - initWithNativeExpressAdClientReference:nativeExpressAdClient - adUnitID:adUnitID - adSize:[GADUPluginUtil adSizeForWidth:width height:height] - adPosition:adPosition]; -} - -- (instancetype)initWithNativeExpressAdClientReference: - (GADUTypeNativeExpressAdClientRef *)nativeExpressAdClient - adUnitID:(NSString *)adUnitID - adSize:(GADAdSize)size - adPosition:(GADAdPosition)adPosition { - self = [super init]; - if (self) { - _nativeExpressAdClient = nativeExpressAdClient; - _adPosition = adPosition; - _nativeExpressAdView = [[GADNativeExpressAdView alloc] initWithAdSize:size]; - _nativeExpressAdView.adUnitID = adUnitID; - _nativeExpressAdView.delegate = self; - _nativeExpressAdView.rootViewController = [GADUPluginUtil unityGLViewController]; - } - return self; -} - -- (instancetype)initWithNativeExpressAdClientReference: - (GADUTypeNativeExpressAdClientRef *)nativeExpressAdClient - adUnitID:(NSString *)adUnitID - width:(CGFloat)width - height:(CGFloat)height - customAdPosition:(CGPoint)customAdPosition { - self = [super init]; - if (self) { - _nativeExpressAdClient = nativeExpressAdClient; - _customAdPosition = customAdPosition; - _adPosition = kGADAdPositionCustom; - GADAdSize adSize = [GADUPluginUtil adSizeForWidth:width height:height]; - _nativeExpressAdView = [[GADNativeExpressAdView alloc] initWithAdSize:adSize]; - _nativeExpressAdView.adUnitID = adUnitID; - _nativeExpressAdView.delegate = self; - _nativeExpressAdView.rootViewController = [GADUPluginUtil unityGLViewController]; - } - return self; -} - -- (void)dealloc { - _nativeExpressAdView.delegate = nil; -} - -- (void)loadRequest:(GADRequest *)request { - if (!self.nativeExpressAdView) { - NSLog(@"GoogleMobileAdsPlugin: NativeExpressAdView is nil. Ignoring ad request."); - return; - } - [self.nativeExpressAdView loadRequest:request]; -} - -- (void)hideNativeExpressAdView { - if (!self.nativeExpressAdView) { - NSLog(@"GoogleMobileAdsPlugin: NativeExpressAdView is nil. Ignoring call to " - @"hideNativeExpressAdView"); - return; - } - self.nativeExpressAdView.hidden = YES; -} - -- (void)showNativeExpressAdView { - if (!self.nativeExpressAdView) { - NSLog(@"GoogleMobileAdsPlugin: NativeExpressAdView is nil. Ignoring call to " - @"showNativeExpressAdView"); - return; - } - self.nativeExpressAdView.hidden = NO; -} - -- (void)removeNativeExpressAdView { - if (!self.nativeExpressAdView) { - NSLog(@"GoogleMobileAdsPlugin: NativeExpressAdView is nil. Ignoring call to " - @"removeNativeExpressAdView"); - return; - } - [self.nativeExpressAdView removeFromSuperview]; -} - -- (NSString *)mediationAdapterClassName { - return [self.nativeExpressAdView adNetworkClassName]; -} - -#pragma mark GADNativeExpressAdViewDelegate implementation - -- (void)nativeExpressAdViewDidReceiveAd:(GADNativeExpressAdView *)nativeExpressAdView { - // Remove existing native express ad view from superview. - [self.nativeExpressAdView removeFromSuperview]; - - // Add the new native express ad view. - self.nativeExpressAdView = nativeExpressAdView; - - /// Align the nativeExpressAdView in the Unity view bounds. - UIView *unityView = [GADUPluginUtil unityGLViewController].view; - if (self.adPosition != kGADAdPositionCustom) { - [GADUPluginUtil positionView:self.nativeExpressAdView - inParentView:unityView - adPosition:self.adPosition]; - } else { - [GADUPluginUtil positionView:self.nativeExpressAdView - inParentView:unityView - customPosition:self.customAdPosition]; - } - [unityView addSubview:self.nativeExpressAdView]; - - if (self.adReceivedCallback) { - self.adReceivedCallback(self.nativeExpressAdClient); - } -} - -- (void)nativeExpressAdView:(GADNativeExpressAdView *)nativeExpressAdView - didFailToReceiveAdWithError:(GADRequestError *)error { - if (self.adFailedCallback) { - NSString *errorMsg = [[NSString alloc] - initWithFormat:@"Failed to receive ad with error: %@", [error localizedFailureReason]]; - self.adFailedCallback(self.nativeExpressAdClient, - [errorMsg cStringUsingEncoding:NSUTF8StringEncoding]); - } -} - -- (void)nativeExpressAdViewWillPresentScreen:(GADNativeExpressAdView *)nativeExpressAdView { - if (self.willPresentScreenCallback) { - self.willPresentScreenCallback(self.nativeExpressAdClient); - } -} - -- (void)nativeExpressAdViewWillDismissScreen:(GADNativeExpressAdView *)nativeExpressAdView { - // Callback is not forwarded to Unity. -} - -- (void)nativeExpressAdViewDidDismissScreen:(GADNativeExpressAdView *)nativeExpressAdView { - if (self.didDismissScreenCallback) { - self.didDismissScreenCallback(self.nativeExpressAdClient); - } -} - -- (void)nativeExpressAdViewWillLeaveApplication:(GADNativeExpressAdView *)nativeExpressAdView { - if (self.willLeaveAppCallback) { - self.willLeaveAppCallback(self.nativeExpressAdClient); - } -} - -@end diff --git a/source/plugin/Assets/Plugins/iOS/GADUNativeExpressAd.m.meta b/source/plugin/Assets/Plugins/iOS/GADUNativeExpressAd.m.meta deleted file mode 100644 index ef064a0eb..000000000 --- a/source/plugin/Assets/Plugins/iOS/GADUNativeExpressAd.m.meta +++ /dev/null @@ -1,33 +0,0 @@ -fileFormatVersion: 2 -guid: 5c1802f16594546fb9bd558b8ce69994 -timeCreated: 1471829018 -licenseType: Free -PluginImporter: - serializedVersion: 2 - iconMap: {} - executionOrder: {} - isPreloaded: 0 - isOverridable: 0 - platformData: - data: - first: - Any: - second: - enabled: 0 - settings: {} - data: - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - data: - first: - iPhone: iOS - second: - enabled: 1 - settings: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/source/plugin/Assets/Plugins/iOS/GADURewardBasedVideoAd.h b/source/plugin/Assets/Plugins/iOS/GADURewardBasedVideoAd.h index 9449add54..30d3daf27 100644 --- a/source/plugin/Assets/Plugins/iOS/GADURewardBasedVideoAd.h +++ b/source/plugin/Assets/Plugins/iOS/GADURewardBasedVideoAd.h @@ -40,6 +40,9 @@ /// The will leave application callback into Unity. @property(nonatomic, assign) GADURewardBasedVideoAdWillLeaveApplicationCallback willLeaveCallback; +/// The did complete callback into Unity. +@property(nonatomic, assign) GADURewardBasedVideoAdDidCompleteCallback didCompleteCallback; + // Returns the mediation adapter class name. @property(nonatomic, readonly, copy) NSString *mediationAdapterClassName; diff --git a/source/plugin/Assets/Plugins/iOS/GADURewardBasedVideoAd.m b/source/plugin/Assets/Plugins/iOS/GADURewardBasedVideoAd.m index ea540e811..74039f6b0 100644 --- a/source/plugin/Assets/Plugins/iOS/GADURewardBasedVideoAd.m +++ b/source/plugin/Assets/Plugins/iOS/GADURewardBasedVideoAd.m @@ -119,4 +119,10 @@ - (void)rewardBasedVideoAdWillLeaveApplication:(GADRewardBasedVideoAd *)rewardBa } } +- (void)rewardBasedVideoAdDidCompletePlaying:(GADRewardBasedVideoAd *)rewardBasedVideoAd { + if (self.didCompleteCallback) { + self.didCompleteCallback(self.rewardBasedVideoAdClient); + } +} + @end diff --git a/source/plugin/Assets/Plugins/iOS/GADUTypes.h b/source/plugin/Assets/Plugins/iOS/GADUTypes.h index c359d3b4a..d54798a21 100644 --- a/source/plugin/Assets/Plugins/iOS/GADUTypes.h +++ b/source/plugin/Assets/Plugins/iOS/GADUTypes.h @@ -32,9 +32,6 @@ typedef const void *GADUTypeAdLoaderClientRef; /// Type representing a Unity native custom template ad. typedef const void *GADUTypeNativeCustomTemplateAdClientRef; -/// Type representing a Unity native express ad client. -typedef const void *GADUTypeNativeExpressAdClientRef; - /// Type representing a GADUBanner. typedef const void *GADUTypeBannerRef; @@ -50,9 +47,6 @@ typedef const void *GADUTypeAdLoaderRef; /// Type representing a GADUNativeCustomTemplateAd. typedef const void *GADUTypeNativeCustomTemplateAdRef; -/// Type representing a GADUNativeExpressAd. -typedef const void *GADUTypeNativeExpressAdRef; - /// Type representing a GADURequest. typedef const void *GADUTypeRequestRef; @@ -135,31 +129,9 @@ typedef void (*GADURewardBasedVideoAdDidRewardCallback)( typedef void (*GADURewardBasedVideoAdWillLeaveApplicationCallback)( GADUTypeRewardBasedVideoAdClientRef *rewardBasedVideoClient); -/// Callback for when a native express ad request was successfully loaded. -typedef void (*GADUNativeExpressAdViewDidReceiveAdCallback)( - GADUTypeNativeExpressAdClientRef *nativeExpressClient); - -/// Callback for when a native express ad request failed. -typedef void (*GADUNativeExpressAdViewDidFailToReceiveAdWithErrorCallback)( - GADUTypeNativeExpressAdClientRef *nativeExpressClient, const char *error); - -/// Callback for when a full screen view is about to be presented as a result of a native express -/// click. -typedef void (*GADUNativeExpressAdViewWillPresentScreenCallback)( - GADUTypeNativeExpressAdClientRef *nativeExpressClient); - -/// Callback for when a full screen view is about to be dismissed. -typedef void (*GADUNativeExpressAdViewWillDismissScreenCallback)( - GADUTypeNativeExpressAdClientRef *nativeExpressClient); - -/// Callback for when a full screen view has just been dismissed. -typedef void (*GADUNativeExpressAdViewDidDismissScreenCallback)( - GADUTypeNativeExpressAdClientRef *nativeExpressClient); - -/// Callback for when an application will background or terminate as a result of a native express -/// click. -typedef void (*GADUNativeExpressAdViewWillLeaveApplicationCallback)( - GADUTypeNativeExpressAdClientRef *nativeExpressClient); +/// Callback for when a reward based video ad completes playing. +typedef void (*GADURewardBasedVideoAdDidCompleteCallback)( + GADUTypeRewardBasedVideoAdClientRef *rewardBasedVideoClient); /// Callback for when a native custom template ad request was successfully loaded. typedef void (*GADUAdLoaderDidReceiveNativeCustomTemplateAdCallback)(