You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

281 lines
11 KiB

  1. // Copyright (C) 2015 Google, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #if UNITY_IOS
  15. using System;
  16. using System.Runtime.InteropServices;
  17. namespace GoogleMobileAds.iOS
  18. {
  19. // Externs used by the iOS component.
  20. internal class Externs
  21. {
  22. #region Common externs
  23. [DllImport("__Internal")]
  24. internal static extern void GADUInitialize(string key);
  25. [DllImport("__Internal")]
  26. internal static extern void GADUSetApplicationVolume(float volume);
  27. [DllImport("__Internal")]
  28. internal static extern void GADUSetApplicationMuted(bool muted);
  29. [DllImport("__Internal")]
  30. internal static extern void GADUSetiOSAppPauseOnBackground(bool pause);
  31. [DllImport("__Internal")]
  32. internal static extern IntPtr GADUCreateRequest();
  33. [DllImport("__Internal")]
  34. internal static extern IntPtr GADUCreateMutableDictionary();
  35. [DllImport("__Internal")]
  36. internal static extern void GADUMutableDictionarySetValue(
  37. IntPtr mutableDictionaryPtr,
  38. string key,
  39. string value);
  40. [DllImport("__Internal")]
  41. internal static extern void GADUSetMediationExtras(
  42. IntPtr request,
  43. IntPtr mutableDictionaryPtr,
  44. string adNetworkExtrasClassName);
  45. [DllImport("__Internal")]
  46. internal static extern void GADUAddTestDevice(IntPtr request, string deviceId);
  47. [DllImport("__Internal")]
  48. internal static extern void GADUAddKeyword(IntPtr request, string keyword);
  49. [DllImport("__Internal")]
  50. internal static extern void GADUSetBirthday(IntPtr request, int year, int month, int day);
  51. [DllImport("__Internal")]
  52. internal static extern void GADUSetGender(IntPtr request, int genderCode);
  53. [DllImport("__Internal")]
  54. internal static extern void GADUTagForChildDirectedTreatment(
  55. IntPtr request, bool childDirectedTreatment);
  56. [DllImport("__Internal")]
  57. internal static extern void GADUSetExtra(IntPtr request, string key, string value);
  58. [DllImport("__Internal")]
  59. internal static extern void GADUSetRequestAgent(IntPtr request, string requestAgent);
  60. [DllImport("__Internal")]
  61. internal static extern void GADURelease(IntPtr obj);
  62. #endregion
  63. #region Banner externs
  64. [DllImport("__Internal")]
  65. internal static extern IntPtr GADUCreateBannerView(
  66. IntPtr bannerClient, string adUnitId, int width, int height, int positionAtTop);
  67. [DllImport("__Internal")]
  68. internal static extern IntPtr GADUCreateBannerViewWithCustomPosition(
  69. IntPtr bannerClient,
  70. string adUnitId,
  71. int width,
  72. int height,
  73. int x,
  74. int y);
  75. [DllImport("__Internal")]
  76. internal static extern IntPtr GADUCreateSmartBannerView(
  77. IntPtr bannerClient, string adUnitId, int positionAtTop);
  78. [DllImport("__Internal")]
  79. internal static extern IntPtr GADUCreateSmartBannerViewWithCustomPosition(
  80. IntPtr bannerClient, string adUnitId, int x, int y);
  81. [DllImport("__Internal")]
  82. internal static extern void GADUSetBannerCallbacks(
  83. IntPtr bannerView,
  84. BannerClient.GADUAdViewDidReceiveAdCallback adReceivedCallback,
  85. BannerClient.GADUAdViewDidFailToReceiveAdWithErrorCallback adFailedCallback,
  86. BannerClient.GADUAdViewWillPresentScreenCallback willPresentCallback,
  87. BannerClient.GADUAdViewDidDismissScreenCallback didDismissCallback,
  88. BannerClient.GADUAdViewWillLeaveApplicationCallback willLeaveCallback);
  89. [DllImport("__Internal")]
  90. internal static extern void GADUHideBannerView(IntPtr bannerView);
  91. [DllImport("__Internal")]
  92. internal static extern void GADUShowBannerView(IntPtr bannerView);
  93. [DllImport("__Internal")]
  94. internal static extern void GADURemoveBannerView(IntPtr bannerView);
  95. [DllImport("__Internal")]
  96. internal static extern void GADURequestBannerAd(IntPtr bannerView, IntPtr request);
  97. [DllImport("__Internal")]
  98. internal static extern float GADUGetBannerViewHeightInPixels(IntPtr bannerView);
  99. [DllImport("__Internal")]
  100. internal static extern float GADUGetBannerViewWidthInPixels(IntPtr bannerView);
  101. [DllImport("__Internal")]
  102. internal static extern void GADUSetBannerViewAdPosition(IntPtr bannerView, int position);
  103. [DllImport("__Internal")]
  104. internal static extern void GADUSetBannerViewCustomPosition(IntPtr bannerView, int x, int y);
  105. [DllImport("__Internal")]
  106. internal static extern string GADUMediationAdapterClassNameForBannerView(IntPtr bannerView);
  107. #endregion
  108. #region Interstitial externs
  109. [DllImport("__Internal")]
  110. internal static extern IntPtr GADUCreateInterstitial(
  111. IntPtr interstitialClient, string adUnitId);
  112. [DllImport("__Internal")]
  113. internal static extern void GADUSetInterstitialCallbacks(
  114. IntPtr interstitial,
  115. InterstitialClient.GADUInterstitialDidReceiveAdCallback adReceivedCallback,
  116. InterstitialClient.GADUInterstitialDidFailToReceiveAdWithErrorCallback
  117. adFailedCallback,
  118. InterstitialClient.GADUInterstitialWillPresentScreenCallback willPresentCallback,
  119. InterstitialClient.GADUInterstitialDidDismissScreenCallback didDismissCallback,
  120. InterstitialClient.GADUInterstitialWillLeaveApplicationCallback
  121. willLeaveCallback);
  122. [DllImport("__Internal")]
  123. internal static extern bool GADUInterstitialReady(IntPtr interstitial);
  124. [DllImport("__Internal")]
  125. internal static extern void GADUShowInterstitial(IntPtr interstitial);
  126. [DllImport("__Internal")]
  127. internal static extern void GADURequestInterstitial(IntPtr interstitial, IntPtr request);
  128. [DllImport("__Internal")]
  129. internal static extern string GADUMediationAdapterClassNameForInterstitial(IntPtr interstitial);
  130. #endregion
  131. #region Reward based video externs
  132. [DllImport("__Internal")]
  133. internal static extern IntPtr GADUCreateRewardBasedVideoAd(IntPtr rewardBasedVideo);
  134. [DllImport("__Internal")]
  135. internal static extern bool GADURewardBasedVideoAdReady(IntPtr rewardBasedVideo);
  136. [DllImport("__Internal")]
  137. internal static extern void GADUShowRewardBasedVideoAd(IntPtr rewardBasedVideo);
  138. [DllImport("__Internal")]
  139. internal static extern void GADUSetRewardBasedVideoAdUserId(IntPtr rewardBasedVideo, string userId);
  140. [DllImport("__Internal")]
  141. internal static extern void GADURequestRewardBasedVideoAd(
  142. IntPtr bannerView, IntPtr request, string adUnitId);
  143. [DllImport("__Internal")]
  144. internal static extern void GADUSetRewardBasedVideoAdCallbacks(
  145. IntPtr rewardBasedVideo,
  146. RewardBasedVideoAdClient.GADURewardBasedVideoAdDidReceiveAdCallback
  147. adReceivedCallback,
  148. RewardBasedVideoAdClient.GADURewardBasedVideoAdDidFailToReceiveAdWithErrorCallback
  149. adFailedCallback,
  150. RewardBasedVideoAdClient.GADURewardBasedVideoAdDidOpenCallback didOpenCallback,
  151. RewardBasedVideoAdClient.GADURewardBasedVideoAdDidStartCallback didStartCallback,
  152. RewardBasedVideoAdClient.GADURewardBasedVideoAdDidCloseCallback didCloseCallback,
  153. RewardBasedVideoAdClient.GADURewardBasedVideoAdDidRewardCallback didRewardcallback,
  154. RewardBasedVideoAdClient.GADURewardBasedVideoAdWillLeaveApplicationCallback
  155. willLeaveCallback,
  156. RewardBasedVideoAdClient.GADURewardBasedVideoAdDidCompleteCallback didCompleteCallback);
  157. [DllImport("__Internal")]
  158. internal static extern string GADUMediationAdapterClassNameForRewardedVideo(IntPtr rewardedVideo);
  159. #endregion
  160. #region AdLoader externs
  161. [DllImport("__Internal")]
  162. internal static extern IntPtr GADUCreateAdLoader(
  163. IntPtr adLoader,
  164. string adUnitId,
  165. string[] templateIds,
  166. int templateIdsCount,
  167. ref NativeAdTypes types);
  168. [DllImport("__Internal")]
  169. internal static extern void GADURequestNativeAd(IntPtr adLoader, IntPtr request);
  170. [DllImport("__Internal")]
  171. internal static extern void GADUSetAdLoaderCallbacks(
  172. IntPtr adLoader,
  173. AdLoaderClient.GADUAdLoaderDidReceiveNativeCustomTemplateAdCallback adReceivedCallback,
  174. AdLoaderClient.GADUAdLoaderDidFailToReceiveAdWithErrorCallback adFailedCallback);
  175. #endregion
  176. #region NativeCustomTemplateAd externs
  177. [DllImport("__Internal")]
  178. internal static extern string GADUNativeCustomTemplateAdTemplateID(
  179. IntPtr nativeCustomTemplateAd);
  180. [DllImport("__Internal")]
  181. internal static extern string GADUNativeCustomTemplateAdImageAsBytesForKey(
  182. IntPtr nativeCustomTemplateAd, string key);
  183. [DllImport("__Internal")]
  184. internal static extern string GADUNativeCustomTemplateAdStringForKey(
  185. IntPtr nativeCustomTemplateAd, string key);
  186. [DllImport("__Internal")]
  187. internal static extern void GADUNativeCustomTemplateAdRecordImpression(
  188. IntPtr nativeCustomTemplateAd);
  189. [DllImport("__Internal")]
  190. internal static extern void GADUNativeCustomTemplateAdPerformClickOnAssetWithKey(
  191. IntPtr nativeCustomTemplateAd, string assetName, bool customClickAction);
  192. [DllImport("__Internal")]
  193. internal static extern IntPtr GADUNativeCustomTemplateAdAvailableAssetKeys(
  194. IntPtr nativeCustomTemplateAd);
  195. [DllImport("__Internal")]
  196. internal static extern int GADUNativeCustomTemplateAdNumberOfAvailableAssetKeys(
  197. IntPtr nativeCustomTemplateAd);
  198. [DllImport("__Internal")]
  199. internal static extern void GADUSetNativeCustomTemplateAdUnityClient(
  200. IntPtr nativeCustomTemplateAd, IntPtr nativeCustomTemplateClient);
  201. [DllImport("__Internal")]
  202. internal static extern void GADUSetNativeCustomTemplateAdCallbacks(
  203. IntPtr nativeCustomTemplateAd,
  204. CustomNativeTemplateClient.GADUNativeCustomTemplateDidReceiveClick
  205. adClickedCallback);
  206. #endregion
  207. }
  208. }
  209. #endif