react-native-google-mobile-ads 6.0.0 → 6.2.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 (72) hide show
  1. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java +9 -3
  2. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsEvent.java +2 -0
  3. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsPackage.java +1 -0
  4. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsRewardedInterstitialModule.java +199 -0
  5. package/docs/displaying-ads-hook.mdx +1 -1
  6. package/docs/displaying-ads.mdx +132 -1
  7. package/docs/european-user-consent.mdx +31 -0
  8. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.h +1 -0
  9. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m +7 -1
  10. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedInterstitialModule.h +25 -0
  11. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedInterstitialModule.m +173 -0
  12. package/lib/commonjs/BannerAdSize.js +2 -0
  13. package/lib/commonjs/BannerAdSize.js.map +1 -1
  14. package/lib/commonjs/MobileAds.js +5 -2
  15. package/lib/commonjs/MobileAds.js.map +1 -1
  16. package/lib/commonjs/TestIds.js +6 -2
  17. package/lib/commonjs/TestIds.js.map +1 -1
  18. package/lib/commonjs/ads/MobileAd.js +16 -4
  19. package/lib/commonjs/ads/MobileAd.js.map +1 -1
  20. package/lib/commonjs/ads/RewardedInterstitialAd.js +127 -0
  21. package/lib/commonjs/ads/RewardedInterstitialAd.js.map +1 -0
  22. package/lib/commonjs/hooks/useFullScreenAd.js.map +1 -1
  23. package/lib/commonjs/hooks/useRewardedAd.js.map +1 -1
  24. package/lib/commonjs/hooks/useRewardedInterstitialAd.js +51 -0
  25. package/lib/commonjs/hooks/useRewardedInterstitialAd.js.map +1 -0
  26. package/lib/commonjs/index.js +19 -1
  27. package/lib/commonjs/index.js.map +1 -1
  28. package/lib/commonjs/version.js +1 -1
  29. package/lib/commonjs/version.js.map +1 -1
  30. package/lib/module/BannerAdSize.js +2 -0
  31. package/lib/module/BannerAdSize.js.map +1 -1
  32. package/lib/module/MobileAds.js +5 -2
  33. package/lib/module/MobileAds.js.map +1 -1
  34. package/lib/module/TestIds.js +6 -2
  35. package/lib/module/TestIds.js.map +1 -1
  36. package/lib/module/ads/MobileAd.js +16 -4
  37. package/lib/module/ads/MobileAd.js.map +1 -1
  38. package/lib/module/ads/RewardedInterstitialAd.js +130 -0
  39. package/lib/module/ads/RewardedInterstitialAd.js.map +1 -0
  40. package/lib/module/hooks/useFullScreenAd.js.map +1 -1
  41. package/lib/module/hooks/useRewardedAd.js.map +1 -1
  42. package/lib/module/hooks/useRewardedInterstitialAd.js +38 -0
  43. package/lib/module/hooks/useRewardedInterstitialAd.js.map +1 -0
  44. package/lib/module/index.js +2 -0
  45. package/lib/module/index.js.map +1 -1
  46. package/lib/module/version.js +1 -1
  47. package/lib/module/version.js.map +1 -1
  48. package/lib/typescript/BannerAdSize.d.ts +10 -1
  49. package/lib/typescript/MobileAds.d.ts +1 -1
  50. package/lib/typescript/TestIds.d.ts +2 -0
  51. package/lib/typescript/ads/MobileAd.d.ts +3 -2
  52. package/lib/typescript/ads/RewardedInterstitialAd.d.ts +82 -0
  53. package/lib/typescript/hooks/useFullScreenAd.d.ts +2 -1
  54. package/lib/typescript/hooks/useRewardedAd.d.ts +1 -1
  55. package/lib/typescript/hooks/useRewardedInterstitialAd.d.ts +9 -0
  56. package/lib/typescript/index.d.ts +3 -1
  57. package/lib/typescript/types/GoogleMobileAdsNativeModule.d.ts +12 -7
  58. package/lib/typescript/types/MobileAdsModule.interface.d.ts +1 -1
  59. package/lib/typescript/version.d.ts +1 -1
  60. package/package.json +8 -8
  61. package/src/BannerAdSize.ts +12 -1
  62. package/src/MobileAds.ts +9 -0
  63. package/src/TestIds.ts +4 -0
  64. package/src/ads/MobileAd.ts +16 -6
  65. package/src/ads/RewardedInterstitialAd.ts +143 -0
  66. package/src/hooks/useFullScreenAd.ts +4 -3
  67. package/src/hooks/useRewardedAd.ts +1 -1
  68. package/src/hooks/useRewardedInterstitialAd.ts +47 -0
  69. package/src/index.ts +2 -0
  70. package/src/types/GoogleMobileAdsNativeModule.ts +16 -7
  71. package/src/types/MobileAdsModule.interface.ts +1 -1
  72. package/src/version.ts +1 -1
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useRewardedInterstitialAd = useRewardedInterstitialAd;
7
+
8
+ var _react = require("react");
9
+
10
+ var _useDeepCompareEffect = _interopRequireDefault(require("use-deep-compare-effect"));
11
+
12
+ var _RewardedInterstitialAd = require("../ads/RewardedInterstitialAd");
13
+
14
+ var _useFullScreenAd = require("./useFullScreenAd");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ /*
19
+ * Copyright (c) 2016-present Invertase Limited & Contributors
20
+ *
21
+ * Licensed under the Apache License, Version 2.0 (the "License");
22
+ * you may not use this library except in compliance with the License.
23
+ * You may obtain a copy of the License at
24
+ *
25
+ * http://www.apache.org/licenses/LICENSE-2.0
26
+ *
27
+ * Unless required by applicable law or agreed to in writing, software
28
+ * distributed under the License is distributed on an "AS IS" BASIS,
29
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30
+ * See the License for the specific language governing permissions and
31
+ * limitations under the License.
32
+ *
33
+ */
34
+
35
+ /**
36
+ * React Hook for Rewarded Interstitial Ad.
37
+ *
38
+ * @param adUnitId The Ad Unit ID for the Rewarded Interstitial Ad. You can find this on your Google Mobile Ads dashboard. You can destroy ad instance by setting this value to null.
39
+ * @param requestOptions Optional RequestOptions used to load the ad.
40
+ */
41
+ function useRewardedInterstitialAd(adUnitId) {
42
+ let requestOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
43
+ const [rewardedInterstitialAd, setRewardedInterstitialAd] = (0, _react.useState)(null);
44
+ (0, _useDeepCompareEffect.default)(() => {
45
+ setRewardedInterstitialAd(() => {
46
+ return adUnitId ? _RewardedInterstitialAd.RewardedInterstitialAd.createForAdRequest(adUnitId, requestOptions) : null;
47
+ });
48
+ }, [adUnitId, requestOptions]);
49
+ return (0, _useFullScreenAd.useFullScreenAd)(rewardedInterstitialAd);
50
+ }
51
+ //# sourceMappingURL=useRewardedInterstitialAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useRewardedInterstitialAd.ts"],"names":["useRewardedInterstitialAd","adUnitId","requestOptions","rewardedInterstitialAd","setRewardedInterstitialAd","RewardedInterstitialAd","createForAdRequest"],"mappings":";;;;;;;AAiBA;;AACA;;AAEA;;AAIA;;;;AAxBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,yBAAT,CACLC,QADK,EAGU;AAAA,MADfC,cACe,uEADkB,EAClB;AACf,QAAM,CAACC,sBAAD,EAAyBC,yBAAzB,IACJ,qBAAwC,IAAxC,CADF;AAGA,qCAAqB,MAAM;AACzBA,IAAAA,yBAAyB,CAAC,MAAM;AAC9B,aAAOH,QAAQ,GAAGI,+CAAuBC,kBAAvB,CAA0CL,QAA1C,EAAoDC,cAApD,CAAH,GAAyE,IAAxF;AACD,KAFwB,CAAzB;AAGD,GAJD,EAIG,CAACD,QAAD,EAAWC,cAAX,CAJH;AAMA,SAAO,sCAAgBC,sBAAhB,CAAP;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 { useState } from 'react';\nimport useDeepCompareEffect from 'use-deep-compare-effect';\n\nimport { RewardedInterstitialAd } from '../ads/RewardedInterstitialAd';\nimport { AdHookReturns } from '../types/AdStates';\nimport { RequestOptions } from '../types/RequestOptions';\n\nimport { useFullScreenAd } from './useFullScreenAd';\n\n/**\n * React Hook for Rewarded Interstitial Ad.\n *\n * @param adUnitId The Ad Unit ID for the Rewarded Interstitial Ad. You can find this on your Google Mobile Ads dashboard. You can destroy ad instance by setting this value to null.\n * @param requestOptions Optional RequestOptions used to load the ad.\n */\nexport function useRewardedInterstitialAd(\n adUnitId: string | null,\n requestOptions: RequestOptions = {},\n): AdHookReturns {\n const [rewardedInterstitialAd, setRewardedInterstitialAd] =\n useState<RewardedInterstitialAd | null>(null);\n\n useDeepCompareEffect(() => {\n setRewardedInterstitialAd(() => {\n return adUnitId ? RewardedInterstitialAd.createForAdRequest(adUnitId, requestOptions) : null;\n });\n }, [adUnitId, requestOptions]);\n\n return useFullScreenAd(rewardedInterstitialAd);\n}\n"]}
@@ -20,12 +20,14 @@ var _exportNames = {
20
20
  AppOpenAd: true,
21
21
  InterstitialAd: true,
22
22
  RewardedAd: true,
23
+ RewardedInterstitialAd: true,
23
24
  BannerAd: true,
24
25
  GAMBannerAd: true,
25
26
  GAMInterstitialAd: true,
26
27
  useAppOpenAd: true,
27
28
  useInterstitialAd: true,
28
- useRewardedAd: true
29
+ useRewardedAd: true,
30
+ useRewardedInterstitialAd: true
29
31
  };
