diff --git a/ChangeLog.txt b/ChangeLog.txt index 8684b8b40..b091e8226 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,13 +1,38 @@ Google Mobile Ads Unity Plugin Change Log +************** +Version 3.10.0 +************** + +Plugin: +- Updated Smart Banner positioning to render within safe area on iOS 11. +- Added API to return height and width of BannerView in pixels. +- Added SetPosition method to reposition banner ads. +- Updated AppLovin Unity mediation package to support AppLovin initialization +integration. + +Mediation packages: +- Added InMobi mediation support package. +- Added Tapjoy mediation support package. +- Added Unity Ads mediation support package. +- Added myTarget mediation support package. + +Built and tested with: +- Google Play services 11.6.2 +- Google Mobile Ads iOS SDK 7.27.0 +- Unity Jar Resolver 1.2.59.0 + ************* Version 3.9.0 ************* +Plugin: - Implemented workaround for issue where ad views are rendered in incorrect position. - Resolved compatibility issues with Gradle 4. - Resovled comnpatilbity issues with older versions of Xcode. + +Mediation packages: - Added API for video ad volume control. - Added AdColony mediation support package. - Added AppLovin mediation support package. diff --git a/build.gradle b/build.gradle index 349b47196..89b7cbe56 100644 --- a/build.gradle +++ b/build.gradle @@ -31,8 +31,9 @@ project.ext { pluginSource = file('source/plugin').absolutePath pluginBuildDir = file('temp/plugin-build-dir').absolutePath - buildPath = file('temp').absolutePath exportPath = file('GoogleMobileAds.unitypackage').absolutePath + + buildPath = file('temp').absolutePath resolverDir = file("${buildPath}/jarresolver").absolutePath } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 12a08711a..7a3265ee9 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ee050b283..4afd970f0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed Jul 12 16:58:21 PDT 2017 +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.1-bin.zip +zipStoreBase=GRADLE_USER_HOME diff --git a/mediation/.gitignore b/mediation/.gitignore new file mode 100644 index 000000000..fa9cbd408 --- /dev/null +++ b/mediation/.gitignore @@ -0,0 +1,8 @@ +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.idea +.DS_Store +/build +*.iml diff --git a/mediation/AppLovin/CHANGELOG.md b/mediation/AppLovin/CHANGELOG.md new file mode 100644 index 000000000..f8cfbb9e6 --- /dev/null +++ b/mediation/AppLovin/CHANGELOG.md @@ -0,0 +1,7 @@ +# AppLovin Adapter plugin for Google Mobile Ads SDK for Unity 3D Changelog + +## 1.0.0 + +- First release! +- Supports Android adapter version 7.4.1.1. +- Supports iOS adapter version 4.4.1.1. diff --git a/mediation/AppLovin/README.md b/mediation/AppLovin/README.md new file mode 100644 index 000000000..21e724869 --- /dev/null +++ b/mediation/AppLovin/README.md @@ -0,0 +1,5 @@ +# AppLovin 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 +[AppLovin Adapter Integration Guide](https://developers.google.com/admob/unity/mediation/applovin). diff --git a/mediation/AppLovin/build.gradle b/mediation/AppLovin/build.gradle index d3b2ddac1..b60e3b83d 100644 --- a/mediation/AppLovin/build.gradle +++ b/mediation/AppLovin/build.gradle @@ -2,6 +2,9 @@ * Gradle file to build a Unity package to add AppLovin mediation support to the Google Mobile Ads Unity plugin. * Usage: ./gradlew exportPackage */ +plugins { + id "com.jfrog.bintray" version "1.7.3" +} defaultTasks 'exportPackage' @@ -20,10 +23,15 @@ project.ext { 'UNITY_EXE environment variable and point it to your Unity installation.') } + versionString = '1.0.0' + pluginName = 'GoogleMobileAdsAppLovinMediation' + 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('GoogleMobileAdsAppLovinMediation.unitypackage').absolutePath + exportPath = file(pluginFileName).absolutePath } // Build unity package using through command line interface. @@ -37,7 +45,7 @@ task exportPackage(type: Exec) { "-projectPath", "${pluginBuildDir}", "-logFile", "temp/unity.log", "-exportPackage", - "Assets/GoogleMobileAds/Editor", + "Assets/GoogleMobileAds", "Assets/Plugins", "${exportPath}", "-quit" @@ -66,3 +74,72 @@ task clearTempBuildFolder(type: Delete) { 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 = 'AppLovin plugin for Google Mobile Ads Mediation.' + websiteUrl = 'https://developers.google.com/admob/unity/mediation/applovin' + 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/AppLovin/source/plugin/Assets/GoogleMobileAds/Api/Mediation/AppLovin/AppLovin.cs b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Api/Mediation/AppLovin/AppLovin.cs new file mode 100644 index 000000000..e1ebbc074 --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Api/Mediation/AppLovin/AppLovin.cs @@ -0,0 +1,36 @@ +// Copyright (C) 2017 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.Common.Mediation.AppLovin; +using GoogleMobileAds.Mediation; + +namespace GoogleMobileAds.Api.Mediation.AppLovin +{ + public class AppLovin + { + private static readonly IAppLovinClient client = GetAppLovinClient(); + + public static void Initialize() + { + client.Initialize(); + } + + private static IAppLovinClient GetAppLovinClient() + { + return AppLovinClientFactory.AppLovinInstance(); + } + } +} diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Api/Mediation/AppLovin/AppLovin.cs.meta b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Api/Mediation/AppLovin/AppLovin.cs.meta new file mode 100644 index 000000000..1c6d4ac41 --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Api/Mediation/AppLovin/AppLovin.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4f5531356b2a84ee9b2532ba2fe07baa +timeCreated: 1510790432 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Common/Mediation/AppLovin/DummyClient.cs b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Common/Mediation/AppLovin/DummyClient.cs new file mode 100644 index 000000000..80de60ef1 --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Common/Mediation/AppLovin/DummyClient.cs @@ -0,0 +1,35 @@ +// Copyright (C) 2017 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 UnityEngine; + +namespace GoogleMobileAds.Common.Mediation.AppLovin +{ + public class DummyClient : IAppLovinClient + { + public DummyClient() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void Initialize() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + } +} + diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Common/Mediation/AppLovin/DummyClient.cs.meta b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Common/Mediation/AppLovin/DummyClient.cs.meta new file mode 100644 index 000000000..814b4ccc2 --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Common/Mediation/AppLovin/DummyClient.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1435817287d76405da76fafb68a3d867 +timeCreated: 1510861611 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Common/Mediation/AppLovin/IAppLovinClient.cs b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Common/Mediation/AppLovin/IAppLovinClient.cs new file mode 100644 index 000000000..a299a2e25 --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Common/Mediation/AppLovin/IAppLovinClient.cs @@ -0,0 +1,25 @@ +// Copyright (C) 2017 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 UnityEngine; +using System.Collections; + +namespace GoogleMobileAds.Common.Mediation.AppLovin +{ + public interface IAppLovinClient + { + // Initialize the AppLovin SDK. + void Initialize(); + } +} diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Common/Mediation/AppLovin/IAppLovinClient.cs.meta b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Common/Mediation/AppLovin/IAppLovinClient.cs.meta new file mode 100644 index 000000000..04a0dee61 --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Common/Mediation/AppLovin/IAppLovinClient.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1351aa272269b428782be9b8bf45f5e2 +timeCreated: 1510852788 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Editor/AppLovinPostProcessBuild.cs b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Editor/AppLovinPostProcessBuild.cs new file mode 100644 index 000000000..9c95fbe1b --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Editor/AppLovinPostProcessBuild.cs @@ -0,0 +1,42 @@ +// Copyright (C) 2017 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 UnityEditor; +using UnityEditor.Callbacks; +using UnityEditor.iOS.Xcode; +using System.IO; + +namespace GoogleMobileAds.Common.Mediation.AppLovin +{ + public class AppLovinPostProcessBuild + { + [PostProcessBuild] + public static void ChangeXcodePlist(BuildTarget buildTarget, + string pathToBuiltProject) + { + if (buildTarget == BuildTarget.iOS) + { + string plistPath = pathToBuiltProject + "/Info.plist"; + PlistDocument plist = new PlistDocument(); + plist.ReadFromString(File.ReadAllText(plistPath)); + + PlistElementDict rootDict = plist.root; + + rootDict.SetString("AppLovinSdkKey", + "INSERT_APP_LOVIN_SDK_KEY_HERE"); + File.WriteAllText(plistPath, plist.WriteToString()); + } + } + } +} diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Editor/AppLovinPostProcessBuild.cs.meta b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Editor/AppLovinPostProcessBuild.cs.meta new file mode 100644 index 000000000..802568da4 --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Editor/AppLovinPostProcessBuild.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2c4a3193998ef4beda91f084c8214b7b +timeCreated: 1511219903 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/Android/Mediation/AppLovin.meta b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/Android/Mediation/AppLovin.meta new file mode 100644 index 000000000..9d6756392 --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/Android/Mediation/AppLovin.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d494be46f4442408ea5901b780b9b6b9 +folderAsset: yes +timeCreated: 1510861611 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/Android/Mediation/AppLovin/AppLovinClient.cs b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/Android/Mediation/AppLovin/AppLovinClient.cs new file mode 100644 index 000000000..02c431a93 --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/Android/Mediation/AppLovin/AppLovinClient.cs @@ -0,0 +1,48 @@ +// Copyright (C) 2017 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.Reflection; +using UnityEngine; + +using GoogleMobileAds.Common.Mediation.AppLovin; + +namespace GoogleMobileAds.Android.Mediation.AppLovin +{ + public class AppLovinClient : IAppLovinClient + { + private static AppLovinClient instance = new AppLovinClient(); + private AppLovinClient() { } + + public static AppLovinClient Instance + { + get + { + return instance; + } + } + + public void Initialize() + { + MonoBehaviour.print("AppLovin intialize received"); + AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); + AndroidJavaObject currentActivity = unityPlayer.GetStatic("currentActivity"); + AndroidJavaObject appLovin = new AndroidJavaObject("com.applovin.sdk.AppLovinSdk"); + appLovin.CallStatic("initializeSdk", currentActivity); + } + } +} + +#endif diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/Android/Mediation/AppLovin/AppLovinClient.cs.meta b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/Android/Mediation/AppLovin/AppLovinClient.cs.meta new file mode 100644 index 000000000..7d766fdd0 --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/Android/Mediation/AppLovin/AppLovinClient.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 45868a7299c2d44038ff2fe930d4b0bb +timeCreated: 1510862669 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/Mediation/AppLovinClientFactory.cs b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/Mediation/AppLovinClientFactory.cs new file mode 100644 index 000000000..61001c2a5 --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/Mediation/AppLovinClientFactory.cs @@ -0,0 +1,25 @@ +using UnityEngine; +using System.Collections; + +using GoogleMobileAds.Common.Mediation.AppLovin; + +namespace GoogleMobileAds.Mediation +{ + public class AppLovinClientFactory + { + public static IAppLovinClient AppLovinInstance() + { +#if UNITY_EDITOR + // Testing UNITY_EDITOR first because the editor also responds to the currently + // selected platform. + return new GoogleMobileAds.Common.Mediation.AppLovin.DummyClient(); +#elif UNITY_ANDROID + return GoogleMobileAds.Android.Mediation.AppLovin.AppLovinClient.Instance; +#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE + return GoogleMobileAds.iOS.Mediation.AppLovin.AppLovinClient.Instance; +#else + return new GoogleMobileAds.Common.Mediation.AppLovin.DummyClient(); +#endif + } + } +} diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/Mediation/AppLovinClientFactory.cs.meta b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/Mediation/AppLovinClientFactory.cs.meta new file mode 100644 index 000000000..eeeeb79b9 --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/Mediation/AppLovinClientFactory.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 55731d7ee80124795ade704d8e03fa83 +timeCreated: 1510861665 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Mediation/AppLovin.meta b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Mediation/AppLovin.meta new file mode 100644 index 000000000..616bb97bf --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Mediation/AppLovin.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e0cca004d45914167a7615697b5d3f5e +folderAsset: yes +timeCreated: 1510861611 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Mediation/AppLovin/AppLovinClient.cs b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Mediation/AppLovin/AppLovinClient.cs new file mode 100644 index 000000000..a1f8d10e8 --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Mediation/AppLovin/AppLovinClient.cs @@ -0,0 +1,44 @@ +// Copyright (C) 2017 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 UnityEngine; + +using GoogleMobileAds.Common.Mediation.AppLovin; + +namespace GoogleMobileAds.iOS.Mediation.AppLovin +{ + public class AppLovinClient: IAppLovinClient + { + private static AppLovinClient instance = new AppLovinClient(); + + private AppLovinClient() {} + + public static AppLovinClient Instance + { + get + { + return instance; + } + } + + public void Initialize() + { + Externs.GADUMInitializeAppLovin(); + } + } +} + +#endif diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Mediation/AppLovin/AppLovinClient.cs.meta b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Mediation/AppLovin/AppLovinClient.cs.meta new file mode 100644 index 000000000..daba452f9 --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Mediation/AppLovin/AppLovinClient.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cc5a1959b7ddb48ad865987851a66bba +timeCreated: 1510862683 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Mediation/AppLovin/Externs.cs b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Mediation/AppLovin/Externs.cs new file mode 100644 index 000000000..a04daf31f --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Mediation/AppLovin/Externs.cs @@ -0,0 +1,30 @@ +// Copyright (C) 2017 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.Runtime.InteropServices; + +namespace GoogleMobileAds.iOS.Mediation.AppLovin +{ + // Externs used by the iOS component. + internal class Externs + { + [DllImport("__Internal")] + internal static extern void GADUMInitializeAppLovin(); + } +} + +#endif diff --git a/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Mediation/AppLovin/Externs.cs.meta b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Mediation/AppLovin/Externs.cs.meta new file mode 100644 index 000000000..e2fee0eb5 --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Mediation/AppLovin/Externs.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 47a073331f5664e4e940b5664b7f3735 +timeCreated: 1510870215 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/mediation/AppLovin/source/plugin/Assets/Plugins/Android/GoogleMobileAdsAppLovinMediation/AndroidManifest.xml b/mediation/AppLovin/source/plugin/Assets/Plugins/Android/GoogleMobileAdsAppLovinMediation/AndroidManifest.xml index 27ebd7582..8dc233751 100644 --- a/mediation/AppLovin/source/plugin/Assets/Plugins/Android/GoogleMobileAdsAppLovinMediation/AndroidManifest.xml +++ b/mediation/AppLovin/source/plugin/Assets/Plugins/Android/GoogleMobileAdsAppLovinMediation/AndroidManifest.xml @@ -4,9 +4,9 @@ - - - + + +void GADUMInitializeAppLovin(void) { + [ALSdk initializeSdk]; +} diff --git a/mediation/AppLovin/source/plugin/Assets/Plugins/iOS/GADUMAppLovinInterface.m.meta b/mediation/AppLovin/source/plugin/Assets/Plugins/iOS/GADUMAppLovinInterface.m.meta new file mode 100644 index 000000000..06aff174d --- /dev/null +++ b/mediation/AppLovin/source/plugin/Assets/Plugins/iOS/GADUMAppLovinInterface.m.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 77e04acdfaed64aa8ad73e3f2368163f +timeCreated: 1510957728 +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/mediation/InMobi/CHANGELOG.md b/mediation/InMobi/CHANGELOG.md new file mode 100644 index 000000000..327857f38 --- /dev/null +++ b/mediation/InMobi/CHANGELOG.md @@ -0,0 +1,7 @@ +# InMobi Adapter plugin for Google Mobile Ads SDK for Unity 3D Changelog + +## 1.0.0 + +- First release! +- Supports Android adapter version 6.2.4.0. +- Supports iOS adapter version 6.2.1.0. diff --git a/mediation/InMobi/README.md b/mediation/InMobi/README.md new file mode 100644 index 000000000..1ed627df2 --- /dev/null +++ b/mediation/InMobi/README.md @@ -0,0 +1,6 @@ +# InMobi 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 +[InMobi Adapter Integration Guide](https://developers.google.com/admob/unity/mediation/unity). + diff --git a/mediation/InMobi/build.gradle b/mediation/InMobi/build.gradle new file mode 100644 index 000000000..7b273a3ec --- /dev/null +++ b/mediation/InMobi/build.gradle @@ -0,0 +1,144 @@ +/* +* Gradle file to build a Unity package to add InMobi 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 = 'GoogleMobileAdsInMobiMediation' + 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", + "${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 = 'InMobi plugin for Google Mobile Ads Mediation.' + websiteUrl = 'https://developers.google.com/admob/unity/mediation/inmobi' + 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/InMobi/source/plugin/Assets/GoogleMobileAds/Editor/InMobiMediationDependencies.xml b/mediation/InMobi/source/plugin/Assets/GoogleMobileAds/Editor/InMobiMediationDependencies.xml new file mode 100644 index 000000000..7a8ac50b3 --- /dev/null +++ b/mediation/InMobi/source/plugin/Assets/GoogleMobileAds/Editor/InMobiMediationDependencies.xml @@ -0,0 +1,33 @@ + + + + + https://jcenter.bintray.com/ + + + + + https://jcenter.bintray.com/ + + + + + https://jcenter.bintray.com/ + + + + + https://jcenter.bintray.com/ + + + + + + + + https://github.com/CocoaPods/Specs + + + + + diff --git a/mediation/InMobi/source/plugin/Assets/GoogleMobileAds/Plugins/Android/GoogleMobileAdsInMobiMediation/AndroidManifest.xml b/mediation/InMobi/source/plugin/Assets/GoogleMobileAds/Plugins/Android/GoogleMobileAdsInMobiMediation/AndroidManifest.xml new file mode 100644 index 000000000..d08d7073e --- /dev/null +++ b/mediation/InMobi/source/plugin/Assets/GoogleMobileAds/Plugins/Android/GoogleMobileAdsInMobiMediation/AndroidManifest.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + diff --git a/mediation/InMobi/source/plugin/Assets/GoogleMobileAds/Plugins/Android/GoogleMobileAdsInMobiMediation/project.properties b/mediation/InMobi/source/plugin/Assets/GoogleMobileAds/Plugins/Android/GoogleMobileAdsInMobiMediation/project.properties new file mode 100644 index 000000000..3a387fb86 --- /dev/null +++ b/mediation/InMobi/source/plugin/Assets/GoogleMobileAds/Plugins/Android/GoogleMobileAdsInMobiMediation/project.properties @@ -0,0 +1,2 @@ +target=android-26 +android.library=true diff --git a/mediation/MyTarget/CHANGELOG.md b/mediation/MyTarget/CHANGELOG.md new file mode 100644 index 000000000..aa0517748 --- /dev/null +++ b/mediation/MyTarget/CHANGELOG.md @@ -0,0 +1,7 @@ +# myTarget Adapter plugin for Google Mobile Ads SDK for Unity 3D Changelog + +## 1.0.0 + +- First release! +- Supports Android adapter version 4.6.27.0. +- Supports iOS adapter version 4.6.24.0. diff --git a/mediation/MyTarget/README.md b/mediation/MyTarget/README.md new file mode 100644 index 000000000..ac18894ce --- /dev/null +++ b/mediation/MyTarget/README.md @@ -0,0 +1,6 @@ +# myTarget 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 +[myTarget Adapter Integration Guide](https://developers.google.com/admob/unity/mediation/myTarget). + diff --git a/mediation/MyTarget/build.gradle b/mediation/MyTarget/build.gradle new file mode 100644 index 000000000..f2c754cf3 --- /dev/null +++ b/mediation/MyTarget/build.gradle @@ -0,0 +1,144 @@ +/* +* Gradle file to build a Unity package to add myTarget 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 = 'GoogleMobileAdsMyTargetMediation' + 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", + "${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 = 'myTarget plugin for Google Mobile Ads Mediation.' + websiteUrl = 'https://developers.google.com/admob/unity/mediation/mytarget' + 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/MyTarget/source/plugin/Assets/GoogleMobileAds/Editor/MyTargetMediationDependencies.xml b/mediation/MyTarget/source/plugin/Assets/GoogleMobileAds/Editor/MyTargetMediationDependencies.xml new file mode 100644 index 000000000..88c65b181 --- /dev/null +++ b/mediation/MyTarget/source/plugin/Assets/GoogleMobileAds/Editor/MyTargetMediationDependencies.xml @@ -0,0 +1,23 @@ + + + + + https://google.bintray.com/mobile-ads-adapters-android + + + + + https://dl.bintray.com/mytarget/maven/ + + + + + + + + https://github.com/CocoaPods/Specs + + + + + diff --git a/mediation/Tapjoy/build.gradle b/mediation/Tapjoy/build.gradle new file mode 100644 index 000000000..43b480b58 --- /dev/null +++ b/mediation/Tapjoy/build.gradle @@ -0,0 +1,68 @@ +/* +* Gradle file to build a Unity package to add Tapjoy mediation support to the Google Mobile Ads Unity plugin. +* Usage: ./gradlew exportPackage +*/ + +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.') + } + + pluginSource = file('source/plugin').absolutePath + pluginBuildDir = file('temp/plugin-build-dir').absolutePath + buildPath = file('temp').absolutePath + exportPath = file('GoogleMobileAdsTapjoyMediation.unitypackage').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) diff --git a/mediation/Tapjoy/source/plugin/Assets/GoogleMobileAds/Editor/TapjoyMediationDependencies.xml b/mediation/Tapjoy/source/plugin/Assets/GoogleMobileAds/Editor/TapjoyMediationDependencies.xml new file mode 100644 index 000000000..dd868bc68 --- /dev/null +++ b/mediation/Tapjoy/source/plugin/Assets/GoogleMobileAds/Editor/TapjoyMediationDependencies.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + https://github.com/CocoaPods/Specs + + + + + diff --git a/mediation/Tapjoy/source/plugin/Assets/Plugins/Android/GoogleMobileAdsTapjoyMediation/AndroidManifest.xml b/mediation/Tapjoy/source/plugin/Assets/Plugins/Android/GoogleMobileAdsTapjoyMediation/AndroidManifest.xml new file mode 100644 index 000000000..cc37fd16a --- /dev/null +++ b/mediation/Tapjoy/source/plugin/Assets/Plugins/Android/GoogleMobileAdsTapjoyMediation/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + diff --git a/mediation/Tapjoy/source/plugin/Assets/Plugins/Android/GoogleMobileAdsTapjoyMediation/project.properties b/mediation/Tapjoy/source/plugin/Assets/Plugins/Android/GoogleMobileAdsTapjoyMediation/project.properties new file mode 100644 index 000000000..78d7553ad --- /dev/null +++ b/mediation/Tapjoy/source/plugin/Assets/Plugins/Android/GoogleMobileAdsTapjoyMediation/project.properties @@ -0,0 +1,3 @@ +target=android-26 +android.library=true + diff --git a/mediation/UnityAds/CHANGELOG.md b/mediation/UnityAds/CHANGELOG.md new file mode 100644 index 000000000..01195a33b --- /dev/null +++ b/mediation/UnityAds/CHANGELOG.md @@ -0,0 +1,7 @@ +# Unity Ads Adapter plugin for Google Mobile Ads SDK for Unity 3D Changelog + +## 1.0.0 + +- First release! +- Supports Android adapter version 2.1.2.0. +- Supports iOS adapter version 2.1.2.0. diff --git a/mediation/UnityAds/README.md b/mediation/UnityAds/README.md new file mode 100644 index 000000000..cfeb5b03c --- /dev/null +++ b/mediation/UnityAds/README.md @@ -0,0 +1,6 @@ +# Unity Ads 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 +[Unity Ads Adapter Integration Guide](https://developers.google.com/admob/unity/mediation/unity). + diff --git a/mediation/UnityAds/build.gradle b/mediation/UnityAds/build.gradle new file mode 100644 index 000000000..105c11185 --- /dev/null +++ b/mediation/UnityAds/build.gradle @@ -0,0 +1,144 @@ +/* +* Gradle file to build a Unity package to add Unity Ads 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 = 'GoogleMobileAdsUnityAdsMediation' + 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", + "${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 = 'Unity Ads plugin for Google Mobile Ads Mediation.' + websiteUrl = 'https://developers.google.com/admob/unity/mediation/unity' + 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/UnityAds/source/plugin/Assets/GoogleMobileAds/Editor/UnityMediationDependencies.xml b/mediation/UnityAds/source/plugin/Assets/GoogleMobileAds/Editor/UnityMediationDependencies.xml new file mode 100644 index 000000000..77f1fda31 --- /dev/null +++ b/mediation/UnityAds/source/plugin/Assets/GoogleMobileAds/Editor/UnityMediationDependencies.xml @@ -0,0 +1,23 @@ + + + + + https://jcenter.bintray.com/ + + + + + https://jcenter.bintray.com/ + + + + + + + + https://github.com/CocoaPods/Specs + + + + + diff --git a/mediation/Vungle/CHANGELOG.md b/mediation/Vungle/CHANGELOG.md new file mode 100644 index 000000000..ef8525759 --- /dev/null +++ b/mediation/Vungle/CHANGELOG.md @@ -0,0 +1,7 @@ +# Vungle Adapter plugin for Google Mobile Ads SDK for Unity 3D Changelog + +## 1.0.0 + +- First release! +- Supports Android adapter version 5.3.0.0. +- Supports iOS adapter version 5.3.0.0. diff --git a/mediation/Vungle/README.md b/mediation/Vungle/README.md new file mode 100644 index 000000000..a3e7c0944 --- /dev/null +++ b/mediation/Vungle/README.md @@ -0,0 +1,6 @@ +# Vungle 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 +[Vungle Adapter Integration Guide](https://developers.google.com/admob/unity/mediation/vungle). + diff --git a/mediation/Vungle/build.gradle b/mediation/Vungle/build.gradle index fc1e778a1..2867010ca 100644 --- a/mediation/Vungle/build.gradle +++ b/mediation/Vungle/build.gradle @@ -2,6 +2,9 @@ * Gradle file to build a Unity package to add Vungle mediation support to the Google Mobile Ads Unity plugin. * Usage: ./gradlew exportPackage */ +plugins { + id "com.jfrog.bintray" version "1.7.3" +} defaultTasks 'exportPackage' @@ -20,10 +23,15 @@ project.ext { 'UNITY_EXE environment variable and point it to your Unity installation.') } + versionString = '1.0.0' + pluginName = 'GoogleMobileAdsVungleMediation' + 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('GoogleMobileAdsVungleMediation.unitypackage').absolutePath + exportPath = file(pluginFileName).absolutePath } // Build jar from android plugin source files using existing Gradle build file. @@ -90,3 +98,72 @@ task clearTempBuildFolder(type: Delete) { exportPackage.dependsOn(createTempBuildFolder, copyAndroidLibraryJar, copyExtrasInterface) 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 = 'Vungle plugin for Google Mobile Ads Mediation.' + websiteUrl = 'https://developers.google.com/admob/unity/mediation/vungle' + 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/Vungle/source/android-library/gradle/wrapper/gradle-wrapper.jar b/mediation/Vungle/source/android-library/gradle/wrapper/gradle-wrapper.jar index 12a08711a..7a3265ee9 100644 Binary files a/mediation/Vungle/source/android-library/gradle/wrapper/gradle-wrapper.jar and b/mediation/Vungle/source/android-library/gradle/wrapper/gradle-wrapper.jar differ diff --git a/mediation/Vungle/source/android-library/gradle/wrapper/gradle-wrapper.properties b/mediation/Vungle/source/android-library/gradle/wrapper/gradle-wrapper.properties index ee050b283..4afd970f0 100644 --- a/mediation/Vungle/source/android-library/gradle/wrapper/gradle-wrapper.properties +++ b/mediation/Vungle/source/android-library/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed Jul 12 16:58:21 PDT 2017 +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.1-bin.zip +zipStoreBase=GRADLE_USER_HOME diff --git a/source/android-library/app/build.gradle b/source/android-library/app/build.gradle index 21099c181..f79ba7c24 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.6.0' + api 'com.google.android.gms:play-services-ads:11.6.2' } task clearJar(type: Delete) { diff --git a/source/android-library/app/src/main/java/com/google/unity/ads/Banner.java b/source/android-library/app/src/main/java/com/google/unity/ads/Banner.java index e01206f25..b95641041 100644 --- a/source/android-library/app/src/main/java/com/google/unity/ads/Banner.java +++ b/source/android-library/app/src/main/java/com/google/unity/ads/Banner.java @@ -17,6 +17,7 @@ import android.app.Activity; import android.graphics.Color; +import android.graphics.Point; import android.os.Build; import android.util.Log; import android.view.Gravity; @@ -136,7 +137,7 @@ public void run() { }); } - public void createAdView(final String publisherId, final AdSize adSize) { + private void createAdView(final String publisherId, final AdSize adSize) { mAdView = new AdView(mUnityPlayerActivity); // Setting the background color works around an issue where the first ad isn't visible. mAdView.setBackgroundColor(Color.TRANSPARENT); @@ -205,37 +206,10 @@ private void createPopupWindow() { 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); - } - } + // Android Nougat has a PopUpWindow bug where gravity doesn't position views as expected. + // Using offset values as a workaround. + Point location = getPositionInPixels(anchorView); + mPopupWindow.showAsDropDown(anchorView, location.x, location.y); } /** @@ -308,6 +282,96 @@ public void run() { }); } + /** + * Get {@link AdView} height. + * @return the height of the {@link AdView}. + */ + public float getHeightInPixels() { + return mAdView.getAdSize().getHeightInPixels(mUnityPlayerActivity); + } + + /** + * Get {@link AdView} width. + * @return the width of the {@link AdView}. + */ + public float getWidthInPixels() { + return mAdView.getAdSize().getWidthInPixels(mUnityPlayerActivity); + } + + /** + * Updates the {@link AdView} position. + * + * @param positionCode A code indicating where to place the ad. + */ + public void setPosition(final int positionCode) { + mUnityPlayerActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mPositionCode = positionCode; + updatePosition(); + } + }); + } + + /** + * Updates the {@link AdView} position. + * + * @param positionX Position of banner ad on the x axis. + * @param positionY Position of banner ad on the y axis. + */ + public void setPosition(final int positionX, final int positionY) { + mUnityPlayerActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mPositionCode = PluginUtils.POSITION_CUSTOM; + mHorizontalOffset = positionX; + mVerticalOffset = positionY; + updatePosition(); + } + }); + } + + /** + * Update the {@link AdView} position based on current parameters. + */ + private void updatePosition() { + + if (mPopupWindow != null && mPopupWindow.isShowing()) { + View anchorView = mUnityPlayerActivity.getWindow().getDecorView().getRootView(); + Point location = getPositionInPixels(anchorView); + mPopupWindow.update(anchorView, + location.x, + location.y, + mPopupWindow.getWidth(), + mPopupWindow.getHeight()); + } + } + + /** + * Gets the location for the PopUp window based on the current position code / offset and ad + * view size. The location is in bottom left coordinate system as per the showAsDropDown and + * update methods requirements. + * @param anchorView the anchorview to position against. + * @return the position point in pixels in the bottom left coordinate system. + */ + private Point getPositionInPixels(View anchorView) { + + if (mPositionCode == PluginUtils.POSITION_CUSTOM) { + int x = (int) PluginUtils.convertDpToPixel(mHorizontalOffset); + int y = (int) PluginUtils.convertDpToPixel(mVerticalOffset) - anchorView.getHeight(); + return new Point(x, y); + } else { + int adViewWidth = mAdView.getAdSize().getWidthInPixels(mUnityPlayerActivity); + int adViewHeight = mAdView.getAdSize().getHeightInPixels(mUnityPlayerActivity); + + int x = PluginUtils.getHorizontalOffsetForPositionCode(mPositionCode, adViewWidth, + anchorView.getWidth()); + int y = PluginUtils.getVerticalOffsetForPositionCode(mPositionCode, adViewHeight, + anchorView.getHeight()); + return new Point(x, y); + } + } + /** * 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. diff --git a/source/android-library/app/src/main/java/com/google/unity/ads/PluginUtils.java b/source/android-library/app/src/main/java/com/google/unity/ads/PluginUtils.java index fa16f3c07..03167f91b 100644 --- a/source/android-library/app/src/main/java/com/google/unity/ads/PluginUtils.java +++ b/source/android-library/app/src/main/java/com/google/unity/ads/PluginUtils.java @@ -162,6 +162,14 @@ public static int getHorizontalOffsetForPositionCode(int positionCode, int viewW return offset; } + /** + * Returns the vertical offset using a bottom left co-ordinate system. + * i.e top is at -anchorHeight. + * @param positionCode the position code to use + * @param viewHeight the height of the view + * @param anchorHeight the height of the anchoring view to position in + * @return the vertical offset relative to the bottom of the anchorview. + */ public static int getVerticalOffsetForPositionCode(int positionCode, int viewHeight, int anchorHeight) { int offset; diff --git a/source/android-library/gradle/wrapper/gradle-wrapper.jar b/source/android-library/gradle/wrapper/gradle-wrapper.jar index 12a08711a..7a3265ee9 100644 Binary files a/source/android-library/gradle/wrapper/gradle-wrapper.jar and b/source/android-library/gradle/wrapper/gradle-wrapper.jar differ diff --git a/source/android-library/gradle/wrapper/gradle-wrapper.properties b/source/android-library/gradle/wrapper/gradle-wrapper.properties index ee050b283..4afd970f0 100644 --- a/source/android-library/gradle/wrapper/gradle-wrapper.properties +++ b/source/android-library/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed Jul 12 16:58:21 PDT 2017 +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.1-bin.zip +zipStoreBase=GRADLE_USER_HOME diff --git a/source/plugin/Assets/GoogleMobileAds/Api/AdRequest.cs b/source/plugin/Assets/GoogleMobileAds/Api/AdRequest.cs index 9ecbc491c..6191f4015 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.9.0"; + public const string Version = "3.10.0"; public const string TestDeviceSimulator = "SIMULATOR"; private AdRequest(Builder builder) diff --git a/source/plugin/Assets/GoogleMobileAds/Api/BannerView.cs b/source/plugin/Assets/GoogleMobileAds/Api/BannerView.cs index 0cff00f8c..d9cf299bc 100644 --- a/source/plugin/Assets/GoogleMobileAds/Api/BannerView.cs +++ b/source/plugin/Assets/GoogleMobileAds/Api/BannerView.cs @@ -86,6 +86,30 @@ public void Destroy() client.DestroyBannerView(); } + // Returns the height of the BannerView in pixels. + public float GetHeightInPixels() + { + return client.GetHeightInPixels(); + } + + // Returns the width of the BannerView in pixels. + public float GetWidthInPixels() + { + return client.GetWidthInPixels(); + } + + // Set the position of the BannerView using standard position. + public void SetPosition(AdPosition adPosition) + { + client.SetPosition(adPosition); + } + + // Set the position of the BannerView using custom position. + public void SetPosition(int x, int y) + { + client.SetPosition(x, y); + } + private void ConfigureBannerEvents() { this.client.OnAdLoaded += (sender, args) => diff --git a/source/plugin/Assets/GoogleMobileAds/Common/DummyClient.cs b/source/plugin/Assets/GoogleMobileAds/Common/DummyClient.cs index bb26ef9e0..63da6acfc 100644 --- a/source/plugin/Assets/GoogleMobileAds/Common/DummyClient.cs +++ b/source/plugin/Assets/GoogleMobileAds/Common/DummyClient.cs @@ -108,6 +108,28 @@ public void DestroyBannerView() Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); } + public float GetHeightInPixels() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + return 0; + } + + public float GetWidthInPixels() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + return 0; + } + + public void SetPosition(AdPosition adPosition) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void SetPosition(int x, int y) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + public void CreateInterstitialAd(string adUnitId) { Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); diff --git a/source/plugin/Assets/GoogleMobileAds/Common/IBannerClient.cs b/source/plugin/Assets/GoogleMobileAds/Common/IBannerClient.cs index 7eba4f194..8c33b989a 100644 --- a/source/plugin/Assets/GoogleMobileAds/Common/IBannerClient.cs +++ b/source/plugin/Assets/GoogleMobileAds/Common/IBannerClient.cs @@ -48,6 +48,18 @@ public interface IBannerClient // Destroys a banner view. void DestroyBannerView(); + // Returns the height of the BannerView in pixels. + float GetHeightInPixels(); + + // Returns the width of the BannerView in pixels. + float GetWidthInPixels(); + + // Set the position of the banner view using standard position. + void SetPosition(AdPosition adPosition); + + // Set the position of the banner view using custom position. + void SetPosition(int x, int y); + // Returns the mediation adapter class name. string MediationAdapterClassName(); } diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/Android/BannerClient.cs b/source/plugin/Assets/GoogleMobileAds/Platforms/Android/BannerClient.cs index cc8cc8ebb..c824fe159 100644 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/Android/BannerClient.cs +++ b/source/plugin/Assets/GoogleMobileAds/Platforms/Android/BannerClient.cs @@ -85,6 +85,30 @@ public void DestroyBannerView() this.bannerView.Call("destroy"); } + // Returns the height of the BannerView in pixels. + public float GetHeightInPixels() + { + return this.bannerView.Call("getHeightInPixels"); + } + + // Returns the width of the BannerView in pixels. + public float GetWidthInPixels() + { + return this.bannerView.Call("getWidthInPixels"); + } + + // Set the position of the banner view using standard position. + public void SetPosition(AdPosition adPosition) + { + this.bannerView.Call("setPosition", (int)adPosition); + } + + // Set the position of the banner view using custom position. + public void SetPosition(int x, int y) + { + this.bannerView.Call("setPosition", x, y); + } + // Returns the mediation adapter class name. public string MediationAdapterClassName() { diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/BannerClient.cs b/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/BannerClient.cs index e2f5601b3..3c13b7948 100644 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/BannerClient.cs +++ b/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/BannerClient.cs @@ -156,6 +156,30 @@ public void DestroyBannerView() this.BannerViewPtr = IntPtr.Zero; } + // Returns the height of the BannerView in pixels. + public float GetHeightInPixels() + { + return Externs.GADUGetBannerViewHeightInPixels(this.BannerViewPtr); + } + + // Returns the width of the BannerView in pixels. + public float GetWidthInPixels() + { + return Externs.GADUGetBannerViewWidthInPixels(this.BannerViewPtr); + } + + // Set the position of the banner view using standard position. + public void SetPosition(AdPosition adPosition) + { + Externs.GADUSetBannerViewAdPosition(this.BannerViewPtr, (int)adPosition); + } + + // Set the position of the banner view using custom position. + public void SetPosition(int x, int y) + { + Externs.GADUSetBannerViewCustomPosition(this.BannerViewPtr, x, y); + } + // Returns the mediation adapter class name. public string MediationAdapterClassName() { diff --git a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Externs.cs b/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Externs.cs index 57cabdfd8..8b0fc5cfa 100644 --- a/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Externs.cs +++ b/source/plugin/Assets/GoogleMobileAds/Platforms/iOS/Externs.cs @@ -122,6 +122,18 @@ internal static extern void GADUSetBannerCallbacks( [DllImport("__Internal")] internal static extern void GADURequestBannerAd(IntPtr bannerView, IntPtr request); + [DllImport("__Internal")] + internal static extern float GADUGetBannerViewHeightInPixels(IntPtr bannerView); + + [DllImport("__Internal")] + internal static extern float GADUGetBannerViewWidthInPixels(IntPtr bannerView); + + [DllImport("__Internal")] + internal static extern void GADUSetBannerViewAdPosition(IntPtr bannerView, int position); + + [DllImport("__Internal")] + internal static extern void GADUSetBannerViewCustomPosition(IntPtr bannerView, int x, int y); + [DllImport("__Internal")] internal static extern string GADUMediationAdapterClassNameForBannerView(IntPtr bannerView); diff --git a/source/plugin/Assets/Plugins/iOS/GADUBanner.h b/source/plugin/Assets/Plugins/iOS/GADUBanner.h index 2f77546ee..43442391d 100644 --- a/source/plugin/Assets/Plugins/iOS/GADUBanner.h +++ b/source/plugin/Assets/Plugins/iOS/GADUBanner.h @@ -59,6 +59,12 @@ // Returns the mediation adapter class name. @property(nonatomic, readonly, copy) NSString *mediationAdapterClassName; +// Returns the height of the banner view in pixels. +@property(nonatomic, readonly) CGFloat heightInPixels; + +// Returns the width of the banner view in pixels. +@property(nonatomic, readonly) CGFloat widthInPixels; + /// Makes an ad request. Additional targeting options can be supplied with a request object. - (void)loadRequest:(GADRequest *)request; @@ -71,4 +77,10 @@ /// Removes the GADBannerView from the view hierarchy. - (void)removeBannerView; +/// Set the GADBannerView's position on screen using a standard position. +- (void)setAdPosition:(GADAdPosition)adPosition; + +/// Set the GADBannerView's position on screen using a custom position. +- (void)setCustomAdPosition:(CGPoint)customPosition; + @end diff --git a/source/plugin/Assets/Plugins/iOS/GADUBanner.m b/source/plugin/Assets/Plugins/iOS/GADUBanner.m index 151140828..6c289d9b2 100644 --- a/source/plugin/Assets/Plugins/iOS/GADUBanner.m +++ b/source/plugin/Assets/Plugins/iOS/GADUBanner.m @@ -84,7 +84,7 @@ - (id)initWithBannerClientReference:(GADUTypeBannerClientRef *)bannerClient if (self) { _bannerClient = bannerClient; _adPosition = adPosition; - _bannerView = [[GADBannerView alloc] initWithAdSize:size]; + _bannerView = [[GADBannerView alloc] initWithAdSize:[GADUPluginUtil safeAdSizeForAdSize:size]]; _bannerView.adUnitID = adUnitID; _bannerView.delegate = self; _bannerView.rootViewController = [GADUPluginUtil unityGLViewController]; @@ -101,7 +101,7 @@ - (id)initWithBannerClientReference:(GADUTypeBannerClientRef *)bannerClient _bannerClient = bannerClient; _customAdPosition = customAdPosition; _adPosition = kGADAdPositionCustom; - _bannerView = [[GADBannerView alloc] initWithAdSize:size]; + _bannerView = [[GADBannerView alloc] initWithAdSize:[GADUPluginUtil safeAdSizeForAdSize:size]]; _bannerView.adUnitID = adUnitID; _bannerView.delegate = self; _bannerView.rootViewController = [GADUPluginUtil unityGLViewController]; @@ -149,27 +149,51 @@ - (NSString *)mediationAdapterClassName { return [self.bannerView adNetworkClassName]; } -#pragma mark GADBannerViewDelegate implementation +- (CGFloat)heightInPixels { + return CGRectGetHeight(CGRectStandardize(self.bannerView.frame)) * [UIScreen mainScreen].scale; +} -- (void)adViewDidReceiveAd:(GADBannerView *)adView { - // Remove existing banner view from superview. - [self.bannerView removeFromSuperview]; +- (CGFloat)widthInPixels { + return CGRectGetWidth(CGRectStandardize(self.bannerView.frame)) * [UIScreen mainScreen].scale; +} - // Add the new banner view. - self.bannerView = adView; +- (void)setAdPosition:(GADAdPosition)adPosition { + _adPosition = adPosition; + [self positionBannerView]; +} + +- (void)setCustomAdPosition:(CGPoint)customPosition { + _customAdPosition = customPosition; + _adPosition = kGADAdPositionCustom; + [self positionBannerView]; +} +- (void)positionBannerView { /// Align the bannerView in the Unity view bounds. UIView *unityView = [GADUPluginUtil unityGLViewController].view; if (self.adPosition != kGADAdPositionCustom) { - [GADUPluginUtil positionView:self.bannerView - inParentView:unityView - adPosition:self.adPosition]; + [GADUPluginUtil positionView:self.bannerView inParentView:unityView adPosition:self.adPosition]; } else { [GADUPluginUtil positionView:self.bannerView inParentView:unityView customPosition:self.customAdPosition]; } +} + +#pragma mark GADBannerViewDelegate implementation + +- (void)adViewDidReceiveAd:(GADBannerView *)adView { + // Remove existing banner view from superview. + [self.bannerView removeFromSuperview]; + + // Add the new banner view. + self.bannerView = adView; + + /// Align the bannerView in the Unity view bounds. + UIView *unityView = [GADUPluginUtil unityGLViewController].view; + + [self positionBannerView]; [unityView addSubview:self.bannerView]; diff --git a/source/plugin/Assets/Plugins/iOS/GADUInterface.m b/source/plugin/Assets/Plugins/iOS/GADUInterface.m index df54e1f25..da629b54d 100644 --- a/source/plugin/Assets/Plugins/iOS/GADUInterface.m +++ b/source/plugin/Assets/Plugins/iOS/GADUInterface.m @@ -301,6 +301,16 @@ void GADURemoveBannerView(GADUTypeBannerRef banner) { [internalBanner removeBannerView]; } +float GADUGetBannerViewHeightInPixels(GADUTypeBannerRef banner) { + GADUBanner *internalBanner = (__bridge GADUBanner *)banner; + return internalBanner.heightInPixels; +} + +float GADUGetBannerViewWidthInPixels(GADUTypeBannerRef banner) { + GADUBanner *internalBanner = (__bridge GADUBanner *)banner; + return internalBanner.widthInPixels; +} + /// Hides the GADNativeExpressAdView. void GADUHideNativeExpressAdView(GADUTypeNativeExpressAdRef nativeExpressAd) { GADUNativeExpressAd *internalNativeExpressAd = (__bridge GADUNativeExpressAd *)nativeExpressAd; @@ -443,6 +453,16 @@ void GADURequestBannerAd(GADUTypeBannerRef banner, GADUTypeRequestRef request) { [internalBanner loadRequest:[internalRequest request]]; } +void GADUSetBannerViewAdPosition(GADUTypeBannerRef banner, int position) { + GADUBanner *internalBanner = (__bridge GADUBanner *)banner; + [internalBanner setAdPosition:(GADAdPosition)position]; +} + +void GADUSetBannerViewCustomPosition(GADUTypeBannerRef banner, int x, int y) { + GADUBanner *internalBanner = (__bridge GADUBanner *)banner; + [internalBanner setCustomAdPosition:CGPointMake(x, y)]; +} + /// Makes an interstitial ad request. void GADURequestInterstitial(GADUTypeInterstitialRef interstitial, GADUTypeRequestRef request) { GADUInterstitial *internalInterstitial = (__bridge GADUInterstitial *)interstitial; diff --git a/source/plugin/Assets/Plugins/iOS/GADUPluginUtil.h b/source/plugin/Assets/Plugins/iOS/GADUPluginUtil.h index bf0a74977..c3361b2e4 100644 --- a/source/plugin/Assets/Plugins/iOS/GADUPluginUtil.h +++ b/source/plugin/Assets/Plugins/iOS/GADUPluginUtil.h @@ -24,4 +24,9 @@ /// Returns a GADAdSize for a specified width and height. + (GADAdSize)adSizeForWidth:(CGFloat)width height:(CGFloat)height; +/// If requesting smart banner landscape, returns the custom size for landscape smart banners which +/// is full width of the safe area and auto height. Assumes that the application window is visible. +/// If requesting any other ad size, returns the un-modified ad size. ++ (GADAdSize)safeAdSizeForAdSize:(GADAdSize)adSize; + @end diff --git a/source/plugin/Assets/Plugins/iOS/GADUPluginUtil.m b/source/plugin/Assets/Plugins/iOS/GADUPluginUtil.m index 16584284a..d15419dcb 100644 --- a/source/plugin/Assets/Plugins/iOS/GADUPluginUtil.m +++ b/source/plugin/Assets/Plugins/iOS/GADUPluginUtil.m @@ -8,8 +8,6 @@ @interface UIView (unityStub) @property UILayoutGuide *safeAreaLayoutGuide; @end -@implementation GADUPluginUtil - static BOOL IsOperatingSystemAtLeastVersion(NSInteger majorVersion) { NSProcessInfo *processInfo = NSProcessInfo.processInfo; if ([processInfo respondsToSelector:@selector(isOperatingSystemAtLeastVersion:)]) { @@ -22,6 +20,30 @@ static BOOL IsOperatingSystemAtLeastVersion(NSInteger majorVersion) { } } +static CGFloat FullSafeWidthLandscape(void) { + CGRect screenBounds = [UIScreen mainScreen].bounds; + if (IsOperatingSystemAtLeastVersion(11)) { + CGRect safeFrame = [UIApplication sharedApplication].keyWindow.safeAreaLayoutGuide.layoutFrame; + if (!CGSizeEqualToSize(safeFrame.size, CGSizeZero)) { + screenBounds = safeFrame; + } + } + return MAX(CGRectGetWidth(screenBounds), CGRectGetHeight(screenBounds)); +} + +@implementation GADUPluginUtil + ++ (GADAdSize)safeAdSizeForAdSize:(GADAdSize)adSize { + if (IsOperatingSystemAtLeastVersion(11) && + GADAdSizeEqualToSize(kGADAdSizeSmartBannerLandscape, adSize)) { + CGSize usualSize = CGSizeFromGADAdSize(kGADAdSizeSmartBannerLandscape); + CGSize bannerSize = CGSizeMake(FullSafeWidthLandscape(), usualSize.height); + return GADAdSizeFromCGSize(bannerSize); + } else { + return adSize; + } +} + + (UIViewController *)unityGLViewController { return ((UnityAppController *)[UIApplication sharedApplication].delegate).rootViewController; } @@ -31,7 +53,10 @@ + (void)positionView:(UIView *)view adPosition:(GADAdPosition)adPosition { CGRect parentBounds = parentView.bounds; if (IsOperatingSystemAtLeastVersion(11)) { - parentBounds = parentView.safeAreaLayoutGuide.layoutFrame; + CGRect safeAreaFrame = parentView.safeAreaLayoutGuide.layoutFrame; + if (!CGSizeEqualToSize(CGSizeZero, safeAreaFrame.size)) { + parentBounds = safeAreaFrame; + } } CGFloat top = CGRectGetMinY(parentBounds) + CGRectGetMidY(view.bounds); CGFloat left = CGRectGetMinX(parentBounds) + CGRectGetMidX(view.bounds); @@ -86,8 +111,16 @@ + (void)positionView:(UIView *)view + (void)positionView:(UIView *)view inParentView:(UIView *)parentView customPosition:(CGPoint)adPosition { - CGPoint center = CGPointMake(adPosition.x + CGRectGetMidX(view.bounds), - adPosition.y + CGRectGetMidY(view.bounds)); + CGPoint origin = parentView.bounds.origin; + if (IsOperatingSystemAtLeastVersion(11)) { + CGRect safeAreaFrame = parentView.safeAreaLayoutGuide.layoutFrame; + if (!CGSizeEqualToSize(CGSizeZero, safeAreaFrame.size)) { + origin = safeAreaFrame.origin; + } + } + + CGPoint center = CGPointMake(origin.x + adPosition.x + CGRectGetMidX(view.bounds), + origin.y + adPosition.y + CGRectGetMidY(view.bounds)); view.center = center; } @@ -98,7 +131,7 @@ + (GADAdSize)adSizeForWidth:(CGFloat)width height:(CGFloat)height { return GADAdSizeFullWidthPortraitWithHeight(height); } else if ((width == kGADUAdSizeUseFullWidth && UIInterfaceOrientationIsLandscape(currentOrientation))) { - return GADAdSizeFullWidthLandscapeWithHeight(height); + return GADAdSizeFromCGSize(CGSizeMake(FullSafeWidthLandscape(), height)); } return GADAdSizeFromCGSize(CGSizeMake(width, height)); }