react-native-google-mobile-ads 5.0.1 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/RNGoogleMobileAds.podspec +1 -1
  2. package/__tests__/interstitial.test.ts +32 -5
  3. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsAppOpenModule.java +2 -1
  4. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsBannerAdViewManager.java +110 -68
  5. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java +5 -11
  6. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java +19 -5
  7. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsEvent.java +1 -0
  8. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsInterstitialModule.java +38 -20
  9. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsModule.java +45 -0
  10. package/docs/ad-inspector.mdx +39 -0
  11. package/docs/common-reasons-for-ads-not-showing.mdx +26 -24
  12. package/docs/displaying-ads-hook.mdx +99 -0
  13. package/docs/displaying-ads.mdx +49 -29
  14. package/docs/european-user-consent.mdx +34 -5
  15. package/docs/index.mdx +4 -4
  16. package/docs/migrating-to-v5.mdx +17 -8
  17. package/docs/migrating-to-v6.mdx +111 -0
  18. package/docs.json +5 -2
  19. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.m +1 -0
  20. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerViewManager.m +63 -8
  21. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.h +3 -0
  22. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m +8 -7
  23. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m +14 -0
  24. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.h +2 -1
  25. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.m +17 -2
  26. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.m +44 -30
  27. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.m +19 -0
  28. package/lib/commonjs/AdEventType.js.map +1 -1
  29. package/lib/commonjs/AdsConsent.js +47 -16
  30. package/lib/commonjs/AdsConsent.js.map +1 -1
  31. package/lib/commonjs/AdsConsentPurposes.js +47 -0
  32. package/lib/commonjs/AdsConsentPurposes.js.map +1 -0
  33. package/lib/commonjs/AdsConsentSpecialFeatures.js +39 -0
  34. package/lib/commonjs/AdsConsentSpecialFeatures.js.map +1 -0
  35. package/lib/commonjs/GAMAdEventType.js +30 -0
  36. package/lib/commonjs/GAMAdEventType.js.map +1 -0
  37. package/lib/commonjs/MobileAds.js +4 -0
  38. package/lib/commonjs/MobileAds.js.map +1 -1
  39. package/lib/commonjs/RewardedAdEventType.js.map +1 -1
  40. package/lib/commonjs/TestIds.js +5 -0
  41. package/lib/commonjs/TestIds.js.map +1 -1
  42. package/lib/commonjs/ads/AppOpenAd.js +8 -53
  43. package/lib/commonjs/ads/AppOpenAd.js.map +1 -1
  44. package/lib/commonjs/ads/BannerAd.js +7 -110
  45. package/lib/commonjs/ads/BannerAd.js.map +1 -1
  46. package/lib/commonjs/ads/BaseAd.js +144 -0
  47. package/lib/commonjs/ads/BaseAd.js.map +1 -0
  48. package/lib/commonjs/ads/GAMBannerAd.js +42 -0
  49. package/lib/commonjs/ads/GAMBannerAd.js.map +1 -0
  50. package/lib/commonjs/ads/GAMInterstitialAd.js +48 -0
  51. package/lib/commonjs/ads/GAMInterstitialAd.js.map +1 -0
  52. package/lib/commonjs/ads/InterstitialAd.js +13 -64
  53. package/lib/commonjs/ads/InterstitialAd.js.map +1 -1
  54. package/lib/commonjs/ads/MobileAd.js +119 -12
  55. package/lib/commonjs/ads/MobileAd.js.map +1 -1
  56. package/lib/commonjs/ads/RewardedAd.js +23 -65
  57. package/lib/commonjs/ads/RewardedAd.js.map +1 -1
  58. package/lib/commonjs/hooks/useAppOpenAd.js +51 -0
  59. package/lib/commonjs/hooks/useAppOpenAd.js.map +1 -0
  60. package/lib/commonjs/hooks/useFullScreenAd.js +125 -0
  61. package/lib/commonjs/hooks/useFullScreenAd.js.map +1 -0
  62. package/lib/commonjs/hooks/useInterstitialAd.js +51 -0
  63. package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -0
  64. package/lib/commonjs/hooks/useRewardedAd.js +51 -0
  65. package/lib/commonjs/hooks/useRewardedAd.js.map +1 -0
  66. package/lib/commonjs/index.js +102 -0
  67. package/lib/commonjs/index.js.map +1 -1
  68. package/lib/commonjs/types/AdEventsListener.js +6 -0
  69. package/lib/commonjs/types/AdEventsListener.js.map +1 -0
  70. package/lib/commonjs/types/AdStates.js +6 -0
  71. package/lib/commonjs/types/AdStates.js.map +1 -0
  72. package/lib/commonjs/types/AppEvent.js +2 -0
  73. package/lib/commonjs/types/AppEvent.js.map +1 -0
  74. package/lib/commonjs/types/index.js +149 -0
  75. package/lib/commonjs/types/index.js.map +1 -0
  76. package/lib/commonjs/validateAdRequestOptions.js +0 -38
  77. package/lib/commonjs/validateAdRequestOptions.js.map +1 -1
  78. package/lib/commonjs/version.js +2 -2
  79. package/lib/commonjs/version.js.map +1 -1
  80. package/lib/module/AdEventType.js.map +1 -1
  81. package/lib/module/AdsConsent.js +44 -16
  82. package/lib/module/AdsConsent.js.map +1 -1
  83. package/lib/module/AdsConsentPurposes.js +39 -0
  84. package/lib/module/AdsConsentPurposes.js.map +1 -0
  85. package/lib/module/AdsConsentSpecialFeatures.js +31 -0
  86. package/lib/module/AdsConsentSpecialFeatures.js.map +1 -0
  87. package/lib/module/GAMAdEventType.js +22 -0
  88. package/lib/module/GAMAdEventType.js.map +1 -0
  89. package/lib/module/MobileAds.js +4 -0
  90. package/lib/module/MobileAds.js.map +1 -1
  91. package/lib/module/RewardedAdEventType.js.map +1 -1
  92. package/lib/module/TestIds.js +5 -0
  93. package/lib/module/TestIds.js.map +1 -1
  94. package/lib/module/ads/AppOpenAd.js +10 -37
  95. package/lib/module/ads/AppOpenAd.js.map +1 -1
  96. package/lib/module/ads/BannerAd.js +7 -85
  97. package/lib/module/ads/BannerAd.js.map +1 -1
  98. package/lib/module/ads/BaseAd.js +124 -0
  99. package/lib/module/ads/BaseAd.js.map +1 -0
  100. package/lib/module/ads/GAMBannerAd.js +42 -0
  101. package/lib/module/ads/GAMBannerAd.js.map +1 -0
  102. package/lib/module/ads/GAMInterstitialAd.js +38 -0
  103. package/lib/module/ads/GAMInterstitialAd.js.map +1 -0
  104. package/lib/module/ads/InterstitialAd.js +15 -48
  105. package/lib/module/ads/InterstitialAd.js.map +1 -1
  106. package/lib/module/ads/MobileAd.js +116 -12
  107. package/lib/module/ads/MobileAd.js.map +1 -1
  108. package/lib/module/ads/RewardedAd.js +24 -49
  109. package/lib/module/ads/RewardedAd.js.map +1 -1
  110. package/lib/module/hooks/useAppOpenAd.js +38 -0
  111. package/lib/module/hooks/useAppOpenAd.js.map +1 -0
  112. package/lib/module/hooks/useFullScreenAd.js +114 -0
  113. package/lib/module/hooks/useFullScreenAd.js.map +1 -0
  114. package/lib/module/hooks/useInterstitialAd.js +38 -0
  115. package/lib/module/hooks/useInterstitialAd.js.map +1 -0
  116. package/lib/module/hooks/useRewardedAd.js +38 -0
  117. package/lib/module/hooks/useRewardedAd.js.map +1 -0
  118. package/lib/module/index.js +9 -0
  119. package/lib/module/index.js.map +1 -1
  120. package/lib/module/types/AdEventsListener.js +2 -0
  121. package/lib/module/types/AdEventsListener.js.map +1 -0
  122. package/lib/module/types/AdStates.js +2 -0
  123. package/lib/module/types/AdStates.js.map +1 -0
  124. package/lib/module/types/AppEvent.js +2 -0
  125. package/lib/module/types/AppEvent.js.map +1 -0
  126. package/lib/module/types/index.js +28 -0
  127. package/lib/module/types/index.js.map +1 -0
  128. package/lib/module/validateAdRequestOptions.js +1 -39
  129. package/lib/module/validateAdRequestOptions.js.map +1 -1
  130. package/lib/module/version.js +2 -2
  131. package/lib/module/version.js.map +1 -1
  132. package/lib/typescript/AdEventType.d.ts +4 -8
  133. package/lib/typescript/AdsConsentPurposes.d.ts +148 -0
  134. package/lib/typescript/AdsConsentSpecialFeatures.d.ts +22 -0
  135. package/lib/typescript/GAMAdEventType.d.ts +20 -0
  136. package/lib/typescript/MobileAds.d.ts +2 -1
  137. package/lib/typescript/RewardedAdEventType.d.ts +7 -11
  138. package/lib/typescript/TestIds.d.ts +5 -0
  139. package/lib/typescript/ads/AppOpenAd.d.ts +6 -6
  140. package/lib/typescript/ads/BannerAd.d.ts +1 -1
  141. package/lib/typescript/ads/BaseAd.d.ts +35 -0
  142. package/lib/typescript/ads/GAMBannerAd.d.ts +7 -0
  143. package/lib/typescript/ads/GAMInterstitialAd.d.ts +33 -0
  144. package/lib/typescript/ads/InterstitialAd.d.ts +10 -16
  145. package/lib/typescript/ads/MobileAd.d.ts +34 -16
  146. package/lib/typescript/ads/RewardedAd.d.ts +17 -19
  147. package/lib/typescript/hooks/useAppOpenAd.d.ts +9 -0
  148. package/lib/typescript/hooks/useFullScreenAd.d.ts +5 -0
  149. package/lib/typescript/hooks/useInterstitialAd.d.ts +9 -0
  150. package/lib/typescript/hooks/useRewardedAd.d.ts +9 -0
  151. package/lib/typescript/index.d.ts +10 -1
  152. package/lib/typescript/types/AdEventListener.d.ts +5 -9
  153. package/lib/typescript/types/AdEventsListener.d.ts +8 -0
  154. package/lib/typescript/types/AdStates.d.ts +85 -0
  155. package/lib/typescript/types/AdsConsent.interface.d.ts +216 -0
  156. package/lib/typescript/types/AppEvent.d.ts +13 -0
  157. package/lib/typescript/types/BannerAdProps.d.ts +81 -4
  158. package/lib/typescript/types/GoogleMobileAdsNativeModule.d.ts +3 -2
  159. package/lib/typescript/types/MobileAd.interface.d.ts +37 -12
  160. package/lib/typescript/types/MobileAdsModule.interface.d.ts +9 -0
  161. package/lib/typescript/types/RequestOptions.d.ts +0 -22
  162. package/lib/typescript/types/index.d.ts +11 -0
  163. package/lib/typescript/version.d.ts +1 -1
  164. package/package.json +55 -50
  165. package/src/AdEventType.ts +4 -8
  166. package/src/AdsConsent.ts +75 -20
  167. package/src/AdsConsentPurposes.ts +182 -0
  168. package/src/AdsConsentSpecialFeatures.ts +48 -0
  169. package/src/GAMAdEventType.ts +37 -0
  170. package/src/MobileAds.ts +4 -0
  171. package/src/RewardedAdEventType.ts +7 -11
  172. package/src/TestIds.ts +5 -0
  173. package/src/ads/AppOpenAd.ts +11 -41
  174. package/src/ads/BannerAd.tsx +4 -106
  175. package/src/ads/BaseAd.tsx +156 -0
  176. package/src/ads/GAMBannerAd.tsx +37 -0
  177. package/src/ads/GAMInterstitialAd.ts +45 -0
  178. package/src/ads/InterstitialAd.ts +15 -56
  179. package/src/ads/MobileAd.ts +142 -29
  180. package/src/ads/RewardedAd.ts +29 -55
  181. package/src/hooks/useAppOpenAd.ts +46 -0
  182. package/src/hooks/useFullScreenAd.ts +105 -0
  183. package/src/hooks/useInterstitialAd.ts +46 -0
  184. package/src/hooks/useRewardedAd.ts +46 -0
  185. package/src/index.ts +9 -0
  186. package/src/types/AdEventListener.ts +31 -13
  187. package/src/types/AdEventsListener.ts +24 -0
  188. package/src/types/AdStates.ts +87 -0
  189. package/src/types/AdsConsent.interface.ts +220 -0
  190. package/src/types/AppEvent.ts +14 -0
  191. package/src/types/BannerAdProps.ts +81 -4
  192. package/src/types/GoogleMobileAdsNativeModule.ts +3 -2
  193. package/src/types/MobileAd.interface.ts +56 -12
  194. package/src/types/MobileAdsModule.interface.ts +10 -0
  195. package/src/types/RequestOptions.ts +0 -24
  196. package/src/types/index.ts +28 -0
  197. package/src/validateAdRequestOptions.ts +0 -45
  198. package/src/version.ts +2 -2