30
32
  Object.defineProperty(exports, "AdEventType", {
31
33
  enumerable: true,
@@ -129,6 +131,12 @@ Object.defineProperty(exports, "RewardedAdEventType", {
129
131
  return _RewardedAdEventType.RewardedAdEventType;
130
132
  }
131
133
  });
134
+ Object.defineProperty(exports, "RewardedInterstitialAd", {
135
+ enumerable: true,
136
+ get: function () {
137
+ return _RewardedInterstitialAd.RewardedInterstitialAd;
138
+ }
139
+ });
132
140
  exports.SDK_VERSION = void 0;
133
141
  Object.defineProperty(exports, "TestIds", {
134
142
  enumerable: true,
@@ -160,6 +168,12 @@ Object.defineProperty(exports, "useRewardedAd", {
160
168
  return _useRewardedAd.useRewardedAd;
161
169
  }
162
170
  });
171
+ Object.defineProperty(exports, "useRewardedInterstitialAd", {
172
+ enumerable: true,
173
+ get: function () {
174
+ return _useRewardedInterstitialAd.useRewardedInterstitialAd;
175
+ }
176
+ });
163
177
 
164
178
  var _version = require("./version");
165
179
 
@@ -193,6 +207,8 @@ var _InterstitialAd = require("./ads/InterstitialAd");
193
207
 
194
208
  var _RewardedAd = require("./ads/RewardedAd");
195
209
 
210
+ var _RewardedInterstitialAd = require("./ads/RewardedInterstitialAd");
211
+
196
212
  var _BannerAd = require("./ads/BannerAd");
197
213
 
198
214
  var _GAMBannerAd = require("./ads/GAMBannerAd");
@@ -205,6 +221,8 @@ var _useInterstitialAd = require("./hooks/useInterstitialAd");
205
221
 
206
222
  var _useRewardedAd = require("./hooks/useRewardedAd");
207
223
 
224
+ var _useRewardedInterstitialAd = require("./hooks/useRewardedInterstitialAd");
225
+
208
226
  var _types = require("./types");
209
227
 
210
228
  Object.keys(_types).forEach(function (key) {
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["SDK_VERSION","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;AA3CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACO,MAAMA,WAAW,GAAGC,gBAApB","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 { version } from './version';\n\n// import { SDK_VERSION } from 'react-native-google-mobile-ads';\nexport const SDK_VERSION = version;\n\nexport { default, MobileAds } from './MobileAds';\nexport { AdsConsentDebugGeography } from './AdsConsentDebugGeography';\nexport { AdsConsentPurposes } from './AdsConsentPurposes';\nexport { AdsConsentSpecialFeatures } from './AdsConsentSpecialFeatures';\nexport { AdsConsentStatus } from './AdsConsentStatus';\nexport { MaxAdContentRating } from './MaxAdContentRating';\nexport { TestIds } from './TestIds';\nexport { AdEventType } from './AdEventType';\nexport { BannerAdSize } from './BannerAdSize';\nexport { GAMAdEventType } from './GAMAdEventType';\nexport { RewardedAdEventType } from './RewardedAdEventType';\nexport { AdsConsent } from './AdsConsent';\nexport { AppOpenAd } from './ads/AppOpenAd';\nexport { InterstitialAd } from './ads/InterstitialAd';\nexport { RewardedAd } from './ads/RewardedAd';\nexport { BannerAd } from './ads/BannerAd';\nexport { GAMBannerAd } from './ads/GAMBannerAd';\nexport { GAMInterstitialAd } from './ads/GAMInterstitialAd';\nexport { useAppOpenAd } from './hooks/useAppOpenAd';\nexport { useInterstitialAd } from './hooks/useInterstitialAd';\nexport { useRewardedAd } from './hooks/useRewardedAd';\nexport * from './types';\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["SDK_VERSION","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;AA7CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACO,MAAMA,WAAW,GAAGC,gBAApB","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 { version } from './version';\n\n// import { SDK_VERSION } from 'react-native-google-mobile-ads';\nexport const SDK_VERSION = version;\n\nexport { default, MobileAds } from './MobileAds';\nexport { AdsConsentDebugGeography } from './AdsConsentDebugGeography';\nexport { AdsConsentPurposes } from './AdsConsentPurposes';\nexport { AdsConsentSpecialFeatures } from './AdsConsentSpecialFeatures';\nexport { AdsConsentStatus } from './AdsConsentStatus';\nexport { MaxAdContentRating } from './MaxAdContentRating';\nexport { TestIds } from './TestIds';\nexport { AdEventType } from './AdEventType';\nexport { BannerAdSize } from './BannerAdSize';\nexport { GAMAdEventType } from './GAMAdEventType';\nexport { RewardedAdEventType } from './RewardedAdEventType';\nexport { AdsConsent } from './AdsConsent';\nexport { AppOpenAd } from './ads/AppOpenAd';\nexport { InterstitialAd } from './ads/InterstitialAd';\nexport { RewardedAd } from './ads/RewardedAd';\nexport { RewardedInterstitialAd } from './ads/RewardedInterstitialAd';\nexport { BannerAd } from './ads/BannerAd';\nexport { GAMBannerAd } from './ads/GAMBannerAd';\nexport { GAMInterstitialAd } from './ads/GAMInterstitialAd';\nexport { useAppOpenAd } from './hooks/useAppOpenAd';\nexport { useInterstitialAd } from './hooks/useInterstitialAd';\nexport { useRewardedAd } from './hooks/useRewardedAd';\nexport { useRewardedInterstitialAd } from './hooks/useRewardedInterstitialAd';\nexport * from './types';\n"]}
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = void 0;
7
7
  // Generated by genversion.
8
- const version = '6.0.0';
8
+ const version = '6.2.0';
9
9
  exports.version = version;
10
10
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// Generated by genversion.\nexport const version = '6.0.0';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// Generated by genversion.\nexport const version = '6.2.0';\n"]}
@@ -24,6 +24,8 @@ export let BannerAdSize;
24
24
  BannerAdSize["LEADERBOARD"] = "LEADERBOARD";
25
25
  BannerAdSize["MEDIUM_RECTANGLE"] = "MEDIUM_RECTANGLE";
26
26
  BannerAdSize["ADAPTIVE_BANNER"] = "ADAPTIVE_BANNER";
27
+ BannerAdSize["ANCHORED_ADAPTIVE_BANNER"] = "ANCHORED_ADAPTIVE_BANNER";
28
+ BannerAdSize["INLINE_ADAPTIVE_BANNER"] = "INLINE_ADAPTIVE_BANNER";
27
29
  BannerAdSize["FLUID"] = "FLUID";
28
30
  BannerAdSize["WIDE_SKYSCRAPER"] = "WIDE_SKYSCRAPER";
29
31
  })(BannerAdSize || (BannerAdSize = {}));
@@ -1 +1 @@
1
- {"version":3,"sources":["BannerAdSize.ts"],"names":["BannerAdSize"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,WAAYA,YAAZ;;WAAYA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;GAAAA,Y,KAAAA,Y","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 */\n\nexport enum BannerAdSize {\n /**\n * Mobile Marketing Association (MMA) banner ad size (320x50 density-independent pixels).\n */\n BANNER = 'BANNER',\n\n /**\n * Interactive Advertising Bureau (IAB) full banner ad size (468x60 density-independent pixels).\n */\n FULL_BANNER = 'FULL_BANNER',\n\n /**\n * Large banner ad size (320x100 density-independent pixels).\n */\n LARGE_BANNER = 'LARGE_BANNER',\n\n /**\n * Interactive Advertising Bureau (IAB) leaderboard ad size (728x90 density-independent pixels).\n */\n LEADERBOARD = 'LEADERBOARD',\n\n /**\n * Interactive Advertising Bureau (IAB) medium rectangle ad size (300x250 density-independent pixels).\n */\n MEDIUM_RECTANGLE = 'MEDIUM_RECTANGLE',\n\n /**\n * A (next generation) dynamically sized banner that is full-width and auto-height.\n */\n ADAPTIVE_BANNER = 'ADAPTIVE_BANNER',\n\n /**\n * A dynamically sized banner that matches its parent's width and expands/contracts its height to match the ad's content after loading completes.\n */\n FLUID = 'FLUID',\n\n /**\n * IAB wide skyscraper ad size (160x600 density-independent pixels). This size is currently not supported by the Google Mobile Ads network; this is intended for mediation ad networks only.\n */\n WIDE_SKYSCRAPER = 'WIDE_SKYSCRAPER',\n}\n"]}
1
+ {"version":3,"sources":["BannerAdSize.ts"],"names":["BannerAdSize"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,WAAYA,YAAZ;;WAAYA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;GAAAA,Y,KAAAA,Y","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 */\n\nexport enum BannerAdSize {\n /**\n * Mobile Marketing Association (MMA) banner ad size (320x50 density-independent pixels).\n */\n BANNER = 'BANNER',\n\n /**\n * Interactive Advertising Bureau (IAB) full banner ad size (468x60 density-independent pixels).\n */\n FULL_BANNER = 'FULL_BANNER',\n\n /**\n * Large banner ad size (320x100 density-independent pixels).\n */\n LARGE_BANNER = 'LARGE_BANNER',\n\n /**\n * Interactive Advertising Bureau (IAB) leaderboard ad size (728x90 density-independent pixels).\n */\n LEADERBOARD = 'LEADERBOARD',\n\n /**\n * Interactive Advertising Bureau (IAB) medium rectangle ad size (300x250 density-independent pixels).\n */\n MEDIUM_RECTANGLE = 'MEDIUM_RECTANGLE',\n\n /**\n * @deprecated Use `ANCHORED_ADAPTIVE_BANNER` instead.\n */\n ADAPTIVE_BANNER = 'ADAPTIVE_BANNER',\n\n /**\n * A (next generation) dynamically sized banner that is full-width and auto-height.\n */\n ANCHORED_ADAPTIVE_BANNER = 'ANCHORED_ADAPTIVE_BANNER',\n\n /**\n * Inline adaptive banners are larger, taller banners compared to anchored adaptive banners. They are of variable height, and can be as tall as the device screen.\n * They are intended to be placed in scrolling content.\n */\n INLINE_ADAPTIVE_BANNER = 'INLINE_ADAPTIVE_BANNER',\n\n /**\n * A dynamically sized banner that matches its parent's width and expands/contracts its height to match the ad's content after loading completes.\n */\n FLUID = 'FLUID',\n\n /**\n * IAB wide skyscraper ad size (160x600 density-independent pixels). This size is currently not supported by the Google Mobile Ads network; this is intended for mediation ad networks only.\n */\n WIDE_SKYSCRAPER = 'WIDE_SKYSCRAPER',\n}\n"]}
@@ -2,7 +2,7 @@ import { Module } from './internal';
2
2
  import { validateAdRequestConfiguration } from './validateAdRequestConfiguration';
3
3
  import { version } from './version';
4
4
  const namespace = 'google_mobile_ads';
5
- const nativeModuleName = ['RNGoogleMobileAdsModule', 'RNGoogleMobileAdsAppOpenModule', 'RNGoogleMobileAdsInterstitialModule', 'RNGoogleMobileAdsRewardedModule'];
5
+ const nativeModuleName = ['RNGoogleMobileAdsModule', 'RNGoogleMobileAdsAppOpenModule', 'RNGoogleMobileAdsInterstitialModule', 'RNGoogleMobileAdsRewardedModule', 'RNGoogleMobileAdsRewardedInterstitialModule'];
6
6
 
7
7
  class MobileAdsModule extends Module {
8
8
  constructor(app, config) {
@@ -16,6 +16,9 @@ class MobileAdsModule extends Module {
16
16
  this.emitter.addListener('google_mobile_ads_rewarded_event', event => {
17
17
  this.emitter.emit(`google_mobile_ads_rewarded_event:${event.adUnitId}:${event.requestId}`, event);
18
18
  });
19
+ this.emitter.addListener('google_mobile_ads_rewarded_interstitial_event', event => {
20
+ this.emitter.emit(`google_mobile_ads_rewarded_interstitial_event:${event.adUnitId}:${event.requestId}`, event);
21
+ });
19
22
  }
20
23
 
21
24
  initialize() {
@@ -48,7 +51,7 @@ const MobileAdsInstance = new MobileAdsModule({
48
51
  version,
49
52
  namespace,
50
53
  nativeModuleName,
51
- nativeEvents: ['google_mobile_ads_app_open_event', 'google_mobile_ads_interstitial_event', 'google_mobile_ads_rewarded_event']
54
+ nativeEvents: ['google_mobile_ads_app_open_event', 'google_mobile_ads_interstitial_event', 'google_mobile_ads_rewarded_event', 'google_mobile_ads_rewarded_interstitial_event']
52
55
  });
53
56
  export const MobileAds = () => {
54
57
  return MobileAdsInstance;
@@ -1 +1 @@
1
- {"version":3,"sources":["MobileAds.ts"],"names":["Module","validateAdRequestConfiguration","version","namespace","nativeModuleName","MobileAdsModule","constructor","app","config","emitter","addListener","event","emit","adUnitId","requestId","initialize","native","setRequestConfiguration","requestConfiguration","e","Error","message","openAdInspector","MobileAdsInstance","name","nativeEvents","MobileAds"],"mappings":"AAAA,SAASA,MAAT,QAAuB,YAAvB;AACA,SAASC,8BAAT,QAA+C,kCAA/C;AACA,SAASC,OAAT,QAAwB,WAAxB;AAKA,MAAMC,SAAS,GAAG,mBAAlB;AAEA,MAAMC,gBAAgB,GAAG,CACvB,yBADuB,EAEvB,gCAFuB,EAGvB,qCAHuB,EAIvB,iCAJuB,CAAzB;;AAYA,MAAMC,eAAN,SAA8BL,MAA9B,CAAyE;AACvEM,EAAAA,WAAW,CAACC,GAAD,EAAWC,MAAX,EAA2B;AACpC,UAAMD,GAAN,EAAWC,MAAX;AAEA,SAAKC,OAAL,CAAaC,WAAb,CAAyB,kCAAzB,EAA8DC,KAAD,IAAk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,EAEZ,sCAFY,EAGZ,kCAHY;AAJhB,CAFwB,CAA1B;AAcA,OAAO,MAAMC,SAAS,GAAG,MAAM;AAC7B,SAAOH,iBAAP;AACD,CAFM;AAIP,eAAeG,SAAf","sourcesContent":["import { Module } from './internal';\nimport { validateAdRequestConfiguration } from './validateAdRequestConfiguration';\nimport { version } from './version';\nimport { MobileAdsModuleInterface } from './types/MobileAdsModule.interface';\nimport { RequestConfiguration } from './types/RequestConfiguration';\nimport { App, Config } from './types/Module.interface';\n\nconst namespace = 'google_mobile_ads';\n\nconst nativeModuleName = [\n 'RNGoogleMobileAdsModule',\n 'RNGoogleMobileAdsAppOpenModule',\n 'RNGoogleMobileAdsInterstitialModule',\n 'RNGoogleMobileAdsRewardedModule',\n];\n\ntype Event = {\n adUnitId: string;\n requestId: number;\n};\n\nclass MobileAdsModule extends Module implements MobileAdsModuleInterface {\n constructor(app: App, config: Config) {\n super(app, config);\n\n this.emitter.addListener('google_mobile_ads_app_open_event', (event: Event) => {\n this.emitter.emit(\n `google_mobile_ads_app_open_event:${event.adUnitId}:${event.requestId}`,\n event,\n );\n });\n\n this.emitter.addListener('google_mobile_ads_interstitial_event', (event: Event) => {\n this.emitter.emit(\n `google_mobile_ads_interstitial_event:${event.adUnitId}:${event.requestId}`,\n event,\n );\n });\n\n this.emitter.addListener('google_mobile_ads_rewarded_event', (event: Event) => {\n this.emitter.emit(\n `google_mobile_ads_rewarded_event:${event.adUnitId}:${event.requestId}`,\n event,\n );\n });\n }\n\n initialize() {\n return this.native.initialize();\n }\n\n setRequestConfiguration(requestConfiguration: RequestConfiguration) {\n let config;\n try {\n config = validateAdRequestConfiguration(requestConfiguration);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`googleMobileAds.setRequestConfiguration(*) ${e.message}`);\n }\n }\n\n return this.native.setRequestConfiguration(config);\n }\n\n openAdInspector() {\n return this.native.openAdInspector();\n }\n}\n\nconst MobileAdsInstance = new MobileAdsModule(\n { name: 'AppName' },\n {\n version,\n namespace,\n nativeModuleName,\n nativeEvents: [\n 'google_mobile_ads_app_open_event',\n 'google_mobile_ads_interstitial_event',\n 'google_mobile_ads_rewarded_event',\n ],\n },\n);\n\nexport const MobileAds = () => {\n return MobileAdsInstance;\n};\n\nexport default MobileAds;\n"]}
1
+ {"version":3,"sources":["MobileAds.ts"],"names":["Module","validateAdRequestConfiguration","version","namespace","nativeModuleName","MobileAdsModule","constructor","app","config","emitter","addListener","event","emit","adUnitId","requestId","initialize","native","setRequestConfiguration","requestConfiguration","e","Error","message","openAdInspector","MobileAdsInstance","name","nativeEvents","MobileAds"],"mappings":"AAAA,SAASA,MAAT,QAAuB,YAAvB;AACA,SAASC,8BAAT,QAA+C,kCAA/C;AACA,SAASC,OAAT,QAAwB,WAAxB;AAKA,MAAMC,SAAS,GAAG,mBAAlB;AAEA,MAAMC,gBAAgB,GAAG,CACvB,yBADuB,EAEvB,gCAFuB,EAGvB,qCAHuB,EAIvB,iCAJuB,EAKvB,6CALuB,CAAzB;;AAaA,MAAMC,eAAN,SAA8BL,MAA9B,CAAyE;AACvEM,EAAAA,WAAW,CAACC,GAAD,EAAWC,MAAX,EAA2B;AACpC,UAAMD,GAAN,EAAWC,MAAX;AAEA,SAAKC,OAAL,CAAaC,WAAb,CAAyB,kCAAzB,EAA8DC,KAAD,IAAkB;AAC7E,WAAKF,OAAL,CAAaG,IAAb,CACG,oCAAmCD,KAAK,CAACE,QAAS,IAAGF,KAAK,CAACG,SAAU,EADxE,EAEEH,KAFF;AAID,KALD;AAOA,SAAKF,OAAL,CAAaC,WAAb,CAAyB,sCAAzB,EAAkEC,KAAD,IAAkB;AACjF,WAAKF,OAAL,CAAaG,IAAb,CACG,wCAAuCD,KAAK,CAACE,QAAS,IAAGF,KAAK,CAACG,SAAU,EAD5E,EAEEH,KAFF;AAID,KALD;AAOA,SAAKF,OAAL,CAAaC,WAAb,CAAyB,kCAAzB,EAA8DC,KAAD,IAAkB;AAC7E,WAAKF,OAAL,CAAaG,IAAb,CACG,oCAAmCD,KAAK,CAACE,QAAS,IAAGF,KAAK,CAACG,SAAU,EADxE,EAEEH,KAFF;AAID,KALD;AAOA,SAAKF,OAAL,CAAaC,WAAb,CAAyB,+CAAzB,EAA2EC,KAAD,IAAkB;AAC1F,WAAKF,OAAL,CAAaG,IAAb,CACG,iDAAgDD,KAAK,CAACE,QAAS,IAAGF,KAAK,CAACG,SAAU,EADrF,EAEEH,KAFF;AAID,KALD;AAMD;;AAEDI,EAAAA,UAAU,GAAG;AACX,WAAO,KAAKC,MAAL,CAAYD,UAAZ,EAAP;AACD;;AAEDE,EAAAA,uBAAuB,CAACC,oBAAD,EAA6C;AAClE,QAAIV,MAAJ;;AACA,QAAI;AACFA,MAAAA,MAAM,GAAGP,8BAA8B,CAACiB,oBAAD,CAAvC;AACD,KAFD,CAEE,OAAOC,CAAP,EAAU;AACV,UAAIA,CAAC,YAAYC,KAAjB,EAAwB;AACtB,cAAM,IAAIA,KAAJ,CAAW,8CAA6CD,CAAC,CAACE,OAAQ,EAAlE,CAAN;AACD;AACF;;AAED,WAAO,KAAKL,MAAL,CAAYC,uBAAZ,CAAoCT,MAApC,CAAP;AACD;;AAEDc,EAAAA,eAAe,GAAG;AAChB,WAAO,KAAKN,MAAL,CAAYM,eAAZ,EAAP;AACD;;AApDsE;;AAuDzE,MAAMC,iBAAiB,GAAG,IAAIlB,eAAJ,CACxB;AAAEmB,EAAAA,IAAI,EAAE;AAAR,CADwB,EAExB;AACEtB,EAAAA,OADF;AAEEC,EAAAA,SAFF;AAGEC,EAAAA,gBAHF;AAIEqB,EAAAA,YAAY,EAAE,CACZ,kCADY,EAEZ,sCAFY,EAGZ,kCAHY,EAIZ,+CAJY;AAJhB,CAFwB,CAA1B;AAeA,OAAO,MAAMC,SAAS,GAAG,MAAM;AAC7B,SAAOH,iBAAP;AACD,CAFM;AAIP,eAAeG,SAAf","sourcesContent":["import { Module } from './internal';\nimport { validateAdRequestConfiguration } from './validateAdRequestConfiguration';\nimport { version } from './version';\nimport { MobileAdsModuleInterface } from './types/MobileAdsModule.interface';\nimport { RequestConfiguration } from './types/RequestConfiguration';\nimport { App, Config } from './types/Module.interface';\n\nconst namespace = 'google_mobile_ads';\n\nconst nativeModuleName = [\n 'RNGoogleMobileAdsModule',\n 'RNGoogleMobileAdsAppOpenModule',\n 'RNGoogleMobileAdsInterstitialModule',\n 'RNGoogleMobileAdsRewardedModule',\n 'RNGoogleMobileAdsRewardedInterstitialModule',\n];\n\ntype Event = {\n adUnitId: string;\n requestId: number;\n};\n\nclass MobileAdsModule extends Module implements MobileAdsModuleInterface {\n constructor(app: App, config: Config) {\n super(app, config);\n\n this.emitter.addListener('google_mobile_ads_app_open_event', (event: Event) => {\n this.emitter.emit(\n `google_mobile_ads_app_open_event:${event.adUnitId}:${event.requestId}`,\n event,\n );\n });\n\n this.emitter.addListener('google_mobile_ads_interstitial_event', (event: Event) => {\n this.emitter.emit(\n `google_mobile_ads_interstitial_event:${event.adUnitId}:${event.requestId}`,\n event,\n );\n });\n\n this.emitter.addListener('google_mobile_ads_rewarded_event', (event: Event) => {\n this.emitter.emit(\n `google_mobile_ads_rewarded_event:${event.adUnitId}:${event.requestId}`,\n event,\n );\n });\n\n this.emitter.addListener('google_mobile_ads_rewarded_interstitial_event', (event: Event) => {\n this.emitter.emit(\n `google_mobile_ads_rewarded_interstitial_event:${event.adUnitId}:${event.requestId}`,\n event,\n );\n });\n }\n\n initialize() {\n return this.native.initialize();\n }\n\n setRequestConfiguration(requestConfiguration: RequestConfiguration) {\n let config;\n try {\n config = validateAdRequestConfiguration(requestConfiguration);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`googleMobileAds.setRequestConfiguration(*) ${e.message}`);\n }\n }\n\n return this.native.setRequestConfiguration(config);\n }\n\n openAdInspector() {\n return this.native.openAdInspector();\n }\n}\n\nconst MobileAdsInstance = new MobileAdsModule(\n { name: 'AppName' },\n {\n version,\n namespace,\n nativeModuleName,\n nativeEvents: [\n 'google_mobile_ads_app_open_event',\n 'google_mobile_ads_interstitial_event',\n 'google_mobile_ads_rewarded_event',\n 'google_mobile_ads_rewarded_interstitial_event',\n ],\n },\n);\n\nexport const MobileAds = () => {\n return MobileAdsInstance;\n};\n\nexport default MobileAds;\n"]}
@@ -20,23 +20,27 @@ export const TestIds = {
20
20
  BANNER: '',
21
21
  INTERSTITIAL: '',
22
22
  REWARDED: '',
23
+ REWARDED_INTERSTITIAL: '',
23
24
  GAM_APP_OPEN: '/6499/example/app-open',
24
25
  GAM_BANNER: '/6499/example/banner',
25
26
  GAM_INTERSTITIAL: '/6499/example/interstitial',
26
27
  GAM_REWARDED: '/6499/example/rewarded',
28
+ GAM_REWARDED_INTERSTITIAL: '/21775744923/example/rewarded_interstitial',
27
29
  GAM_NATIVE: '/6499/example/native',
28
30
  ...Platform.select({
29
31
  android: {
30
32
  APP_OPEN: 'ca-app-pub-3940256099942544/3419835294',
31
33
  BANNER: 'ca-app-pub-3940256099942544/6300978111',
32
34
  INTERSTITIAL: 'ca-app-pub-3940256099942544/1033173712',
33
- REWARDED: 'ca-app-pub-3940256099942544/5224354917'
35
+ REWARDED: 'ca-app-pub-3940256099942544/5224354917',
36
+ REWARDED_INTERSTITIAL: 'ca-app-pub-3940256099942544/5354046379'
34
37
  },
35
38
  ios: {
36
39
  APP_OPEN: 'ca-app-pub-3940256099942544/5662855259',
37
40
  BANNER: 'ca-app-pub-3940256099942544/2934735716',
38
41
  INTERSTITIAL: 'ca-app-pub-3940256099942544/4411468910',
39
- REWARDED: 'ca-app-pub-3940256099942544/1712485313'
42
+ REWARDED: 'ca-app-pub-3940256099942544/1712485313',
43
+ REWARDED_INTERSTITIAL: 'ca-app-pub-3940256099942544/6978759866'
40
44
  }
41
45
  })
42
46
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["TestIds.ts"],"names":["Platform","TestIds","APP_OPEN","BANNER","INTERSTITIAL","REWARDED","GAM_APP_OPEN","GAM_BANNER","GAM_INTERSTITIAL","GAM_REWARDED","GAM_NATIVE","select","android","ios"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,QAAT,QAAyB,cAAzB;AAEA,OAAO,MAAMC,OAAO,GAAG;AACrBC,EAAAA,QAAQ,EAAE,EADW;AAErBC,EAAAA,MAAM,EAAE,EAFa;AAGrBC,EAAAA,YAAY,EAAE,EAHO;AAIrBC,EAAAA,QAAQ,EAAE,EAJW;AAKrBC,EAAAA,YAAY,EAAE,wBALO;AAMrBC,EAAAA,UAAU,EAAE,sBANS;AAOrBC,EAAAA,gBAAgB,EAAE,4BAPG;AAQrBC,EAAAA,YAAY,EAAE,wBARO;AASrBC,EAAAA,UAAU,EAAE,sBATS;AAUrB,KAAGV,QAAQ,CAACW,MAAT,CAAgB;AACjBC,IAAAA,OAAO,EAAE;AACPV,MAAAA,QAAQ,EAAE,wCADH;AAEPC,MAAAA,MAAM,EAAE,wCAFD;AAGPC,MAAAA,YAAY,EAAE,wCAHP;AAIPC,MAAAA,QAAQ,EAAE;AAJH,KADQ;AAOjBQ,IAAAA,GAAG,EAAE;AACHX,MAAAA,QAAQ,EAAE,wCADP;AAEHC,MAAAA,MAAM,EAAE,wCAFL;AAGHC,MAAAA,YAAY,EAAE,wCAHX;AAIHC,MAAAA,QAAQ,EAAE;AAJP;AAPY,GAAhB;AAVkB,CAAhB","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 { Platform } from 'react-native';\n\nexport const TestIds = {\n APP_OPEN: '',\n BANNER: '',\n INTERSTITIAL: '',\n REWARDED: '',\n GAM_APP_OPEN: '/6499/example/app-open',\n GAM_BANNER: '/6499/example/banner',\n GAM_INTERSTITIAL: '/6499/example/interstitial',\n GAM_REWARDED: '/6499/example/rewarded',\n GAM_NATIVE: '/6499/example/native',\n ...Platform.select({\n android: {\n APP_OPEN: 'ca-app-pub-3940256099942544/3419835294',\n BANNER: 'ca-app-pub-3940256099942544/6300978111',\n INTERSTITIAL: 'ca-app-pub-3940256099942544/1033173712',\n REWARDED: 'ca-app-pub-3940256099942544/5224354917',\n },\n ios: {\n APP_OPEN: 'ca-app-pub-3940256099942544/5662855259',\n BANNER: 'ca-app-pub-3940256099942544/2934735716',\n INTERSTITIAL: 'ca-app-pub-3940256099942544/4411468910',\n REWARDED: 'ca-app-pub-3940256099942544/1712485313',\n },\n }),\n};\n"]}
1
+ {"version":3,"sources":["TestIds.ts"],"names":["Platform","TestIds","APP_OPEN","BANNER","INTERSTITIAL","REWARDED","REWARDED_INTERSTITIAL","GAM_APP_OPEN","GAM_BANNER","GAM_INTERSTITIAL","GAM_REWARDED","GAM_REWARDED_INTERSTITIAL","GAM_NATIVE","select","android","ios"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,QAAT,QAAyB,cAAzB;AAEA,OAAO,MAAMC,OAAO,GAAG;AACrBC,EAAAA,QAAQ,EAAE,EADW;AAErBC,EAAAA,MAAM,EAAE,EAFa;AAGrBC,EAAAA,YAAY,EAAE,EAHO;AAIrBC,EAAAA,QAAQ,EAAE,EAJW;AAKrBC,EAAAA,qBAAqB,EAAE,EALF;AAMrBC,EAAAA,YAAY,EAAE,wBANO;AAOrBC,EAAAA,UAAU,EAAE,sBAPS;AAQrBC,EAAAA,gBAAgB,EAAE,4BARG;AASrBC,EAAAA,YAAY,EAAE,wBATO;AAUrBC,EAAAA,yBAAyB,EAAE,4CAVN;AAWrBC,EAAAA,UAAU,EAAE,sBAXS;AAYrB,KAAGZ,QAAQ,CAACa,MAAT,CAAgB;AACjBC,IAAAA,OAAO,EAAE;AACPZ,MAAAA,QAAQ,EAAE,wCADH;AAEPC,MAAAA,MAAM,EAAE,wCAFD;AAGPC,MAAAA,YAAY,EAAE,wCAHP;AAIPC,MAAAA,QAAQ,EAAE,wCAJH;AAKPC,MAAAA,qBAAqB,EAAE;AALhB,KADQ;AAQjBS,IAAAA,GAAG,EAAE;AACHb,MAAAA,QAAQ,EAAE,wCADP;AAEHC,MAAAA,MAAM,EAAE,wCAFL;AAGHC,MAAAA,YAAY,EAAE,wCAHX;AAIHC,MAAAA,QAAQ,EAAE,wCAJP;AAKHC,MAAAA,qBAAqB,EAAE;AALpB;AARY,GAAhB;AAZkB,CAAhB","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 { Platform } from 'react-native';\n\nexport const TestIds = {\n APP_OPEN: '',\n BANNER: '',\n INTERSTITIAL: '',\n REWARDED: '',\n REWARDED_INTERSTITIAL: '',\n GAM_APP_OPEN: '/6499/example/app-open',\n GAM_BANNER: '/6499/example/banner',\n GAM_INTERSTITIAL: '/6499/example/interstitial',\n GAM_REWARDED: '/6499/example/rewarded',\n GAM_REWARDED_INTERSTITIAL: '/21775744923/example/rewarded_interstitial',\n GAM_NATIVE: '/6499/example/native',\n ...Platform.select({\n android: {\n APP_OPEN: 'ca-app-pub-3940256099942544/3419835294',\n BANNER: 'ca-app-pub-3940256099942544/6300978111',\n INTERSTITIAL: 'ca-app-pub-3940256099942544/1033173712',\n REWARDED: 'ca-app-pub-3940256099942544/5224354917',\n REWARDED_INTERSTITIAL: 'ca-app-pub-3940256099942544/5354046379',\n },\n ios: {\n APP_OPEN: 'ca-app-pub-3940256099942544/5662855259',\n BANNER: 'ca-app-pub-3940256099942544/2934735716',\n INTERSTITIAL: 'ca-app-pub-3940256099942544/4411468910',\n REWARDED: 'ca-app-pub-3940256099942544/1712485313',\n REWARDED_INTERSTITIAL: 'ca-app-pub-3940256099942544/6978759866',\n },\n }),\n};\n"]}
@@ -144,6 +144,20 @@ export class MobileAd {
144
144
  return this.constructor.name;
145
145
  }
146
146
 
147
+ get _camelCaseType() {
148
+ let type;
149
+
150
+ if (this._type === 'app_open') {
151
+ type = 'appOpen';
152
+ } else if (this._type === 'rewarded_interstitial') {
153
+ type = 'rewardedInterstitial';
154
+ } else {
155
+ type = this._type;
156
+ }
157
+
158
+ return type;
159
+ }
160
+
147
161
  load() {
148
162
  // Prevent multiple load calls
149
163
  if (this._loaded || this._isLoadCalled) {
@@ -151,8 +165,7 @@ export class MobileAd {
151
165
  }
152
166
 
153
167
  this._isLoadCalled = true;
154
- const type = this._type === 'app_open' ? 'appOpen' : this._type;
155
- const load = this._googleMobileAds.native[`${type}Load`];
168
+ const load = this._googleMobileAds.native[`${this._camelCaseType}Load`];
156
169
  load(this._requestId, this._adUnitId, this._requestOptions);
157
170
  }
158
171
 
@@ -173,8 +186,7 @@ export class MobileAd {
173
186
  }
174
187
  }
175
188
 
176
- const type = this._type === 'app_open' ? 'appOpen' : this._type;
177
- const show = this._googleMobileAds.native[`${type}Show`];
189
+ const show = this._googleMobileAds.native[`${this._camelCaseType}Show`];
178
190
  return show(this._requestId, this._adUnitId, options);
179
191
  }
180
192
 
@@ -1 +1 @@
1
- {"version":3,"sources":["MobileAd.ts"],"names":["isFunction","isOneOf","NativeError","AdEventType","RewardedAdEventType","GAMAdEventType","validateAdShowOptions","MobileAd","constructor","type","googleMobileAds","requestId","adUnitId","requestOptions","_type","_googleMobileAds","_requestId","_adUnitId","_requestOptions","_loaded","_isLoadCalled","_adEventsListeners","Map","_adEventListenersMap","Object","values","_","LOADED","forEach","set","_adEventListenerId","_adEventsListenerId","_nativeListener","emitter","addListener","_handleAdEvent","bind","event","error","data","body","CLOSED","payload","fromEvent","listener","_getAdEventListeners","_addAdEventsListener","Error","_className","id","delete","_addAdEventListener","get","name","load","native","show","showOptions","options","e","message","removeAllListeners","clear","map","loaded"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,SAASA,UAAT,EAAqBC,OAArB,QAAoC,WAApC;AACA,SAASC,WAAT,QAA4B,yBAA5B;AACA,SAASC,WAAT,QAA4B,gBAA5B;AACA,SAASC,mBAAT,QAAoC,wBAApC;AAQA,SAASC,cAAT,QAA+B,mBAA/B;AAEA,SAASC,qBAAT,QAAsC,0BAAtC;AAIA,OAAO,MAAeC,QAAf,CAAqD;AAchDC,EAAAA,WAAW,CACnBC,IADmB,EAEnBC,eAFmB,EAGnBC,SAHmB,EAInBC,QAJmB,EAKnBC,cALmB,EAMnB;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AACA,SAAKC,KAAL,GAAaL,IAAb;AACA,SAAKM,gBAAL,GAAwBL,eAAxB;AACA,SAAKM,UAAL,GAAkBL,SAAlB;AACA,SAAKM,SAAL,GAAiBL,QAAjB;AACA,SAAKM,eAAL,GAAuBL,cAAvB;AAEA,SAAKM,OAAL,GAAe,KAAf;AACA,SAAKC,aAAL,GAAqB,KAArB;AACA,SAAKC,kBAAL,GAA0B,IAAIC,GAAJ,EAA1B;AACA,SAAKC,oBAAL,GAA4B,IAAID,GAAJ,EAA5B;AACAE,IAAAA,MAAM,CAACC,MAAP,CAAc,EACZ,GAAGtB,WADS;AAEZ,SAAGC,mBAFS;AAGZ,SAAGC,cAHS;AAIZqB,MAAAA,CAAC,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MG,EAAAA,kBAAkB,GAAG;AAC1B,SAAKxC,kBAAL,CAAwByC,KAAxB;;AACA,SAAKvC,oBAAL,CAA0BK,OAA1B,CAAkC,CAACF,CAAD,EAAIjB,IAAJ,EAAUsD,GAAV,KAAkB;AAClDA,MAAAA,GAAG,CAAClC,GAAJ,CAAQpB,IAAR,EAAc,IAAIa,GAAJ,EAAd;AACD,KAFD;AAGD;;AAEkB,MAARV,QAAQ,GAAG;AACpB,WAAO,KAAKK,SAAZ;AACD;;AAEgB,MAAN+C,MAAM,GAAG;AAClB,WAAO,KAAK7C,OAAZ;AACD;;AAjLyD","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 { EmitterSubscription } from 'react-native';\nimport { isFunction, isOneOf } from '../common';\nimport { NativeError } from '../internal/NativeError';\nimport { AdEventType } from '../AdEventType';\nimport { RewardedAdEventType } from '../RewardedAdEventType';\nimport { AdEventListener, AdEventPayload } from '../types/AdEventListener';\nimport { AdEventsListener } from '../types/AdEventsListener';\nimport { AdShowOptions } from '../types/AdShowOptions';\nimport { RequestOptions } from '../types/RequestOptions';\nimport { MobileAdInterface } from '../types/MobileAd.interface';\nimport { MobileAdsModuleInterface } from '../types/MobileAdsModule.interface';\nimport { RewardedAdReward } from '../types/RewardedAdReward';\nimport { GAMAdEventType } from '../GAMAdEventType';\nimport { AppEvent } from '../types/AppEvent';\nimport { validateAdShowOptions } from '../validateAdShowOptions';\n\ntype EventType = AdEventType | RewardedAdEventType | GAMAdEventType;\n\nexport abstract class MobileAd implements MobileAdInterface {\n protected _type: 'app_open' | 'interstitial' | 'rewarded';\n protected _googleMobileAds: MobileAdsModuleInterface;\n protected _requestId: number;\n protected _adUnitId: string;\n protected _requestOptions: RequestOptions;\n protected _loaded: boolean;\n protected _isLoadCalled: boolean;\n protected _adEventsListeners: Map<number, AdEventsListener<EventType>>;\n protected _adEventListenersMap: Map<EventType, Map<number, AdEventListener<EventType>>>;\n protected _adEventsListenerId: number;\n protected _adEventListenerId: number;\n protected _nativeListener: EmitterSubscription;\n\n protected constructor(\n type: 'app_open' | 'interstitial' | 'rewarded',\n googleMobileAds: MobileAdsModuleInterface,\n requestId: number,\n adUnitId: string,\n requestOptions: RequestOptions,\n ) {\n this._type = type;\n this._googleMobileAds = googleMobileAds;\n this._requestId = requestId;\n this._adUnitId = adUnitId;\n this._requestOptions = requestOptions;\n\n this._loaded = false;\n this._isLoadCalled = false;\n this._adEventsListeners = new Map();\n this._adEventListenersMap = new Map();\n Object.values({\n ...AdEventType,\n ...RewardedAdEventType,\n ...GAMAdEventType,\n _: AdEventType.LOADED, // since AdEventType.LOADED is overwritten by RewardedAdEventType.LOADED\n }).forEach(type => {\n this._adEventListenersMap.set(type as EventType, new Map());\n });\n this._adEventListenerId = 0;\n this._adEventsListenerId = 0;\n\n this._nativeListener = googleMobileAds.emitter.addListener(\n `google_mobile_ads_${type}_event:${adUnitId}:${requestId}`,\n this._handleAdEvent.bind(this),\n );\n }\n\n protected _handleAdEvent(event: {\n body: {\n type: EventType;\n error?: { code: string; message: string };\n data?: RewardedAdReward | AppEvent;\n };\n }) {\n const { type, error, data } = event.body;\n\n if (type === AdEventType.LOADED || type === RewardedAdEventType.LOADED) {\n this._loaded = true;\n }\n\n if (type === AdEventType.CLOSED) {\n this._loaded = false;\n this._isLoadCalled = false;\n }\n\n let payload: AdEventPayload<EventType> = data;\n if (error) {\n payload = NativeError.fromEvent(error, 'googleMobileAds');\n }\n this._adEventsListeners.forEach(listener => {\n listener({\n type,\n payload,\n });\n });\n this._getAdEventListeners(type).forEach(listener => {\n listener(payload);\n });\n }\n\n protected _addAdEventsListener<T extends EventType>(listener: AdEventsListener<T>) {\n if (!isFunction(listener)) {\n throw new Error(`${this._className}.addAdEventsListener(*) 'listener' expected a function.`);\n }\n\n const id = this._adEventsListenerId++;\n this._adEventsListeners.set(id, listener as AdEventsListener<EventType>);\n return () => {\n this._adEventsListeners.delete(id);\n };\n }\n\n protected _addAdEventListener<T extends EventType>(type: T, listener: AdEventListener<T>) {\n if (\n !(\n isOneOf(type, Object.values(AdEventType)) ||\n (isOneOf(type, Object.values(RewardedAdEventType)) && this._type === 'rewarded')\n )\n ) {\n throw new Error(\n `${this._className}.addAdEventListener(*) 'type' expected a valid event type value.`,\n );\n }\n if (!isFunction(listener)) {\n throw new Error(\n `${this._className}.addAdEventListener(_, *) 'listener' expected a function.`,\n );\n }\n\n const id = this._adEventListenerId++;\n this._getAdEventListeners(type).set(id, listener);\n return () => {\n this._getAdEventListeners(type).delete(id);\n };\n }\n\n protected _getAdEventListeners<T extends EventType>(type: T) {\n return this._adEventListenersMap.get(type) as Map<number, AdEventListener<T>>;\n }\n\n protected get _className() {\n return this.constructor.name;\n }\n\n public load() {\n // Prevent multiple load calls\n if (this._loaded || this._isLoadCalled) {\n return;\n }\n\n this._isLoadCalled = true;\n const type = this._type === 'app_open' ? 'appOpen' : this._type;\n const load = this._googleMobileAds.native[`${type}Load`];\n load(this._requestId, this._adUnitId, this._requestOptions);\n }\n\n public show(showOptions?: AdShowOptions) {\n if (!this._loaded) {\n throw new Error(\n `${this._className}.show() The requested ${this._className} 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(`${this._className}.show(*) ${e.message}.`);\n } else {\n throw e;\n }\n }\n\n const type = this._type === 'app_open' ? 'appOpen' : this._type;\n const show = this._googleMobileAds.native[`${type}Show`];\n return show(this._requestId, this._adUnitId, options);\n }\n\n public abstract addAdEventsListener<T extends never>(listener: AdEventsListener<T>): () => void;\n\n public abstract addAdEventListener<T extends never>(type: T, listener: AdEventListener<T>): void;\n\n public removeAllListeners() {\n this._adEventsListeners.clear();\n this._adEventListenersMap.forEach((_, type, map) => {\n map.set(type, new Map());\n });\n }\n\n public get adUnitId() {\n return this._adUnitId;\n }\n\n public get loaded() {\n return this._loaded;\n }\n}\n"]}
1
+ {"version":3,"sources":["MobileAd.ts"],"names":["isFunction","isOneOf","NativeError","AdEventType","RewardedAdEventType","GAMAdEventType","validateAdShowOptions","MobileAd","constructor","type","googleMobileAds","requestId","adUnitId","requestOptions","_type","_googleMobileAds","_requestId","_adUnitId","_requestOptions","_loaded","_isLoadCalled","_adEventsListeners","Map","_adEventListenersMap","Object","values","_","LOADED","forEach","set","_adEventListenerId","_adEventsListenerId","_nativeListener","emitter","addListener","_handleAdEvent","bind","event","error","data","body","CLOSED","payload","fromEvent","listener","_getAdEventListeners","_addAdEventsListener","Error","_className","id","delete","_addAdEventListener","get","name","_camelCaseType","load","native","show","showOptions","options","e","message","removeAllListeners","clear","map","loaded"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,SAASA,UAAT,EAAqBC,OAArB,QAAoC,WAApC;AACA,SAASC,WAAT,QAA4B,yBAA5B;AACA,SAASC,WAAT,QAA4B,gBAA5B;AACA,SAASC,mBAAT,QAAoC,wBAApC;AAQA,SAASC,cAAT,QAA+B,mBAA/B;AAEA,SAASC,qBAAT,QAAsC,0BAAtC;AAIA,OAAO,MAAeC,QAAf,CAAqD;AAchDC,EAAAA,WAAW,CACnBC,IADmB,EAEnBC,eAFmB,EAGnBC,SAHmB,EAInBC,QAJmB,EAKnBC,cALmB,EAMnB;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AACA,SAAKC,KAAL,GAAaL,IAAb;AACA,SAAKM,gBAAL,GAAwBL,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wB,KAAKA,UAAW,yCADvD,CAAN;AAGD;;AAED,QAAIW,OAAJ;;AACA,QAAI;AACFA,MAAAA,OAAO,GAAGrD,qBAAqB,CAACoD,WAAD,CAA/B;AACD,KAFD,CAEE,OAAOE,CAAP,EAAU;AACV,UAAIA,CAAC,YAAYb,KAAjB,EAAwB;AACtB,cAAM,IAAIA,KAAJ,CAAW,GAAE,KAAKC,UAAW,YAAWY,CAAC,CAACC,OAAQ,GAAlD,CAAN;AACD,OAFD,MAEO;AACL,cAAMD,CAAN;AACD;AACF;;AAED,UAAMH,IAAI,GAAG,KAAK1C,gBAAL,CAAsByC,MAAtB,CAA8B,GAAE,KAAKF,cAAe,MAApD,CAAb;AACA,WAAOG,IAAI,CAAC,KAAKzC,UAAN,EAAkB,KAAKC,SAAvB,EAAkC0C,OAAlC,CAAX;AACD;;AAMMG,EAAAA,kBAAkB,GAAG;AAC1B,SAAKzC,kBAAL,CAAwB0C,KAAxB;;AACA,SAAKxC,oBAAL,CAA0BK,OAA1B,CAAkC,CAACF,CAAD,EAAIjB,IAAJ,EAAUuD,GAAV,KAAkB;AAClDA,MAAAA,GAAG,CAACnC,GAAJ,CAAQpB,IAAR,EAAc,IAAIa,GAAJ,EAAd;AACD,KAFD;AAGD;;AAEkB,MAARV,QAAQ,GAAG;AACpB,WAAO,KAAKK,SAAZ;AACD;;AAEgB,MAANgD,MAAM,GAAG;AAClB,WAAO,KAAK9C,OAAZ;AACD;;AA3LyD","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 { EmitterSubscription } from 'react-native';\nimport { isFunction, isOneOf } from '../common';\nimport { NativeError } from '../internal/NativeError';\nimport { AdEventType } from '../AdEventType';\nimport { RewardedAdEventType } from '../RewardedAdEventType';\nimport { AdEventListener, AdEventPayload } from '../types/AdEventListener';\nimport { AdEventsListener } from '../types/AdEventsListener';\nimport { AdShowOptions } from '../types/AdShowOptions';\nimport { RequestOptions } from '../types/RequestOptions';\nimport { MobileAdInterface } from '../types/MobileAd.interface';\nimport { MobileAdsModuleInterface } from '../types/MobileAdsModule.interface';\nimport { RewardedAdReward } from '../types/RewardedAdReward';\nimport { GAMAdEventType } from '../GAMAdEventType';\nimport { AppEvent } from '../types/AppEvent';\nimport { validateAdShowOptions } from '../validateAdShowOptions';\n\ntype EventType = AdEventType | RewardedAdEventType | GAMAdEventType;\n\nexport abstract class MobileAd implements MobileAdInterface {\n protected _type: 'app_open' | 'interstitial' | 'rewarded' | 'rewarded_interstitial';\n protected _googleMobileAds: MobileAdsModuleInterface;\n protected _requestId: number;\n protected _adUnitId: string;\n protected _requestOptions: RequestOptions;\n protected _loaded: boolean;\n protected _isLoadCalled: boolean;\n protected _adEventsListeners: Map<number, AdEventsListener<EventType>>;\n protected _adEventListenersMap: Map<EventType, Map<number, AdEventListener<EventType>>>;\n protected _adEventsListenerId: number;\n protected _adEventListenerId: number;\n protected _nativeListener: EmitterSubscription;\n\n protected constructor(\n type: 'app_open' | 'interstitial' | 'rewarded' | 'rewarded_interstitial',\n googleMobileAds: MobileAdsModuleInterface,\n requestId: number,\n adUnitId: string,\n requestOptions: RequestOptions,\n ) {\n this._type = type;\n this._googleMobileAds = googleMobileAds;\n this._requestId = requestId;\n this._adUnitId = adUnitId;\n this._requestOptions = requestOptions;\n\n this._loaded = false;\n this._isLoadCalled = false;\n this._adEventsListeners = new Map();\n this._adEventListenersMap = new Map();\n Object.values({\n ...AdEventType,\n ...RewardedAdEventType,\n ...GAMAdEventType,\n _: AdEventType.LOADED, // since AdEventType.LOADED is overwritten by RewardedAdEventType.LOADED\n }).forEach(type => {\n this._adEventListenersMap.set(type as EventType, new Map());\n });\n this._adEventListenerId = 0;\n this._adEventsListenerId = 0;\n\n this._nativeListener = googleMobileAds.emitter.addListener(\n `google_mobile_ads_${type}_event:${adUnitId}:${requestId}`,\n this._handleAdEvent.bind(this),\n );\n }\n\n protected _handleAdEvent(event: {\n body: {\n type: EventType;\n error?: { code: string; message: string };\n data?: RewardedAdReward | AppEvent;\n };\n }) {\n const { type, error, data } = event.body;\n\n if (type === AdEventType.LOADED || type === RewardedAdEventType.LOADED) {\n this._loaded = true;\n }\n\n if (type === AdEventType.CLOSED) {\n this._loaded = false;\n this._isLoadCalled = false;\n }\n\n let payload: AdEventPayload<EventType> = data;\n if (error) {\n payload = NativeError.fromEvent(error, 'googleMobileAds');\n }\n this._adEventsListeners.forEach(listener => {\n listener({\n type,\n payload,\n });\n });\n this._getAdEventListeners(type).forEach(listener => {\n listener(payload);\n });\n }\n\n protected _addAdEventsListener<T extends EventType>(listener: AdEventsListener<T>) {\n if (!isFunction(listener)) {\n throw new Error(`${this._className}.addAdEventsListener(*) 'listener' expected a function.`);\n }\n\n const id = this._adEventsListenerId++;\n this._adEventsListeners.set(id, listener as AdEventsListener<EventType>);\n return () => {\n this._adEventsListeners.delete(id);\n };\n }\n\n protected _addAdEventListener<T extends EventType>(type: T, listener: AdEventListener<T>) {\n if (\n !(\n isOneOf(type, Object.values(AdEventType)) ||\n (isOneOf(type, Object.values(RewardedAdEventType)) && this._type === 'rewarded')\n )\n ) {\n throw new Error(\n `${this._className}.addAdEventListener(*) 'type' expected a valid event type value.`,\n );\n }\n if (!isFunction(listener)) {\n throw new Error(\n `${this._className}.addAdEventListener(_, *) 'listener' expected a function.`,\n );\n }\n\n const id = this._adEventListenerId++;\n this._getAdEventListeners(type).set(id, listener);\n return () => {\n this._getAdEventListeners(type).delete(id);\n };\n }\n\n protected _getAdEventListeners<T extends EventType>(type: T) {\n return this._adEventListenersMap.get(type) as Map<number, AdEventListener<T>>;\n }\n\n protected get _className() {\n return this.constructor.name;\n }\n\n protected get _camelCaseType() {\n let type: 'appOpen' | 'interstitial' | 'rewarded' | 'rewardedInterstitial';\n if (this._type === 'app_open') {\n type = 'appOpen';\n } else if (this._type === 'rewarded_interstitial') {\n type = 'rewardedInterstitial';\n } else {\n type = this._type;\n }\n return type;\n }\n\n public load() {\n // Prevent multiple load calls\n if (this._loaded || this._isLoadCalled) {\n return;\n }\n\n this._isLoadCalled = true;\n const load = this._googleMobileAds.native[`${this._camelCaseType}Load`];\n load(this._requestId, this._adUnitId, this._requestOptions);\n }\n\n public show(showOptions?: AdShowOptions) {\n if (!this._loaded) {\n throw new Error(\n `${this._className}.show() The requested ${this._className} 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(`${this._className}.show(*) ${e.message}.`);\n } else {\n throw e;\n }\n }\n\n const show = this._googleMobileAds.native[`${this._camelCaseType}Show`];\n return show(this._requestId, this._adUnitId, options);\n }\n\n public abstract addAdEventsListener<T extends never>(listener: AdEventsListener<T>): () => void;\n\n public abstract addAdEventListener<T extends never>(type: T, listener: AdEventListener<T>): void;\n\n public removeAllListeners() {\n this._adEventsListeners.clear();\n this._adEventListenersMap.forEach((_, type, map) => {\n map.set(type, new Map());\n });\n }\n\n public get adUnitId() {\n return this._adUnitId;\n }\n\n public get loaded() {\n return this._loaded;\n }\n}\n"]}
@@ -0,0 +1,130 @@
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
+
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 { isString } from '../common';
20
+ import { MobileAds } from '../MobileAds';
21
+ import { validateAdRequestOptions } from '../validateAdRequestOptions';
22
+ import { MobileAd } from './MobileAd';
23
+ import { AdEventType } from '../AdEventType';
24
+
25
+ /**
26
+ * A class for interacting and showing Rewarded Interstitial Ads.
27
+ *
28
+ * An Rewarded Interstitial advert can be pre-loaded and shown at a suitable point in your apps flow, such as at the end of a level
29
+ * in a game. The content of a rewarded interstital advert can be controlled via your Google Mobile Ads dashboard. Typically users are rewarded
30
+ * after completing a specific advert action (e.g. watching a video or submitting an option via an interactive form).
31
+ * Events (such as the user earning a reward or closing a rewarded interstital advert early) are sent back for you to handle accordingly
32
+ * within your application.
33
+ *
34
+ * #### Example
35
+ *
36
+ * First create a new Rewarded Interstitial instance, passing in your Ad Unit ID from the Google Mobile Ads configuration console, and any additional
37
+ * request options. The example below will present a test advert, and only request a non-personalized ad.
38
+ *
39
+ * ```js
40
+ * import { RewardedInterstitialAd, TestIds } from 'react-native-google-mobile-ads';
41
+ *
42
+ * const rewardedInterstitial = RewardedInterstitialAd.createForAdRequest(TestIds.REWARDED_INTERSTITIAL, {
43
+ * requestNonPersonalizedAdsOnly: true,
44
+ * });
45
+ * ```
46
+ *
47
+ * Each advert needs to be loaded from Google Mobile Ads before being shown. It is recommended this is performed before the user
48
+ * reaches the checkpoint to show the advert, so it's ready to go. Before loading the advert, we need to setup
49
+ * event listeners to listen for updates from Google Mobile Ads, such as advert loaded or failed to load.
50
+ *
51
+ * Event types match the `AdEventType` or `RewardedAdEventType` interface. The potential user reward for rewarded interstitial
52
+ * adverts are passed back to the event handler on advert load and when the user earns the reward.
53
+ *
54
+ * ```js
55
+ * import { RewardedAdEventType } from 'react-native-google-mobile-ads';
56
+ *
57
+ * rewardedInterstitial.addAdEventListener(RewardedAdEventType.LOADED. () => {
58
+ * rewarded.show();
59
+ * });
60
+ * rewardedInterstitial.addAdEventListener(RewardedAdEventType.EARNED_REWARD. (reward) => {
61
+ * console.log('User earned reward of ', reward);
62
+ * });
63
+ *
64
+ * rewardedInterstitial.load();
65
+ * ```
66
+ *
67
+ * The rewarded interstitial advert will be presented to the user, and several more events can be triggered such as the user clicking the
68
+ * advert, closing it or completing the action.
69
+ */
70
+ export class RewardedInterstitialAd extends MobileAd {
71
+ /**
72
+ * Creates a new RewardedInterstitialAd instance.
73
+ *
74
+ * #### Example
75
+ *
76
+ * ```js
77
+ * import { RewardedInterstitialAd, RewardedAdEventType, TestIds } from 'react-native-google-mobile-ads';
78
+ *
79
+ * const rewardedInterstitialAd = await RewardedInterstitialAd.createForAdRequest(TestIds.REWARDED_INTERSTITIAL, {
80
+ * requestAgent: 'CoolAds',
81
+ * });
82
+ *
83
+ * rewardedInterstitialAd.addAdEventListener(RewardedAdEventType.LOADED. () => {
84
+ * rewardedInterstitialAd.show();
85
+ * });
86
+ * rewardedInterstitialAd.addAdEventListener(RewardedAdEventType.EARNED_REWARD. (reward) => {
87
+ * console.log('User earned reward of ', reward);
88
+ * });
89
+ *
90
+ * rewardedInterstitialAd.load();
91
+ * ```
92
+ *
93
+ * @param adUnitId The Ad Unit ID for the Rewarded Interstitial Ad. You can find this on your Google Mobile Ads dashboard.
94
+ * @param requestOptions Optional RequestOptions used to load the ad.
95
+ */
96
+ static createForAdRequest(adUnitId, requestOptions) {
97
+ if (!isString(adUnitId)) {
98
+ throw new Error("RewardedInterstitialAd.createForAdRequest(*) 'adUnitId' expected an string value.");
99
+ }
100
+
101
+ let options = {};
102
+
103
+ try {
104
+ options = validateAdRequestOptions(requestOptions);
105
+ } catch (e) {
106
+ if (e instanceof Error) {
107
+ throw new Error(`RewardedInterstitialAd.createForAdRequest(_, *) ${e.message}.`);
108
+ }
109
+ }
110
+
111
+ const requestId = RewardedInterstitialAd._rewardedInterstitialRequest++;
112
+ return new RewardedInterstitialAd('rewarded_interstitial', MobileAds(), requestId, adUnitId, options);
113
+ }
114
+
115
+ addAdEventsListener(listener) {
116
+ return this._addAdEventsListener(listener);
117
+ }
118
+
119
+ addAdEventListener(type, listener) {
120
+ if (type === AdEventType.LOADED) {
121
+ throw new Error('RewardedInterstitialAd.addAdEventListener(*) use RewardedAdEventType.LOADED instead of AdEventType.LOADED.');
122
+ }
123
+
124
+ return this._addAdEventListener(type, listener);
125
+ }
126
+
127
+ }
128
+
129
+ _defineProperty(RewardedInterstitialAd, "_rewardedInterstitialRequest", 0);
130
+ //# sourceMappingURL=RewardedInterstitialAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["RewardedInterstitialAd.ts"],"names":["isString","MobileAds","validateAdRequestOptions","MobileAd","AdEventType","RewardedInterstitialAd","createForAdRequest","adUnitId","requestOptions","Error","options","e","message","requestId","_rewardedInterstitialRequest","addAdEventsListener","listener","_addAdEventsListener","addAdEventListener","type","LOADED","_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;AACA,SAASC,WAAT,QAA4B,gBAA5B;;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;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAN,SAAqCF,QAArC,CAA8C;AAEnD;AACF;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,EAAoD;AAC3E,QAAI,CAACR,QAAQ,CAACO,QAAD,CAAb,EAAyB;AACvB,YAAM,IAAIE,KAAJ,CACJ,mFADI,CAAN;AAGD;;AAED,QAAIC,OAAO,GAAG,EAAd;;AACA,QAAI;AACFA,MAAAA,OAAO,GAAGR,wBAAwB,CAACM,cAAD,CAAlC;AACD,KAFD,CAEE,OAAOG,CAAP,EAAU;AACV,UAAIA,CAAC,YAAYF,KAAjB,EAAwB;AACtB,cAAM,IAAIA,KAAJ,CAAW,mDAAkDE,CAAC,CAACC,OAAQ,GAAvE,CAAN;AACD;AACF;;AAED,UAAMC,SAAS,GAAGR,sBAAsB,CAACS,4BAAvB,EAAlB;AACA,WAAO,IAAIT,sBAAJ,CACL,uBADK,EAELJ,SAAS,EAFJ,EAGLY,SAHK,EAILN,QAJK,EAKLG,OALK,CAAP;AAOD;;AAEDK,EAAAA,mBAAmB,CACjBC,QADiB,EAEL;AACZ,WAAO,KAAKC,oBAAL,CAA0BD,QAA1B,CAAP;AACD;;AAEDE,EAAAA,kBAAkB,CAChBC,IADgB,EAEhBH,QAFgB,EAGhB;AACA,QAAIG,IAAI,KAAKf,WAAW,CAACgB,MAAzB,EAAiC;AAC/B,YAAM,IAAIX,KAAJ,CACJ,4GADI,CAAN;AAGD;;AACD,WAAO,KAAKY,mBAAL,CAAyBF,IAAzB,EAA+BH,QAA/B,CAAP;AACD;;AArEkD;;gBAAxCX,sB,kCACqC,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 { RewardedAdEventType } from '../RewardedAdEventType';\nimport { AdEventListener } from '../types/AdEventListener';\nimport { AdEventsListener } from '../types/AdEventsListener';\nimport { RequestOptions } from '../types/RequestOptions';\n\n/**\n * A class for interacting and showing Rewarded Interstitial Ads.\n *\n * An Rewarded 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. The content of a rewarded interstital advert can be controlled via your Google Mobile Ads dashboard. Typically users are rewarded\n * after completing a specific advert action (e.g. watching a video or submitting an option via an interactive form).\n * Events (such as the user earning a reward or closing a rewarded interstital advert early) are sent back for you to handle accordingly\n * within your application.\n *\n * #### Example\n *\n * First create a new Rewarded 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 { RewardedInterstitialAd, TestIds } from 'react-native-google-mobile-ads';\n *\n * const rewardedInterstitial = RewardedInterstitialAd.createForAdRequest(TestIds.REWARDED_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` or `RewardedAdEventType` interface. The potential user reward for rewarded interstitial\n * adverts are passed back to the event handler on advert load and when the user earns the reward.\n *\n * ```js\n * import { RewardedAdEventType } from 'react-native-google-mobile-ads';\n *\n * rewardedInterstitial.addAdEventListener(RewardedAdEventType.LOADED. () => {\n * rewarded.show();\n * });\n * rewardedInterstitial.addAdEventListener(RewardedAdEventType.EARNED_REWARD. (reward) => {\n * console.log('User earned reward of ', reward);\n * });\n *\n * rewardedInterstitial.load();\n * ```\n *\n * The rewarded interstitial advert will be presented to the user, and several more events can be triggered such as the user clicking the\n * advert, closing it or completing the action.\n */\nexport class RewardedInterstitialAd extends MobileAd {\n protected static _rewardedInterstitialRequest = 0;\n /**\n * Creates a new RewardedInterstitialAd instance.\n *\n * #### Example\n *\n * ```js\n * import { RewardedInterstitialAd, RewardedAdEventType, TestIds } from 'react-native-google-mobile-ads';\n *\n * const rewardedInterstitialAd = await RewardedInterstitialAd.createForAdRequest(TestIds.REWARDED_INTERSTITIAL, {\n * requestAgent: 'CoolAds',\n * });\n *\n * rewardedInterstitialAd.addAdEventListener(RewardedAdEventType.LOADED. () => {\n * rewardedInterstitialAd.show();\n * });\n * rewardedInterstitialAd.addAdEventListener(RewardedAdEventType.EARNED_REWARD. (reward) => {\n * console.log('User earned reward of ', reward);\n * });\n *\n * rewardedInterstitialAd.load();\n * ```\n *\n * @param adUnitId The Ad Unit ID for the Rewarded Interstitial Ad. 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(\n \"RewardedInterstitialAd.createForAdRequest(*) 'adUnitId' expected an string value.\",\n );\n }\n\n let options = {};\n try {\n options = validateAdRequestOptions(requestOptions);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`RewardedInterstitialAd.createForAdRequest(_, *) ${e.message}.`);\n }\n }\n\n const requestId = RewardedInterstitialAd._rewardedInterstitialRequest++;\n return new RewardedInterstitialAd(\n 'rewarded_interstitial',\n MobileAds(),\n requestId,\n adUnitId,\n options,\n );\n }\n\n addAdEventsListener<T extends AdEventType | RewardedAdEventType>(\n listener: AdEventsListener<T>,\n ): () => void {\n return this._addAdEventsListener(listener);\n }\n\n addAdEventListener<T extends AdEventType | RewardedAdEventType>(\n type: T,\n listener: AdEventListener<T>,\n ) {\n if (type === AdEventType.LOADED) {\n throw new Error(\n 'RewardedInterstitialAd.addAdEventListener(*) use RewardedAdEventType.LOADED instead of AdEventType.LOADED.',\n );\n }\n return this._addAdEventListener(type, listener);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["useFullScreenAd.ts"],"names":["useCallback","useEffect","useReducer","AdEventType","RewardedAdEventType","initialState","isLoaded","isOpened","isClicked","isClosed","error","undefined","reward","isEarnedReward","useFullScreenAd","ad","state","setState","prevState","newState","isShowing","load","show","showOptions","unsubscribe","addAdEventsListener","type","payload","LOADED","OPENED","CLOSED","CLICKED","ERROR","EARNED_REWARD"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAAkBA,WAAlB,EAA+BC,SAA/B,EAA0CC,UAA1C,QAA4D,OAA5D;AAEA,SAASC,WAAT,QAA4B,gBAA5B;AAIA,SAASC,mBAAT,QAAoC,wBAApC;AAKA,MAAMC,YAAsB,GAAG;AAC7BC,EAAAA,QAAQ,EAAE,KADmB;AAE7BC,EAAAA,QAAQ,EAAE,KAFmB;AAG7BC,EAAAA,SAAS,EAAE,KAHkB;AAI7BC,EAAAA,QAAQ,EAAE,KAJmB;AAK7BC,EAAAA,KAAK,EAAEC,SALsB;AAM7BC,EAAAA,MAAM,EAAED,SANqB;AAO7BE,EAAAA,cAAc,EAAE;AAPa,CAA/B;AAUA,OAAO,SAASC,eAAT,CACLC,EADK,EAEU;AACf,QAAM,CAACC,KAAD,EAAQC,QAAR,IAAoBf,UAAU,CAClC,CAACgB,SAAD,EAAYC,QAAZ,MAA0B,EAAE,GAAGD,SAAL;AAAgB,OAAGC;AAAnB,GAA1B,CADkC,EAElCd,YAFkC,CAApC;AAIA,QAAMe,SAAS,GAAGJ,KAAK,CAACT,QAAN,IAAkB,CAACS,KAAK,CAACP,QAA3C;AAEA,QAAMY,IAAI,GAAGrB,WA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AAAA,QAAQ,EAAE,IAAZ;AAAkBM,YAAAA,MAAM,EAAEe;AAA1B,WAAD,CAAR;AACA;;AACF,aAAKvB,mBAAmB,CAAC6B,aAAzB;AACEhB,UAAAA,QAAQ,CAAC;AAAEJ,YAAAA,cAAc,EAAE,IAAlB;AAAwBD,YAAAA,MAAM,EAAEe;AAAhC,WAAD,CAAR;AACA;AArBJ;AAuBD,KAxBmB,CAApB;AAyBA,WAAO,MAAM;AACXH,MAAAA,WAAW;AACZ,KAFD;AAGD,GAjCQ,EAiCN,CAACT,EAAD,CAjCM,CAAT;AAmCA,SAAO,EACL,GAAGC,KADE;AAELI,IAAAA,SAFK;AAGLC,IAAAA,IAHK;AAILC,IAAAA;AAJK,GAAP;AAMD","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 { Reducer, useCallback, useEffect, useReducer } from 'react';\n\nimport { AdEventType } from '../AdEventType';\nimport { AppOpenAd } from '../ads/AppOpenAd';\nimport { InterstitialAd } from '../ads/InterstitialAd';\nimport { RewardedAd } from '../ads/RewardedAd';\nimport { RewardedAdEventType } from '../RewardedAdEventType';\nimport { AdStates, AdHookReturns } from '../types/AdStates';\nimport { AdShowOptions } from '../types/AdShowOptions';\nimport { RewardedAdReward } from '../types/RewardedAdReward';\n\nconst initialState: AdStates = {\n isLoaded: false,\n isOpened: false,\n isClicked: false,\n isClosed: false,\n error: undefined,\n reward: undefined,\n isEarnedReward: false,\n};\n\nexport function useFullScreenAd<T extends InterstitialAd | RewardedAd | AppOpenAd | null>(\n ad: T,\n): AdHookReturns {\n const [state, setState] = useReducer<Reducer<AdStates, Partial<AdStates>>>(\n (prevState, newState) => ({ ...prevState, ...newState }),\n initialState,\n );\n const isShowing = state.isOpened && !state.isClosed;\n\n const load = useCallback(() => {\n if (ad) {\n setState(initialState);\n ad.load();\n }\n }, [ad]);\n\n const show = useCallback(\n (showOptions?: AdShowOptions) => {\n if (ad) {\n ad.show(showOptions);\n }\n },\n [ad],\n );\n\n useEffect(() => {\n setState(initialState);\n if (!ad) {\n return;\n }\n const unsubscribe = (ad as RewardedAd).addAdEventsListener(({ type, payload }) => {\n switch (type) {\n case AdEventType.LOADED:\n setState({ isLoaded: true });\n break;\n case AdEventType.OPENED:\n setState({ isOpened: true });\n break;\n case AdEventType.CLOSED:\n setState({ isClosed: true });\n break;\n case AdEventType.CLICKED:\n setState({ isClicked: true });\n break;\n case AdEventType.ERROR:\n setState({ error: payload as Error });\n break;\n case RewardedAdEventType.LOADED:\n setState({ isLoaded: true, reward: payload as RewardedAdReward });\n break;\n case RewardedAdEventType.EARNED_REWARD:\n setState({ isEarnedReward: true, reward: payload as RewardedAdReward });\n break;\n }\n });\n return () => {\n unsubscribe();\n };\n }, [ad]);\n\n return {\n ...state,\n isShowing,\n load,\n show,\n };\n}\n"]}
1
+ {"version":3,"sources":["useFullScreenAd.ts"],"names":["useCallback","useEffect","useReducer","AdEventType","RewardedAdEventType","initialState","isLoaded","isOpened","isClicked","isClosed","error","undefined","reward","isEarnedReward","useFullScreenAd","ad","state","setState","prevState","newState","isShowing","load","show","showOptions","unsubscribe","addAdEventsListener","type","payload","LOADED","OPENED","CLOSED","CLICKED","ERROR","EARNED_REWARD"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAAkBA,WAAlB,EAA+BC,SAA/B,EAA0CC,UAA1C,QAA4D,OAA5D;AAEA,SAASC,WAAT,QAA4B,gBAA5B;AAKA,SAASC,mBAAT,QAAoC,wBA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AACEX,UAAAA,QAAQ,CAAC;AAAEX,YAAAA,QAAQ,EAAE;AAAZ,WAAD,CAAR;AACA;;AACF,aAAKH,WAAW,CAAC0B,MAAjB;AACEZ,UAAAA,QAAQ,CAAC;AAAEV,YAAAA,QAAQ,EAAE;AAAZ,WAAD,CAAR;AACA;;AACF,aAAKJ,WAAW,CAAC2B,MAAjB;AACEb,UAAAA,QAAQ,CAAC;AAAER,YAAAA,QAAQ,EAAE;AAAZ,WAAD,CAAR;AACA;;AACF,aAAKN,WAAW,CAAC4B,OAAjB;AACEd,UAAAA,QAAQ,CAAC;AAAET,YAAAA,SAAS,EAAE;AAAb,WAAD,CAAR;AACA;;AACF,aAAKL,WAAW,CAAC6B,KAAjB;AACEf,UAAAA,QAAQ,CAAC;AAAEP,YAAAA,KAAK,EAAEiB;AAAT,WAAD,CAAR;AACA;;AACF,aAAKvB,mBAAmB,CAACwB,MAAzB;AACEX,UAAAA,QAAQ,CAAC;AAAEX,YAAAA,QAAQ,EAAE,IAAZ;AAAkBM,YAAAA,MAAM,EAAEe;AAA1B,WAAD,CAAR;AACA;;AACF,aAAKvB,mBAAmB,CAAC6B,aAAzB;AACEhB,UAAAA,QAAQ,CAAC;AAAEJ,YAAAA,cAAc,EAAE,IAAlB;AAAwBD,YAAAA,MAAM,EAAEe;AAAhC,WAAD,CAAR;AACA;AArBJ;AAuBD,KAxBmB,CAApB;AAyBA,WAAO,MAAM;AACXH,MAAAA,WAAW;AACZ,KAFD;AAGD,GAjCQ,EAiCN,CAACT,EAAD,CAjCM,CAAT;AAmCA,SAAO,EACL,GAAGC,KADE;AAELI,IAAAA,SAFK;AAGLC,IAAAA,IAHK;AAILC,IAAAA;AAJK,GAAP;AAMD","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 { Reducer, useCallback, useEffect, useReducer } from 'react';\n\nimport { AdEventType } from '../AdEventType';\nimport { AppOpenAd } from '../ads/AppOpenAd';\nimport { InterstitialAd } from '../ads/InterstitialAd';\nimport { RewardedAd } from '../ads/RewardedAd';\nimport { RewardedInterstitialAd } from '../ads/RewardedInterstitialAd';\nimport { RewardedAdEventType } from '../RewardedAdEventType';\nimport { AdStates, AdHookReturns } from '../types/AdStates';\nimport { AdShowOptions } from '../types/AdShowOptions';\nimport { RewardedAdReward } from '../types/RewardedAdReward';\n\nconst initialState: AdStates = {\n isLoaded: false,\n isOpened: false,\n isClicked: false,\n isClosed: false,\n error: undefined,\n reward: undefined,\n isEarnedReward: false,\n};\n\nexport function useFullScreenAd<\n T extends AppOpenAd | InterstitialAd | RewardedAd | RewardedInterstitialAd | null,\n>(ad: T): AdHookReturns {\n const [state, setState] = useReducer<Reducer<AdStates, Partial<AdStates>>>(\n (prevState, newState) => ({ ...prevState, ...newState }),\n initialState,\n );\n const isShowing = state.isOpened && !state.isClosed;\n\n const load = useCallback(() => {\n if (ad) {\n setState(initialState);\n ad.load();\n }\n }, [ad]);\n\n const show = useCallback(\n (showOptions?: AdShowOptions) => {\n if (ad) {\n ad.show(showOptions);\n }\n },\n [ad],\n );\n\n useEffect(() => {\n setState(initialState);\n if (!ad) {\n return;\n }\n const unsubscribe = (ad as RewardedAd).addAdEventsListener(({ type, payload }) => {\n switch (type) {\n case AdEventType.LOADED:\n setState({ isLoaded: true });\n break;\n case AdEventType.OPENED:\n setState({ isOpened: true });\n break;\n case AdEventType.CLOSED:\n setState({ isClosed: true });\n break;\n case AdEventType.CLICKED:\n setState({ isClicked: true });\n break;\n case AdEventType.ERROR:\n setState({ error: payload as Error });\n break;\n case RewardedAdEventType.LOADED:\n setState({ isLoaded: true, reward: payload as RewardedAdReward });\n break;\n case RewardedAdEventType.EARNED_REWARD:\n setState({ isEarnedReward: true, reward: payload as RewardedAdReward });\n break;\n }\n });\n return () => {\n unsubscribe();\n };\n }, [ad]);\n\n return {\n ...state,\n isShowing,\n load,\n show,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["useRewardedAd.ts"],"names":["useState","useDeepCompareEffect","RewardedAd","useFullScreenAd","useRewardedAd","adUnitId","requestOptions","rewardedAd","setRewardedAd","createForAdRequest"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,QAAT,QAAyB,OAAzB;AACA,OAAOC,oBAAP,MAAiC,yBAAjC;AAEA,SAASC,UAAT,QAA2B,mBAA3B;AAIA,SAASC,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,aAAT,CACLC,QADK,EAG4B;AAAA,MADjCC,cACiC,uEADA,EACA;AACjC,QAAM,CAACC,UAAD,EAAaC,aAAb,IAA8BR,QAAQ,CAAoB,IAApB,CAA5C;AAEAC,EAAAA,oBAAoB,CAAC,MAAM;AACzBO,IAAAA,aAAa,CAAC,MAAM;AAClB,aAAOH,QAAQ,GAAGH,UAAU,CAACO,kBAAX,CAA8BJ,QAA9B,EAAwCC,cAAxC,CAAH,GAA6D,IAA5E;AACD,KAFY,CAAb;AAGD,GAJmB,EAIjB,CAACD,QAAD,EAAWC,cAAX,CAJiB,CAApB;AAMA,SAAOH,eAAe,CAACI,UAAD,CAAtB;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 { useState } from 'react';\nimport useDeepCompareEffect from 'use-deep-compare-effect';\n\nimport { RewardedAd } from '../ads/RewardedAd';\nimport { AdHookReturns } from '../types/AdStates';\nimport { RequestOptions } from '../types/RequestOptions';\n\nimport { useFullScreenAd } from './useFullScreenAd';\n\n/**\n * React Hook for Rewarded Ad.\n *\n * @param adUnitId The Ad Unit ID for the Rewarded Ad. You can find this on your Google Mobile Ads dashboard. You can destroy ad instance by setting this value to null.\n * @param requestOptions Optional RequestOptions used to load the ad.\n */\nexport function useRewardedAd(\n adUnitId: string | null,\n requestOptions: RequestOptions = {},\n): Omit<AdHookReturns, 'adReward'> {\n const [rewardedAd, setRewardedAd] = useState<RewardedAd | null>(null);\n\n useDeepCompareEffect(() => {\n setRewardedAd(() => {\n return adUnitId ? RewardedAd.createForAdRequest(adUnitId, requestOptions) : null;\n });\n }, [adUnitId, requestOptions]);\n\n return useFullScreenAd(rewardedAd);\n}\n"]}
1
+ {"version":3,"sources":["useRewardedAd.ts"],"names":["useState","useDeepCompareEffect","RewardedAd","useFullScreenAd","useRewardedAd","adUnitId","requestOptions","rewardedAd","setRewardedAd","createForAdRequest"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,QAAT,QAAyB,OAAzB;AACA,OAAOC,oBAAP,MAAiC,yBAAjC;AAEA,SAASC,UAAT,QAA2B,mBAA3B;AAIA,SAASC,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,aAAT,CACLC,QADK,EAGU;AAAA,MADfC,cACe,uEADkB,EAClB;AACf,QAAM,CAACC,UAAD,EAAaC,aAAb,IAA8BR,QAAQ,CAAoB,IAApB,CAA5C;AAEAC,EAAAA,oBAAoB,CAAC,MAAM;AACzBO,IAAAA,aAAa,CAAC,MAAM;AAClB,aAAOH,QAAQ,GAAGH,UAAU,CAACO,kBAAX,CAA8BJ,QAA9B,EAAwCC,cAAxC,CAAH,GAA6D,IAA5E;AACD,KAFY,CAAb;AAGD,GAJmB,EAIjB,CAACD,QAAD,EAAWC,cAAX,CAJiB,CAApB;AAMA,SAAOH,eAAe,CAACI,UAAD,CAAtB;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 { useState } from 'react';\nimport useDeepCompareEffect from 'use-deep-compare-effect';\n\nimport { RewardedAd } from '../ads/RewardedAd';\nimport { AdHookReturns } from '../types/AdStates';\nimport { RequestOptions } from '../types/RequestOptions';\n\nimport { useFullScreenAd } from './useFullScreenAd';\n\n/**\n * React Hook for Rewarded Ad.\n *\n * @param adUnitId The Ad Unit ID for the Rewarded Ad. You can find this on your Google Mobile Ads dashboard. You can destroy ad instance by setting this value to null.\n * @param requestOptions Optional RequestOptions used to load the ad.\n */\nexport function useRewardedAd(\n adUnitId: string | null,\n requestOptions: RequestOptions = {},\n): AdHookReturns {\n const [rewardedAd, setRewardedAd] = useState<RewardedAd | null>(null);\n\n useDeepCompareEffect(() => {\n setRewardedAd(() => {\n return adUnitId ? RewardedAd.createForAdRequest(adUnitId, requestOptions) : null;\n });\n }, [adUnitId, requestOptions]);\n\n return useFullScreenAd(rewardedAd);\n}\n"]}