@@ -1,3 +1,5 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
1
3
  /*
2
4
  * Copyright (c) 2016-present Invertase Limited & Contributors
3
5
  *
@@ -14,95 +16,15 @@
14
16
  * limitations under the License.
15
17
  *
16
18
  */
17
- import React, { useState, useEffect } from 'react';
18
- import { requireNativeComponent } from 'react-native';
19
- import { isFunction } from '../common';
20
- import { NativeError } from '../internal/NativeError';
21
- import { BannerAdSize } from '../BannerAdSize';
22
- import { validateAdRequestOptions } from '../validateAdRequestOptions';
23
- const initialState = [0, 0];
24
- const sizeRegex = /([0-9]+)x([0-9]+)/;
19
+ import React from 'react';
20
+ import { BaseAd } from './BaseAd';
25
21
  export function BannerAd(_ref) {
26
22
  let {
27
- unitId,
28
23
  size,
29
- requestOptions,
30
24
  ...props
31
25
  } = _ref;
32
- const [dimensions, setDimensions] = useState(initialState);
33
- useEffect(() => {
34
- if (!unitId) {
35
- throw new Error("BannerAd: 'unitId' expected a valid string unit ID.");
36
- }
37
- }, [unitId]);
38
- useEffect(() => {
39
- if (!(size in BannerAdSize) && !sizeRegex.test(size)) {
40
- throw new Error("BannerAd: 'size' expected a valid BannerAdSize or custom size string.");
41
- }
42
- }, [size]);
43
- useEffect(() => {
44
- if (!(size in BannerAdSize) && !sizeRegex.test(size)) {
45
- throw new Error("BannerAd: 'size' expected a valid BannerAdSize or custom size string.");
46
- }
47
- }, [size]);
48
- const parsedRequestOptions = JSON.stringify(requestOptions);
49
- useEffect(() => {
50
- if (requestOptions) {
51
- try {
52
- validateAdRequestOptions(requestOptions);
53
- } catch (e) {
54
- if (e instanceof Error) {
55
- throw new Error(`BannerAd: ${e.message}`);
56
- }
57
- }
58
- }
59
- }, [parsedRequestOptions]);
60
-
61
- function onNativeEvent(_ref2) {
62
- let {
63
- nativeEvent
64
- } = _ref2;
65
- const {
66
- type
67
- } = nativeEvent;
68
-
69
- if (type !== 'onSizeChange' && isFunction(props[type])) {
70
- let eventHandler;
71
-
72
- if (type === 'onAdFailedToLoad') {
73
- const eventPayload = NativeError.fromEvent(nativeEvent, 'googleMobileAds');
74
- if (eventHandler = props[type]) eventHandler(eventPayload);
75
- } else if (eventHandler = props[type]) eventHandler();
76
- }
77
-
78
- if ((type === 'onAdLoaded' || type === 'onSizeChange') && size !== 'FLUID') {
79
- const {
80
- width,
81
- height
82
- } = nativeEvent;
83
- if (width && height) setDimensions([width, height]);
84
- }
85
- }
86
-
87
- let style;
88
-
89
- if (size === 'FLUID') {
90
- // @ts-ignore: Property 'style' does not exist on type error
91
- style = props.style;
92
- } else {
93
- style = {
94
- width: dimensions[0],
95
- height: dimensions[1]
96
- };
97
- }
98
-
99
- return /*#__PURE__*/React.createElement(GoogleMobileAdsBannerView, {
100
- size: size,
101
- style: style,
102
- unitId: unitId,
103
- request: validateAdRequestOptions(requestOptions),
104
- onNativeEvent: onNativeEvent
105
- });
26
+ return /*#__PURE__*/React.createElement(BaseAd, _extends({
27
+ sizes: [size]
28
+ }, props));
106
29
  }
107
- const GoogleMobileAdsBannerView = requireNativeComponent('RNGoogleMobileAdsBannerView');
108
30
  //# sourceMappingURL=BannerAd.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["BannerAd.tsx"],"names":["React","useState","useEffect","requireNativeComponent","isFunction","NativeError","BannerAdSize","validateAdRequestOptions","initialState","sizeRegex","BannerAd","unitId","size","requestOptions","props","dimensions","setDimensions","Error","test","parsedRequestOptions","JSON","stringify","e","message","onNativeEvent","nativeEvent","type","eventHandler","eventPayload","fromEvent","width","height","style","GoogleMobileAdsBannerView"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,SAAwBC,sBAAxB,QAAsD,cAAtD;AACA,SAASC,UAAT,QAA2B,WAA3B;AACA,SAASC,WAAT,QAA4B,yBAA5B;AACA,SAASC,YAAT,QAA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AAEoB,KAFT;AAGE,IAAA,MAAM,EAAErB,MAHV;AAIE,IAAA,OAAO,EAAEJ,wBAAwB,CAACM,cAAD,CAJnC;AAKE,IAAA,aAAa,EAAEW;AALjB,IADF;AASD;AAED,MAAMS,yBASJ,GAAG9B,sBAAsB,CAAC,6BAAD,CAT3B","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport React, { useState, useEffect } from 'react';\nimport { HostComponent, requireNativeComponent } from 'react-native';\nimport { isFunction } from '../common';\nimport { NativeError } from '../internal/NativeError';\nimport { BannerAdSize } from '../BannerAdSize';\nimport { validateAdRequestOptions } from '../validateAdRequestOptions';\nimport { BannerAdProps } from '../types/BannerAdProps';\nimport { RequestOptions } from '../types/RequestOptions';\n\ntype NativeEvent =\n | {\n type: 'onAdLoaded' | 'onSizeChange';\n width: number;\n height: number;\n }\n | { type: 'onAdOpened' | 'onAdClosed' }\n | {\n type: 'onAdFailedToLoad';\n code: string;\n message: string;\n };\n\nconst initialState = [0, 0];\nconst sizeRegex = /([0-9]+)x([0-9]+)/;\n\nexport function BannerAd({ unitId, size, requestOptions, ...props }: BannerAdProps) {\n const [dimensions, setDimensions] = useState(initialState);\n\n useEffect(() => {\n if (!unitId) {\n throw new Error(\"BannerAd: 'unitId' expected a valid string unit ID.\");\n }\n }, [unitId]);\n\n useEffect(() => {\n if (!(size in BannerAdSize) && !sizeRegex.test(size)) {\n throw new Error(\"BannerAd: 'size' expected a valid BannerAdSize or custom size string.\");\n }\n }, [size]);\n\n useEffect(() => {\n if (!(size in BannerAdSize) && !sizeRegex.test(size)) {\n throw new Error(\"BannerAd: 'size' expected a valid BannerAdSize or custom size string.\");\n }\n }, [size]);\n\n const parsedRequestOptions = JSON.stringify(requestOptions);\n\n useEffect(() => {\n if (requestOptions) {\n try {\n validateAdRequestOptions(requestOptions);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`BannerAd: ${e.message}`);\n }\n }\n }\n }, [parsedRequestOptions]);\n\n function onNativeEvent({ nativeEvent }: { nativeEvent: NativeEvent }) {\n const { type } = nativeEvent;\n\n if (type !== 'onSizeChange' && isFunction(props[type])) {\n let eventHandler;\n if (type === 'onAdFailedToLoad') {\n const eventPayload = NativeError.fromEvent(nativeEvent, 'googleMobileAds');\n if ((eventHandler = props[type])) eventHandler(eventPayload);\n } else if ((eventHandler = props[type])) eventHandler();\n }\n\n if ((type === 'onAdLoaded' || type === 'onSizeChange') && size !== 'FLUID') {\n const { width, height } = nativeEvent;\n if (width && height) setDimensions([width, height]);\n }\n }\n\n let style;\n if (size === 'FLUID') {\n // @ts-ignore: Property 'style' does not exist on type error\n style = props.style;\n } else {\n style = {\n width: dimensions[0],\n height: dimensions[1],\n };\n }\n\n return (\n <GoogleMobileAdsBannerView\n size={size}\n style={style}\n unitId={unitId}\n request={validateAdRequestOptions(requestOptions)}\n onNativeEvent={onNativeEvent}\n />\n );\n}\n\nconst GoogleMobileAdsBannerView: HostComponent<{\n size: BannerAdProps['size'];\n style: {\n width: number;\n height: number;\n };\n unitId: string;\n request: RequestOptions;\n onNativeEvent: (event: { nativeEvent: NativeEvent }) => void;\n}> = requireNativeComponent('RNGoogleMobileAdsBannerView');\n"]}
1
+ {"version":3,"sources":["BannerAd.tsx"],"names":["React","BaseAd","BannerAd","size","props"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,MAAT,QAAuB,UAAvB;AAEA,OAAO,SAASC,QAAT,OAAqD;AAAA,MAAnC;AAAEC,IAAAA,IAAF;AAAQ,OAAGC;AAAX,GAAmC;AAC1D,sBAAO,oBAAC,MAAD;AAAQ,IAAA,KAAK,EAAE,CAACD,IAAD;AAAf,KAA2BC,KAA3B,EAAP;AACD","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport React from 'react';\nimport { BannerAdProps } from '../types/BannerAdProps';\nimport { BaseAd } from './BaseAd';\n\nexport function BannerAd({ size, ...props }: BannerAdProps) {\n return <BaseAd sizes={[size]} {...props} />;\n}\n"]}
@@ -0,0 +1,124 @@
1
+ /* eslint-disable react/prop-types */
2
+
3
+ /*
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+ import React, { useState, useEffect } from 'react';
20
+ import { requireNativeComponent } from 'react-native';
21
+ import { isFunction } from '../common';
22
+ import { NativeError } from '../internal/NativeError';
23
+ import { BannerAdSize } from '../BannerAdSize';
24
+ import { validateAdRequestOptions } from '../validateAdRequestOptions';
25
+ const sizeRegex = /([0-9]+)x([0-9]+)/;
26
+ export const BaseAd = /*#__PURE__*/React.forwardRef((_ref, ref) => {
27
+ let {
28
+ unitId,
29
+ sizes,
30
+ requestOptions,
31
+ manualImpressionsEnabled,
32
+ ...props
33
+ } = _ref;
34
+ const [dimensions, setDimensions] = useState([0, 0]);
35
+ useEffect(() => {
36
+ if (!unitId) {
37
+ throw new Error("BannerAd: 'unitId' expected a valid string unit ID.");
38
+ }
39
+ }, [unitId]);
40
+ useEffect(() => {
41
+ if (sizes.length === 0 || !sizes.every(size => size in BannerAdSize || sizeRegex.test(size))) {
42
+ throw new Error("BannerAd: 'size(s)' expected a valid BannerAdSize or custom size string.");
43
+ }
44
+ }, [sizes]);
45
+ const parsedRequestOptions = JSON.stringify(requestOptions);
46
+ useEffect(() => {
47
+ if (requestOptions) {
48
+ try {
49
+ validateAdRequestOptions(requestOptions);
50
+ } catch (e) {
51
+ if (e instanceof Error) {
52
+ throw new Error(`BannerAd: ${e.message}`);
53
+ }
54
+ }
55
+ }
56
+ }, [parsedRequestOptions]);
57
+
58
+ function onNativeEvent(_ref2) {
59
+ let {
60
+ nativeEvent
61
+ } = _ref2;
62
+ const {
63
+ type
64
+ } = nativeEvent;
65
+
66
+ if (type !== 'onSizeChange' && isFunction(props[type])) {
67
+ let eventHandler, eventPayload;
68
+
69
+ switch (type) {
70
+ case 'onAdLoaded':
71
+ eventPayload = {
72
+ width: nativeEvent.width,
73
+ height: nativeEvent.height
74
+ };
75
+ if (eventHandler = props[type]) eventHandler(eventPayload);
76
+ break;
77
+
78
+ case 'onAdFailedToLoad':
79
+ eventPayload = NativeError.fromEvent(nativeEvent, 'googleMobileAds');
80
+ if (eventHandler = props[type]) eventHandler(eventPayload);
81
+ break;
82
+
83
+ case 'onAppEvent':
84
+ eventPayload = {
85
+ name: nativeEvent.name,
86
+ data: nativeEvent.data
87
+ };
88
+ if (eventHandler = props[type]) eventHandler(eventPayload);
89
+ break;
90
+
91
+ default:
92
+ if (eventHandler = props[type]) eventHandler();
93
+ }
94
+ }
95
+
96
+ if (type === 'onAdLoaded' || type === 'onSizeChange') {
97
+ const {
98
+ width,
99
+ height
100
+ } = nativeEvent;
101
+ if (width && height) setDimensions([width, height]);
102
+ }
103
+ }
104
+
105
+ const style = sizes.includes(BannerAdSize.FLUID) ? {
106
+ width: '100%',
107
+ height: dimensions[1]
108
+ } : {
109
+ width: dimensions[0],
110
+ height: dimensions[1]
111
+ };
112
+ return /*#__PURE__*/React.createElement(GoogleMobileAdsBannerView, {
113
+ ref: ref,
114
+ sizes: sizes,
115
+ style: style,
116
+ unitId: unitId,
117
+ request: validateAdRequestOptions(requestOptions),
118
+ manualImpressionsEnabled: !!manualImpressionsEnabled,
119
+ onNativeEvent: onNativeEvent
120
+ });
121
+ });
122
+ BaseAd.displayName = 'BaseAd';
123
+ const GoogleMobileAdsBannerView = requireNativeComponent('RNGoogleMobileAdsBannerView');
124
+ //# sourceMappingURL=BaseAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["BaseAd.tsx"],"names":["React","useState","useEffect","requireNativeComponent","isFunction","NativeError","BannerAdSize","validateAdRequestOptions","sizeRegex","BaseAd","forwardRef","ref","unitId","sizes","requestOptions","manualImpressionsEnabled","props","dimensions","setDimensions","Error","length","every","size","test","parsedRequestOptions","JSON","stringify","e","message","onNativeEvent","nativeEvent","type","eventHandler","eventPayload","width","height","fromEvent","name","data","style","includes","FLUID","displayName","GoogleMobileAdsBannerView"],"mappings":"AAAA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,SAAwBC,sBAAxB,QAAsD,cAAtD;AACA,SAASC,UAAT,QAA2B,WAA3B;AACA,SAASC,WAAT,QAA4B,yBAA5B;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASC,wBAAT,QAAyC,6BAAzC;AAsBA,MAAMC,SAAS,GAAG,m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ACmC,KAA5B,IACV;AACEP,IAAAA,KAAK,EAAE,MADT;AAEEC,IAAAA,MAAM,EAAElB,UAAU,CAAC,CAAD;AAFpB,GADU,GAKV;AACEiB,IAAAA,KAAK,EAAEjB,UAAU,CAAC,CAAD,CADnB;AAEEkB,IAAAA,MAAM,EAAElB,UAAU,CAAC,CAAD;AAFpB,GALJ;AAUA,sBACE,oBAAC,yBAAD;AACE,IAAA,GAAG,EAAEN,GADP;AAEE,IAAA,KAAK,EAAEE,KAFT;AAGE,IAAA,KAAK,EAAE0B,KAHT;AAIE,IAAA,MAAM,EAAE3B,MAJV;AAKE,IAAA,OAAO,EAAEL,wBAAwB,CAACO,cAAD,CALnC;AAME,IAAA,wBAAwB,EAAE,CAAC,CAACC,wBAN9B;AAOE,IAAA,aAAa,EAAEc;AAPjB,IADF;AAWD,CAzFmB,CAAf;AA2FPpB,MAAM,CAACiC,WAAP,GAAqB,QAArB;AAcA,MAAMC,yBAAyB,GAAGxC,sBAAsB,CACtD,6BADsD,CAAxD","sourcesContent":["/* eslint-disable react/prop-types */\n/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport React, { useState, useEffect } from 'react';\nimport { NativeMethods, requireNativeComponent } from 'react-native';\nimport { isFunction } from '../common';\nimport { NativeError } from '../internal/NativeError';\nimport { BannerAdSize } from '../BannerAdSize';\nimport { validateAdRequestOptions } from '../validateAdRequestOptions';\nimport { GAMBannerAdProps } from '../types/BannerAdProps';\nimport { RequestOptions } from '../types/RequestOptions';\n\ntype NativeEvent =\n | {\n type: 'onAdLoaded' | 'onSizeChange';\n width: number;\n height: number;\n }\n | { type: 'onAdOpened' | 'onAdClosed' }\n | {\n type: 'onAdFailedToLoad';\n code: string;\n message: string;\n }\n | {\n type: 'onAppEvent';\n name: string;\n data?: string;\n };\n\nconst sizeRegex = /([0-9]+)x([0-9]+)/;\n\nexport const BaseAd = React.forwardRef<GoogleMobileAdsBannerView, GAMBannerAdProps>(\n ({ unitId, sizes, requestOptions, manualImpressionsEnabled, ...props }, ref) => {\n const [dimensions, setDimensions] = useState<(number | string)[]>([0, 0]);\n\n useEffect(() => {\n if (!unitId) {\n throw new Error(\"BannerAd: 'unitId' expected a valid string unit ID.\");\n }\n }, [unitId]);\n\n useEffect(() => {\n if (\n sizes.length === 0 ||\n !sizes.every(size => size in BannerAdSize || sizeRegex.test(size))\n ) {\n throw new Error(\"BannerAd: 'size(s)' expected a valid BannerAdSize or custom size string.\");\n }\n }, [sizes]);\n\n const parsedRequestOptions = JSON.stringify(requestOptions);\n\n useEffect(() => {\n if (requestOptions) {\n try {\n validateAdRequestOptions(requestOptions);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`BannerAd: ${e.message}`);\n }\n }\n }\n }, [parsedRequestOptions]);\n\n function onNativeEvent({ nativeEvent }: { nativeEvent: NativeEvent }) {\n const { type } = nativeEvent;\n\n if (type !== 'onSizeChange' && isFunction(props[type])) {\n let eventHandler, eventPayload;\n switch (type) {\n case 'onAdLoaded':\n eventPayload = {\n width: nativeEvent.width,\n height: nativeEvent.height,\n };\n if ((eventHandler = props[type])) eventHandler(eventPayload);\n break;\n case 'onAdFailedToLoad':\n eventPayload = NativeError.fromEvent(nativeEvent, 'googleMobileAds');\n if ((eventHandler = props[type])) eventHandler(eventPayload);\n break;\n case 'onAppEvent':\n eventPayload = {\n name: nativeEvent.name,\n data: nativeEvent.data,\n };\n if ((eventHandler = props[type])) eventHandler(eventPayload);\n break;\n default:\n if ((eventHandler = props[type])) eventHandler();\n }\n }\n\n if (type === 'onAdLoaded' || type === 'onSizeChange') {\n const { width, height } = nativeEvent;\n if (width && height) setDimensions([width, height]);\n }\n }\n\n const style = sizes.includes(BannerAdSize.FLUID)\n ? {\n width: '100%',\n height: dimensions[1],\n }\n : {\n width: dimensions[0],\n height: dimensions[1],\n };\n\n return (\n <GoogleMobileAdsBannerView\n ref={ref}\n sizes={sizes}\n style={style}\n unitId={unitId}\n request={validateAdRequestOptions(requestOptions)}\n manualImpressionsEnabled={!!manualImpressionsEnabled}\n onNativeEvent={onNativeEvent}\n />\n );\n },\n);\nBaseAd.displayName = 'BaseAd';\n\ninterface NativeBannerProps {\n sizes: GAMBannerAdProps['sizes'];\n style: {\n width?: number | string;\n height?: number | string;\n };\n unitId: string;\n request: RequestOptions;\n manualImpressionsEnabled: boolean;\n onNativeEvent: (event: { nativeEvent: NativeEvent }) => void;\n}\n\nconst GoogleMobileAdsBannerView = requireNativeComponent<NativeBannerProps>(\n 'RNGoogleMobileAdsBannerView',\n);\nexport type GoogleMobileAdsBannerView = React.Component<NativeBannerProps> & NativeMethods;\n"]}
@@ -0,0 +1,42 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+
5
+ /*
6
+ * Copyright (c) 2016-present Invertase Limited & Contributors
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this library except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ *
20
+ */
21
+ import React, { createRef } from 'react';
22
+ import { findNodeHandle, UIManager } from 'react-native';
23
+ import { BaseAd } from './BaseAd';
24
+ export class GAMBannerAd extends React.Component {
25
+ constructor() {
26
+ super(...arguments);
27
+
28
+ _defineProperty(this, "ref", /*#__PURE__*/createRef());
29
+ }
30
+
31
+ recordManualImpression() {
32
+ UIManager.dispatchViewManagerCommand(findNodeHandle(this.ref.current), 'recordManualImpression', undefined);
33
+ }
34
+
35
+ render() {
36
+ return /*#__PURE__*/React.createElement(BaseAd, _extends({
37
+ ref: this.ref
38
+ }, this.props));
39
+ }
40
+
41
+ }
42
+ //# sourceMappingURL=GAMBannerAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["GAMBannerAd.tsx"],"names":["React","createRef","findNodeHandle","UIManager","BaseAd","GAMBannerAd","Component","recordManualImpression","dispatchViewManagerCommand","ref","current","undefined","render","props"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,cAAT,EAAyBC,SAAzB,QAA0C,cAA1C;AAEA,SAASC,MAAT,QAAkD,UAAlD;AAEA,OAAO,MAAMC,WAAN,SAA0BL,KAAK,CAACM,SAAhC,CAA4D;AAAA;AAAA;;AAAA,8CACnDL,SAAS,EAD0C;AAAA;;AAGjEM,EAAAA,sBAAsB,GAAG;AACvBJ,IAAAA,SAAS,CAACK,0BAAV,CACEN,cAAc,CAAC,KAAKO,GAAL,CAASC,OAAV,CADhB,EAEE,wBAFF,EAGEC,SAHF;AAKD;;AAEDC,EAAAA,MAAM,GAAG;AACP,wBAAO,oBAAC,MAAD;AAAQ,MAAA,GAAG,EAAE,KAAKH;AAAlB,OAA2B,KAAKI,KAAhC,EAAP;AACD;;AAbgE","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport React, { createRef } from 'react';\nimport { findNodeHandle, UIManager } from 'react-native';\nimport { GAMBannerAdProps } from '../types/BannerAdProps';\nimport { BaseAd, GoogleMobileAdsBannerView } from './BaseAd';\n\nexport class GAMBannerAd extends React.Component<GAMBannerAdProps> {\n private ref = createRef<GoogleMobileAdsBannerView>();\n\n recordManualImpression() {\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(this.ref.current),\n 'recordManualImpression',\n undefined,\n );\n }\n\n render() {\n return <BaseAd ref={this.ref} {...this.props} />;\n }\n}\n"]}
@@ -0,0 +1,38 @@
1
+ import { InterstitialAd } from './InterstitialAd';
2
+ export class GAMInterstitialAd extends InterstitialAd {
3
+ /**
4
+ * Creates a new GAMInterstitialAd instance.
5
+ *
6
+ * #### Example
7
+ *
8
+ * ```js
9
+ * import { GAMInterstitialAd, AdEventType, TestIds } from 'react-native-google-mobile-ads';
10
+ *
11
+ * const interstitialAd = await GAMInterstitialAd.createForAdRequest(TestIds.GAM_INTERSTITIAL, {
12
+ * requestAgent: 'CoolAds',
13
+ * });
14
+ *
15
+ * interstitialAd.addAdEventListener(AdEventType.Loaded, () => {
16
+ * interstitialAd.show();
17
+ * });
18
+ *
19
+ * interstitialAd.load();
20
+ * ```
21
+ *
22
+ * @param adUnitId The Ad Unit ID for the Interstitial. You can find this on your Google Mobile Ads dashboard.
23
+ * @param requestOptions Optional RequestOptions used to load the ad.
24
+ */
25
+ static createForAdRequest(adUnitId, requestOptions) {
26
+ return super.createForAdRequest(adUnitId, requestOptions);
27
+ }
28
+
29
+ addAdEventsListener(listener) {
30
+ return this._addAdEventsListener(listener);
31
+ }
32
+
33
+ addAdEventListener(type, listener) {
34
+ return this._addAdEventListener(type, listener);
35
+ }
36
+
37
+ }
38
+ //# sourceMappingURL=GAMInterstitialAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["GAMInterstitialAd.ts"],"names":["InterstitialAd","GAMInterstitialAd","createForAdRequest","adUnitId","requestOptions","addAdEventsListener","listener","_addAdEventsListener","addAdEventListener","type","_addAdEventListener"],"mappings":"AAKA,SAASA,cAAT,QAA+B,kBAA/B;AAEA,OAAO,MAAMC,iBAAN,SAAgCD,cAAhC,CAA+C;AACpD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC2B,SAAlBE,kBAAkB,CAACC,QAAD,EAAmBC,cAAnB,EAAoD;AAC3E,WAAO,MAAMF,kBAAN,CAAyBC,QAAzB,EAAmCC,cAAnC,CAAP;AACD;;AAEDC,EAAAA,mBAAmB,CAAyCC,QAAzC,EAAwE;AACzF,WAAO,KAAKC,oBAAL,CAA0BD,QAA1B,CAAP;AACD;;AAEDE,EAAAA,kBAAkB,CAChBC,IADgB,EAEhBH,QAFgB,EAGhB;AACA,WAAO,KAAKI,mBAAL,CAAyBD,IAAzB,EAA+BH,QAA/B,CAAP;AACD;;AApCmD","sourcesContent":["import { AdEventType } from '../AdEventType';\nimport { GAMAdEventType } from '../GAMAdEventType';\nimport { AdEventListener } from '../types/AdEventListener';\nimport { AdEventsListener } from '../types/AdEventsListener';\nimport { RequestOptions } from '../types/RequestOptions';\nimport { InterstitialAd } from './InterstitialAd';\n\nexport class GAMInterstitialAd extends InterstitialAd {\n /**\n * Creates a new GAMInterstitialAd instance.\n *\n * #### Example\n *\n * ```js\n * import { GAMInterstitialAd, AdEventType, TestIds } from 'react-native-google-mobile-ads';\n *\n * const interstitialAd = await GAMInterstitialAd.createForAdRequest(TestIds.GAM_INTERSTITIAL, {\n * requestAgent: 'CoolAds',\n * });\n *\n * interstitialAd.addAdEventListener(AdEventType.Loaded, () => {\n * interstitialAd.show();\n * });\n *\n * interstitialAd.load();\n * ```\n *\n * @param adUnitId The Ad Unit ID for the Interstitial. You can find this on your Google Mobile Ads dashboard.\n * @param requestOptions Optional RequestOptions used to load the ad.\n */\n static createForAdRequest(adUnitId: string, requestOptions?: RequestOptions) {\n return super.createForAdRequest(adUnitId, requestOptions) as GAMInterstitialAd;\n }\n\n addAdEventsListener<T extends AdEventType | GAMAdEventType>(listener: AdEventsListener<T>) {\n return this._addAdEventsListener(listener);\n }\n\n addAdEventListener<T extends AdEventType | GAMAdEventType>(\n type: T,\n listener: AdEventListener<T>,\n ) {\n return this._addAdEventListener(type, listener);\n }\n}\n"]}
@@ -1,3 +1,5 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
1
3
  /*
2
4
  * Copyright (c) 2016-present Invertase Limited & Contributors
3
5
  *
@@ -14,12 +16,11 @@
14
16
  * limitations under the License.
15
17
  *
16
18
  */
17
- import { isFunction, isString } from '../common';
19
+ import { isString } from '../common';
18
20
  import { MobileAds } from '../MobileAds';
19
21
  import { validateAdRequestOptions } from '../validateAdRequestOptions';
20
- import { validateAdShowOptions } from '../validateAdShowOptions';
21
22
  import { MobileAd } from './MobileAd';
22
- let _interstitialRequest = 0;
23
+
23
24
  /**
24
25
  * A class for interacting and showing Interstitial Ads.
25
26
  *
@@ -49,10 +50,8 @@ let _interstitialRequest = 0;
49
50
  * ```js
50
51
  * import { AdEventType } from 'react-native-google-mobile-ads';
51
52
  *
52
- * interstitial.onAdEvent((type) => {
53
- * if (type === AdEventType.LOADED) {
54
- * interstitial.show();
55
- * }
53
+ * interstitialAd.addAdEventListener(AdEventType.Loaded, () => {
54
+ * interstitialAd.show();
56
55
  * });
57
56
  *
58
57
  * interstitial.load();
@@ -61,7 +60,6 @@ let _interstitialRequest = 0;
61
60
  * The advert will be presented to the user, and several more events can be triggered such as the user clicking the
62
61
  * advert or closing it.
63
62
  */
64
-
65
63
  export class InterstitialAd extends MobileAd {
66
64
  /**
67
65
  * Creates a new InterstitialAd instance.
@@ -75,12 +73,8 @@ export class InterstitialAd extends MobileAd {
75
73
  * requestAgent: 'CoolAds',
76
74
  * });
77
75
  *
78
- * interstitialAd.onAdEvent((type, error) => {
79
- * console.log('New event: ', type, error);
80
- *
81
- * if (type === AdEventType.LOADED) {
82
- * interstitialAd.show();
83
- * }
76
+ * interstitialAd.addAdEventListener(AdEventType.Loaded, () => {
77
+ * interstitialAd.show();
84
78
  * });
85
79
  *
86
80
  * interstitialAd.load();
@@ -104,46 +98,19 @@ export class InterstitialAd extends MobileAd {
104
98
  }
105
99
  }
106
100
 
107
- const requestId = _interstitialRequest++;
101
+ const requestId = InterstitialAd._interstitialRequest++;
108
102
  return new InterstitialAd('interstitial', MobileAds(), requestId, adUnitId, options);
109
103
  }
110
104
 
111
- load() {
112
- // Prevent multiple load calls
113
- if (this._loaded || this._isLoadCalled) {
114
- return;
115
- }
116
-
117
- this._isLoadCalled = true;
118
-
119
- this._googleMobileAds.native.interstitialLoad(this._requestId, this._adUnitId, this._requestOptions);
105
+ addAdEventsListener(listener) {
106
+ return this._addAdEventsListener(listener);
120
107
  }
121
108
 
122
- onAdEvent(handler) {
123
- if (!isFunction(handler)) {
124
- throw new Error("InterstitialAd.onAdEvent(*) 'handler' expected a function.");
125
- }
126
-
127
- return this._setAdEventHandler(handler);
128
- }
129
-
130
- show(showOptions) {
131
- if (!this._loaded) {
132
- throw new Error('InterstitialAd.show() The requested InterstitialAd has not loaded and could not be shown.');
133
- }
134
-
135
- let options;
136
-
137
- try {
138
- options = validateAdShowOptions(showOptions);
139
- } catch (e) {
140
- if (e instanceof Error) {
141
- throw new Error(`InterstitialAd.show(*) ${e.message}.`);
142
- }
143
- }
144
-
145
- return this._googleMobileAds.native.interstitialShow(this._requestId, options);
109
+ addAdEventListener(type, listener) {
110
+ return this._addAdEventListener(type, listener);
146
111
  }
147
112
 
148
113
  }
114
+
115
+ _defineProperty(InterstitialAd, "_interstitialRequest", 0);
149
116
  //# sourceMappingURL=InterstitialAd.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["InterstitialAd.ts"],"names":["isFunction","isString","MobileAds","validateAdRequestOptions","validateAdShowOptions","MobileAd","_interstitialRequest","InterstitialAd","createForAdRequest","adUnitId","requestOptions","Error","options","e","message","requestId","load","_loaded","_isLoadCalled","_googleMobileAds","native","interstitialLoad","_requestId","_adUnitId","_requestOptions","onAdEvent","handler","_setAdEventHandler","show","showOptions","interstitialShow"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,UAAT,EAAqBC,QAArB,QAAqC,WAArC;AACA,SAASC,SAAT,QAA0B,cAA1B;AACA,SAASC,wBAAT,QAAyC,6BAAzC;AACA,SAASC,qBAAT,QAAsC,0BAAtC;AACA,SAASC,QAAT,QAAyB,YAAzB;AAMA,IAAIC,oBAAoB,GAAG,CAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,cAAN,SAA6BF,QAA7B,CAAmE;AACxE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC2B,SAAlBG,kBAAkB,CAACC,QAAD,EAAmBC,cAAnB,EAAoE;AAC3F,QAAI,CAACT,QAAQ,CAACQ,QAAD,CAAb,EAAyB;AACvB,YA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BAAyBE,CAAC,CAACC,OAAQ,GAA9C,CAAN;AACD;AACF;;AAED,WAAO,KAAKK,gBAAL,CAAsBC,MAAtB,CAA6BU,gBAA7B,CAA8C,KAAKR,UAAnD,EAA+DV,OAA/D,CAAP;AACD;;AApFuE","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport { isFunction, isString } from '../common';\nimport { MobileAds } from '../MobileAds';\nimport { validateAdRequestOptions } from '../validateAdRequestOptions';\nimport { validateAdShowOptions } from '../validateAdShowOptions';\nimport { MobileAd } from './MobileAd';\nimport { AdEventListener } from '../types/AdEventListener';\nimport { AdShowOptions } from '../types/AdShowOptions';\nimport { RequestOptions } from '../types/RequestOptions';\nimport { MobileAdInterface } from '../types/MobileAd.interface';\n\nlet _interstitialRequest = 0;\n\n/**\n * A class for interacting and showing Interstitial Ads.\n *\n * An Interstitial advert can be pre-loaded and shown at a suitable point in your apps flow, such as at the end of a level\n * in a game. An Interstitial is a full screen advert, laid on-top of your entire application which the user can interact with.\n * Interactions are passed back via events which should be handled accordingly inside of your app.\n *\n * #### Example\n *\n * First create a new Interstitial instance, passing in your Ad Unit ID from the Google Mobile Ads configuration console, and any additional\n * request options. The example below will present a test advert, and only request a non-personalized ad.\n *\n * ```js\n * import { InterstitialAd, TestIds } from 'react-native-google-mobile-ads';\n *\n * const interstitial = InterstitialAd.createForAdRequest(TestIds.INTERSTITIAL, {\n * requestNonPersonalizedAdsOnly: true,\n * });\n * ```\n *\n * Each advert needs to be loaded from Google Mobile Ads before being shown. It is recommended this is performed before the user\n * reaches the checkpoint to show the advert, so it's ready to go. Before loading the advert, we need to setup\n * event listeners to listen for updates from Google Mobile Ads, such as advert loaded or failed to load.\n *\n * Event types match the `AdEventType` interface. Once the advert has loaded, we can trigger it to show:\n *\n * ```js\n * import { AdEventType } from 'react-native-google-mobile-ads';\n *\n * interstitial.onAdEvent((type) => {\n * if (type === AdEventType.LOADED) {\n * interstitial.show();\n * }\n * });\n *\n * interstitial.load();\n * ```\n *\n * The advert will be presented to the user, and several more events can be triggered such as the user clicking the\n * advert or closing it.\n */\nexport class InterstitialAd extends MobileAd implements MobileAdInterface {\n /**\n * Creates a new InterstitialAd instance.\n *\n * #### Example\n *\n * ```js\n * import { InterstitialAd, AdEventType, TestIds } from 'react-native-google-mobile-ads';\n *\n * const interstitialAd = await InterstitialAd.createForAdRequest(TestIds.INTERSTITIAL, {\n * requestAgent: 'CoolAds',\n * });\n *\n * interstitialAd.onAdEvent((type, error) => {\n * console.log('New event: ', type, error);\n *\n * if (type === AdEventType.LOADED) {\n * interstitialAd.show();\n * }\n * });\n *\n * interstitialAd.load();\n * ```\n *\n * @param adUnitId The Ad Unit ID for the Interstitial. You can find this on your Google Mobile Ads dashboard.\n * @param requestOptions Optional RequestOptions used to load the ad.\n */\n static createForAdRequest(adUnitId: string, requestOptions?: RequestOptions): InterstitialAd {\n if (!isString(adUnitId)) {\n throw new Error(\"InterstitialAd.createForAdRequest(*) 'adUnitId' expected an string value.\");\n }\n\n let options = {};\n try {\n options = validateAdRequestOptions(requestOptions);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`InterstitialAd.createForAdRequest(_, *) ${e.message}.`);\n }\n }\n\n const requestId = _interstitialRequest++;\n return new InterstitialAd('interstitial', MobileAds(), requestId, adUnitId, options);\n }\n\n load() {\n // Prevent multiple load calls\n if (this._loaded || this._isLoadCalled) {\n return;\n }\n\n this._isLoadCalled = true;\n this._googleMobileAds.native.interstitialLoad(\n this._requestId,\n this._adUnitId,\n this._requestOptions,\n );\n }\n\n onAdEvent(handler: AdEventListener) {\n if (!isFunction(handler)) {\n throw new Error(\"InterstitialAd.onAdEvent(*) 'handler' expected a function.\");\n }\n\n return this._setAdEventHandler(handler);\n }\n\n show(showOptions?: AdShowOptions) {\n if (!this._loaded) {\n throw new Error(\n 'InterstitialAd.show() The requested InterstitialAd has not loaded and could not be shown.',\n );\n }\n\n let options;\n try {\n options = validateAdShowOptions(showOptions);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`InterstitialAd.show(*) ${e.message}.`);\n }\n }\n\n return this._googleMobileAds.native.interstitialShow(this._requestId, options);\n }\n}\n"]}
1
+ {"version":3,"sources":["InterstitialAd.ts"],"names":["isString","MobileAds","validateAdRequestOptions","MobileAd","InterstitialAd","createForAdRequest","adUnitId","requestOptions","Error","options","e","message","requestId","_interstitialRequest","addAdEventsListener","listener","_addAdEventsListener","addAdEventListener","type","_addAdEventListener"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,QAAT,QAAyB,WAAzB;AACA,SAASC,SAAT,QAA0B,cAA1B;AACA,SAASC,wBAAT,QAAyC,6BAAzC;AACA,SAASC,QAAT,QAAyB,YAAzB;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAN,SAA6BD,QAA7B,CAAsC;AAE3C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC2B,SAAlBE,kBAAkB,CAACC,QAAD,EAAmBC,cAAnB,EAAoD;AAC3E,QAAI,CAACP,QAAQ,CAACM,QAAD,CAAb,EAAyB;AACvB,YAAM,IAAIE,KAAJ,CAAU,2EAAV,CAAN;AACD;;AAED,QAAIC,OAAO,GAAG,EAAd;;AACA,QAAI;AACFA,MAAAA,OAAO,GAAGP,wBAAwB,CAACK,cAAD,CAAlC;AACD,KAFD,CAEE,OAAOG,CAAP,EAAU;AACV,UAAIA,CAAC,YAAYF,KAAjB,EAAwB;AACtB,cAAM,IAAIA,KAAJ,CAAW,2CAA0CE,CAAC,CAACC,OAAQ,GAA/D,CAAN;AACD;AACF;;AAED,UAAMC,SAAS,GAAGR,cAAc,CAACS,oBAAf,EAAlB;AACA,WAAO,IAAIT,cAAJ,CAAmB,cAAnB,EAAmCH,SAAS,EAA5C,EAAgDW,SAAhD,EAA2DN,QAA3D,EAAqEG,OAArE,CAAP;AACD;;AAEDK,EAAAA,mBAAmB,CAAwBC,QAAxB,EAAuD;AACxE,WAAO,KAAKC,oBAAL,CAA0BD,QAA1B,CAAP;AACD;;AAEDE,EAAAA,kBAAkB,CAAwBC,IAAxB,EAAiCH,QAAjC,EAA+D;AAC/E,WAAO,KAAKI,mBAAL,CAAyBD,IAAzB,EAA+BH,QAA/B,CAAP;AACD;;AAhD0C;;gBAAhCX,c,0BAC6B,C","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport { isString } from '../common';\nimport { MobileAds } from '../MobileAds';\nimport { validateAdRequestOptions } from '../validateAdRequestOptions';\nimport { MobileAd } from './MobileAd';\nimport { AdEventType } from '../AdEventType';\nimport { AdEventListener } from '../types/AdEventListener';\nimport { AdEventsListener } from '../types/AdEventsListener';\nimport { RequestOptions } from '../types/RequestOptions';\n\n/**\n * A class for interacting and showing Interstitial Ads.\n *\n * An Interstitial advert can be pre-loaded and shown at a suitable point in your apps flow, such as at the end of a level\n * in a game. An Interstitial is a full screen advert, laid on-top of your entire application which the user can interact with.\n * Interactions are passed back via events which should be handled accordingly inside of your app.\n *\n * #### Example\n *\n * First create a new Interstitial instance, passing in your Ad Unit ID from the Google Mobile Ads configuration console, and any additional\n * request options. The example below will present a test advert, and only request a non-personalized ad.\n *\n * ```js\n * import { InterstitialAd, TestIds } from 'react-native-google-mobile-ads';\n *\n * const interstitial = InterstitialAd.createForAdRequest(TestIds.INTERSTITIAL, {\n * requestNonPersonalizedAdsOnly: true,\n * });\n * ```\n *\n * Each advert needs to be loaded from Google Mobile Ads before being shown. It is recommended this is performed before the user\n * reaches the checkpoint to show the advert, so it's ready to go. Before loading the advert, we need to setup\n * event listeners to listen for updates from Google Mobile Ads, such as advert loaded or failed to load.\n *\n * Event types match the `AdEventType` interface. Once the advert has loaded, we can trigger it to show:\n *\n * ```js\n * import { AdEventType } from 'react-native-google-mobile-ads';\n *\n * interstitialAd.addAdEventListener(AdEventType.Loaded, () => {\n * interstitialAd.show();\n * });\n *\n * interstitial.load();\n * ```\n *\n * The advert will be presented to the user, and several more events can be triggered such as the user clicking the\n * advert or closing it.\n */\nexport class InterstitialAd extends MobileAd {\n protected static _interstitialRequest = 0;\n /**\n * Creates a new InterstitialAd instance.\n *\n * #### Example\n *\n * ```js\n * import { InterstitialAd, AdEventType, TestIds } from 'react-native-google-mobile-ads';\n *\n * const interstitialAd = await InterstitialAd.createForAdRequest(TestIds.INTERSTITIAL, {\n * requestAgent: 'CoolAds',\n * });\n *\n * interstitialAd.addAdEventListener(AdEventType.Loaded, () => {\n * interstitialAd.show();\n * });\n *\n * interstitialAd.load();\n * ```\n *\n * @param adUnitId The Ad Unit ID for the Interstitial. You can find this on your Google Mobile Ads dashboard.\n * @param requestOptions Optional RequestOptions used to load the ad.\n */\n static createForAdRequest(adUnitId: string, requestOptions?: RequestOptions) {\n if (!isString(adUnitId)) {\n throw new Error(\"InterstitialAd.createForAdRequest(*) 'adUnitId' expected an string value.\");\n }\n\n let options = {};\n try {\n options = validateAdRequestOptions(requestOptions);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`InterstitialAd.createForAdRequest(_, *) ${e.message}.`);\n }\n }\n\n const requestId = InterstitialAd._interstitialRequest++;\n return new InterstitialAd('interstitial', MobileAds(), requestId, adUnitId, options);\n }\n\n addAdEventsListener<T extends AdEventType>(listener: AdEventsListener<T>) {\n return this._addAdEventsListener(listener);\n }\n\n addAdEventListener<T extends AdEventType>(type: T, listener: AdEventListener<T>) {\n return this._addAdEventListener(type, listener);\n }\n}\n"]}