react-native-google-mobile-ads 4.2.0 → 5.1.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 (83) hide show
  1. package/RNGoogleMobileAds.podspec +16 -9
  2. package/__tests__/consent.test.ts +17 -9
  3. package/android/build.gradle +4 -3
  4. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java +111 -168
  5. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsModule.java +1 -1
  6. package/docs/common-reasons-for-ads-not-showing.mdx +26 -24
  7. package/docs/displaying-ads-hook.mdx +99 -0
  8. package/docs/displaying-ads.mdx +3 -4
  9. package/docs/european-user-consent.mdx +67 -156
  10. package/docs/index.mdx +16 -16
  11. package/docs/migrating-to-v5.mdx +63 -0
  12. package/docs.json +4 -2
  13. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.h +0 -1
  14. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m +83 -124
  15. package/ios_config.sh +8 -0
  16. package/lib/commonjs/AdsConsent.js +58 -98
  17. package/lib/commonjs/AdsConsent.js.map +1 -1
  18. package/lib/commonjs/AdsConsentPurposes.js +47 -0
  19. package/lib/commonjs/AdsConsentPurposes.js.map +1 -0
  20. package/lib/commonjs/AdsConsentSpecialFeatures.js +39 -0
  21. package/lib/commonjs/AdsConsentSpecialFeatures.js.map +1 -0
  22. package/lib/commonjs/AdsConsentStatus.js +4 -3
  23. package/lib/commonjs/AdsConsentStatus.js.map +1 -1
  24. package/lib/commonjs/hooks/useAppOpenAd.js +51 -0
  25. package/lib/commonjs/hooks/useAppOpenAd.js.map +1 -0
  26. package/lib/commonjs/hooks/useFullScreenAd.js +120 -0
  27. package/lib/commonjs/hooks/useFullScreenAd.js.map +1 -0
  28. package/lib/commonjs/hooks/useInterstitialAd.js +51 -0
  29. package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -0
  30. package/lib/commonjs/hooks/useRewardedAd.js +51 -0
  31. package/lib/commonjs/hooks/useRewardedAd.js.map +1 -0
  32. package/lib/commonjs/index.js +40 -0
  33. package/lib/commonjs/index.js.map +1 -1
  34. package/lib/commonjs/types/AdStates.js +6 -0
  35. package/lib/commonjs/types/AdStates.js.map +1 -0
  36. package/lib/commonjs/version.js +1 -1
  37. package/lib/commonjs/version.js.map +1 -1
  38. package/lib/module/AdsConsent.js +56 -98
  39. package/lib/module/AdsConsent.js.map +1 -1
  40. package/lib/module/AdsConsentPurposes.js +39 -0
  41. package/lib/module/AdsConsentPurposes.js.map +1 -0
  42. package/lib/module/AdsConsentSpecialFeatures.js +31 -0
  43. package/lib/module/AdsConsentSpecialFeatures.js.map +1 -0
  44. package/lib/module/AdsConsentStatus.js +4 -3
  45. package/lib/module/AdsConsentStatus.js.map +1 -1
  46. package/lib/module/hooks/useAppOpenAd.js +38 -0
  47. package/lib/module/hooks/useAppOpenAd.js.map +1 -0
  48. package/lib/module/hooks/useFullScreenAd.js +109 -0
  49. package/lib/module/hooks/useFullScreenAd.js.map +1 -0
  50. package/lib/module/hooks/useInterstitialAd.js +38 -0
  51. package/lib/module/hooks/useInterstitialAd.js.map +1 -0
  52. package/lib/module/hooks/useRewardedAd.js +38 -0
  53. package/lib/module/hooks/useRewardedAd.js.map +1 -0
  54. package/lib/module/index.js +5 -0
  55. package/lib/module/index.js.map +1 -1
  56. package/lib/module/types/AdStates.js +2 -0
  57. package/lib/module/types/AdStates.js.map +1 -0
  58. package/lib/module/version.js +1 -1
  59. package/lib/module/version.js.map +1 -1
  60. package/lib/typescript/AdsConsentPurposes.d.ts +148 -0
  61. package/lib/typescript/AdsConsentSpecialFeatures.d.ts +22 -0
  62. package/lib/typescript/AdsConsentStatus.d.ts +10 -6
  63. package/lib/typescript/hooks/useAppOpenAd.d.ts +9 -0
  64. package/lib/typescript/hooks/useFullScreenAd.d.ts +5 -0
  65. package/lib/typescript/hooks/useInterstitialAd.d.ts +9 -0
  66. package/lib/typescript/hooks/useRewardedAd.d.ts +9 -0
  67. package/lib/typescript/index.d.ts +6 -1
  68. package/lib/typescript/types/AdStates.d.ts +85 -0
  69. package/lib/typescript/types/AdsConsent.interface.d.ts +229 -180
  70. package/lib/typescript/version.d.ts +1 -1
  71. package/package.json +10 -4
  72. package/src/AdsConsent.ts +91 -135
  73. package/src/AdsConsentPurposes.ts +182 -0
  74. package/src/AdsConsentSpecialFeatures.ts +48 -0
  75. package/src/AdsConsentStatus.ts +11 -6
  76. package/src/hooks/useAppOpenAd.ts +46 -0
  77. package/src/hooks/useFullScreenAd.ts +104 -0
  78. package/src/hooks/useInterstitialAd.ts +46 -0
  79. package/src/hooks/useRewardedAd.ts +46 -0
  80. package/src/index.ts +5 -0
  81. package/src/types/AdStates.ts +87 -0
  82. package/src/types/AdsConsent.interface.ts +230 -187
  83. package/src/version.ts +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["AdsConsentSpecialFeatures.ts"],"names":["AdsConsentSpecialFeatures"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IAEYA,yB;;;WAAAA,yB;AAAAA,EAAAA,yB,CAAAA,yB;AAAAA,EAAAA,yB,CAAAA,yB;GAAAA,yB,yCAAAA,yB","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 *\n * The definitions in this document are copied from IAB's global vendor list.\n *\n * https://vendor-list.consensu.org/v2/vendor-list.json\n * https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework\n *\n */\n\nexport enum AdsConsentSpecialFeatures {\n /**\n * Your precise geolocation data can be used in support of one or more purposes.\n * This means your location can be accurate to within several meters.\n *\n * Vendors can:\n * - Collect and process precise geolocation data in support of one or more purposes.\n * - Precise geolocation means that there are no restrictions on the precision of\n * a user's location; this can be accurate to within several meters.\n */\n USE_PRECISE_GEOLOCATION_DATA = 1,\n\n /**\n * Your device can be identified based on a scan of your device's\n * unique combination of characteristics.\n *\n * Vendors can:\n * - Create an identifier using data collected via actively scanning a device for\n * specific characteristics, e.g. installed fonts or screen resolution.\n * - Use such an identifier to re-identify a device.\n */\n ACTIVELY_SCAN_DEVICE_CHARACTERISTICS_FOR_IDENTIFICATION = 2,\n}\n"]}
@@ -29,8 +29,9 @@ let AdsConsentStatus;
29
29
  exports.AdsConsentStatus = AdsConsentStatus;
30
30
 
31
31
  (function (AdsConsentStatus) {
32
- AdsConsentStatus[AdsConsentStatus["UNKNOWN"] = 0] = "UNKNOWN";
33
- AdsConsentStatus[AdsConsentStatus["NON_PERSONALIZED"] = 1] = "NON_PERSONALIZED";
34
- AdsConsentStatus[AdsConsentStatus["PERSONALIZED"] = 2] = "PERSONALIZED";
32
+ AdsConsentStatus["UNKNOWN"] = "UNKNOWN";
33
+ AdsConsentStatus["REQUIRED"] = "REQUIRED";
34
+ AdsConsentStatus["NOT_REQUIRED"] = "NOT_REQUIRED";
35
+ AdsConsentStatus["OBTAINED"] = "OBTAINED";
35
36
  })(AdsConsentStatus || (exports.AdsConsentStatus = AdsConsentStatus = {}));
36
37
  //# sourceMappingURL=AdsConsentStatus.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["AdsConsentStatus.ts"],"names":["AdsConsentStatus"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;IACYA,gB;;;WAAAA,gB;AAAAA,EAAAA,gB,CAAAA,gB;AAAAA,EAAAA,gB,CAAAA,gB;AAAAA,EAAAA,gB,CAAAA,gB;GAAAA,gB,gCAAAA,gB","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/**\n * AdsConsentStatus enum.\n */\nexport enum AdsConsentStatus {\n /**\n * The consent status is unknown and the user must provide consent to show ads if they are within the EEA or location is also unknown.\n */\n UNKNOWN = 0,\n\n /**\n * The user has accepted non-personalized ads.\n */\n NON_PERSONALIZED = 1,\n\n /**\n * The user has accepted personalized ads.\n */\n PERSONALIZED = 2,\n}\n"]}
1
+ {"version":3,"sources":["AdsConsentStatus.ts"],"names":["AdsConsentStatus"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;IACYA,gB;;;WAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;GAAAA,gB,gCAAAA,gB","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/**\n * AdsConsentStatus enum.\n */\nexport enum AdsConsentStatus {\n /**\n * Unknown consent status, AdsConsent.requestInfoUpdate needs to be called to update it.\n */\n UNKNOWN = 'UNKNOWN',\n\n /**\n * User consent required but not yet obtained.\n */\n REQUIRED = 'REQUIRED',\n\n /**\n * User consent not required.\n */\n NOT_REQUIRED = 'NOT_REQUIRED',\n\n /**\n * User consent already obtained.\n */\n OBTAINED = 'OBTAINED',\n}\n"]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useAppOpenAd = useAppOpenAd;
7
+
8
+ var _react = require("react");
9
+
10
+ var _useDeepCompareEffect = _interopRequireDefault(require("use-deep-compare-effect"));
11
+
12
+ var _AppOpenAd = require("../ads/AppOpenAd");
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 App Open Ad.
37
+ *
38
+ * @param adUnitId The Ad Unit ID for the App Open 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 useAppOpenAd(adUnitId) {
42
+ let requestOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
43
+ const [appOpenAd, setAppOpenAd] = (0, _react.useState)(null);
44
+ (0, _useDeepCompareEffect.default)(() => {
45
+ setAppOpenAd(() => {
46
+ return adUnitId ? _AppOpenAd.AppOpenAd.createForAdRequest(adUnitId, requestOptions) : null;
47
+ });
48
+ }, [adUnitId, requestOptions]);
49
+ return (0, _useFullScreenAd.useFullScreenAd)(appOpenAd);
50
+ }
51
+ //# sourceMappingURL=useAppOpenAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useAppOpenAd.ts"],"names":["useAppOpenAd","adUnitId","requestOptions","appOpenAd","setAppOpenAd","AppOpenAd","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,YAAT,CACLC,QADK,EAG4B;AAAA,MADjCC,cACiC,uEADA,EACA;AACjC,QAAM,CAACC,SAAD,EAAYC,YAAZ,IAA4B,qBAA2B,IAA3B,CAAlC;AAEA,qCAAqB,MAAM;AACzBA,IAAAA,YAAY,CAAC,MAAM;AACjB,aAAOH,QAAQ,GAAGI,qBAAUC,kBAAV,CAA6BL,QAA7B,EAAuCC,cAAvC,CAAH,GAA4D,IAA3E;AACD,KAFW,CAAZ;AAGD,GAJD,EAIG,CAACD,QAAD,EAAWC,cAAX,CAJH;AAMA,SAAO,sCAAgBC,SAAhB,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 { AppOpenAd } from '../ads/AppOpenAd';\nimport { AdHookReturns } from '../types/AdStates';\nimport { RequestOptions } from '../types/RequestOptions';\n\nimport { useFullScreenAd } from './useFullScreenAd';\n\n/**\n * React Hook for App Open Ad.\n *\n * @param adUnitId The Ad Unit ID for the App Open 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 useAppOpenAd(\n adUnitId: string | null,\n requestOptions: RequestOptions = {},\n): Omit<AdHookReturns, 'adReward'> {\n const [appOpenAd, setAppOpenAd] = useState<AppOpenAd | null>(null);\n\n useDeepCompareEffect(() => {\n setAppOpenAd(() => {\n return adUnitId ? AppOpenAd.createForAdRequest(adUnitId, requestOptions) : null;\n });\n }, [adUnitId, requestOptions]);\n\n return useFullScreenAd(appOpenAd);\n}\n"]}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useFullScreenAd = useFullScreenAd;
7
+
8
+ var _react = require("react");
9
+
10
+ var _AdEventType = require("../AdEventType");
11
+
12
+ var _RewardedAdEventType = require("../RewardedAdEventType");
13
+
14
+ /*
15
+ * Copyright (c) 2016-present Invertase Limited & Contributors
16
+ *
17
+ * Licensed under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this library except in compliance with the License.
19
+ * You may obtain a copy of the License at
20
+ *
21
+ * http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing, software
24
+ * distributed under the License is distributed on an "AS IS" BASIS,
25
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
+ * See the License for the specific language governing permissions and
27
+ * limitations under the License.
28
+ *
29
+ */
30
+ const initialState = {
31
+ isLoaded: false,
32
+ isOpened: false,
33
+ isClicked: false,
34
+ isClosed: false,
35
+ error: undefined,
36
+ reward: undefined,
37
+ isEarnedReward: false
38
+ };
39
+
40
+ function useFullScreenAd(ad) {
41
+ const [state, setState] = (0, _react.useReducer)((prevState, newState) => ({ ...prevState,
42
+ ...newState
43
+ }), initialState);
44
+ const isShowing = state.isOpened && !state.isClosed;
45
+ const load = (0, _react.useCallback)(() => {
46
+ if (ad) {
47
+ setState(initialState);
48
+ ad.load();
49
+ }
50
+ }, [ad]);
51
+ const show = (0, _react.useCallback)(showOptions => {
52
+ if (ad) {
53
+ ad.show(showOptions);
54
+ }
55
+ }, [ad]);
56
+ (0, _react.useEffect)(() => {
57
+ setState(initialState);
58
+
59
+ if (!ad) {
60
+ return;
61
+ }
62
+
63
+ const unsubscribe = ad.onAdEvent((type, error, data) => {
64
+ switch (type) {
65
+ case _AdEventType.AdEventType.LOADED:
66
+ setState({
67
+ isLoaded: true
68
+ });
69
+ break;
70
+
71
+ case _AdEventType.AdEventType.OPENED:
72
+ setState({
73
+ isOpened: true
74
+ });
75
+ break;
76
+
77
+ case _AdEventType.AdEventType.CLOSED:
78
+ setState({
79
+ isClosed: true
80
+ });
81
+ break;
82
+
83
+ case _AdEventType.AdEventType.CLICKED:
84
+ setState({
85
+ isClicked: true
86
+ });
87
+ break;
88
+
89
+ case _AdEventType.AdEventType.ERROR:
90
+ setState({
91
+ error: error
92
+ });
93
+ break;
94
+
95
+ case _RewardedAdEventType.RewardedAdEventType.LOADED:
96
+ setState({
97
+ isLoaded: true,
98
+ reward: data
99
+ });
100
+ break;
101
+
102
+ case _RewardedAdEventType.RewardedAdEventType.EARNED_REWARD:
103
+ setState({
104
+ isEarnedReward: true,
105
+ reward: data
106
+ });
107
+ break;
108
+ }
109
+ });
110
+ return () => {
111
+ unsubscribe();
112
+ };
113
+ }, [ad]);
114
+ return { ...state,
115
+ isShowing,
116
+ load,
117
+ show
118
+ };
119
+ }
120
+ //# sourceMappingURL=useFullScreenAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useFullScreenAd.ts"],"names":["initialState","isLoaded","isOpened","isClicked","isClosed","error","undefined","reward","isEarnedReward","useFullScreenAd","ad","state","setState","prevState","newState","isShowing","load","show","showOptions","unsubscribe","onAdEvent","type","data","AdEventType","LOADED","OPENED","CLOSED","CLICKED","ERROR","RewardedAdEventType","EARNED_REWARD"],"mappings":";;;;;;;AAiBA;;AAEA;;AAIA;;AAvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAYA,MAAMA,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;;AAUO,SAASC,eAAT,CACLC,EADK,EAEU;AACf,QAAM,CAACC,KAAD,EAAQC,QAAR,IAAoB,uBACxB,CAACC,SAAD,EAAYC,QAAZ,MAA0B,EAAE,GAAGD,SAAL;AAAgB,OAAGC;AAAnB,GAA1B,CADwB,EAExBd,YAFwB,CAA1B;AAIA,QAAMe,SAAS,GAAGJ,KAAK,CAACT,QAAN,IAAkB,CAACS,KAAK,CAACP,QAA3C;AAEA,QAAMY,IAAI,GAAG,wBAAY,MAAM;AAC7B,QAAIN,EAAJ,EAAQ;AACNE,MAAAA,QAAQ,CAACZ,YAAD,CAAR;AACAU,MAAAA,EAAE,CAACM,IAAH;AACD;AACF,GALY,EAKV,CAACN,EAAD,CALU,CAAb;AAOA,QAAMO,IAAI,GAAG,wBACVC,WAAD,IAAiC;AAC/B,QAAIR,EAAJ,EAAQ;AACNA,MAAAA,EAAE,CAACO,IAAH,CAAQC,WAAR;AACD;AACF,GALU,EAMX,CAACR,EAAD,CANW,CAAb;AASA,wBAAU,MAAM;AACdE,IAAAA,QAAQ,CAACZ,YAAD,CAAR;;AACA,QAAI,CAACU,EAAL,EAAS;AACP;AACD;;AACD,UAAMS,WAAW,GAAGT,EAAE,CAACU,SAAH,CAAa,CAACC,IAAD,EAAOhB,KAAP,EAAciB,IAAd,KAAuB;AACtD,cAAQD,IAAR;AACE,aAAKE,yBAAYC,MAAjB;AACEZ,UAAAA,QAAQ,CAAC;AAAEX,YAAAA,QAAQ,EAAE;AAAZ,WAAD,CAAR;AACA;;AACF,aAAKsB,yBAAYE,MAAjB;AACEb,UAAAA,QAAQ,CAAC;AAAEV,YAAAA,QAAQ,EAAE;AAAZ,WAAD,CAAR;AACA;;AACF,aAAKqB,yBAAYG,MAAjB;AACEd,UAAAA,QAAQ,CAAC;AAAER,YAAAA,QAAQ,EAAE;AAAZ,WAAD,CAAR;AACA;;AACF,aAAKmB,yBAAYI,OAAjB;AACEf,UAAAA,QAAQ,CAAC;AAAET,YAAAA,SAAS,EAAE;AAAb,WAAD,CAAR;AACA;;AACF,aAAKoB,yBAAYK,KAAjB;AACEhB,UAAAA,QAAQ,CAAC;AAAEP,YAAAA,KAAK,EAAEA;AAAT,WAAD,CAAR;AACA;;AACF,aAAKwB,yCAAoBL,MAAzB;AACEZ,UAAAA,QAAQ,CAAC;AAAEX,YAAAA,QAAQ,EAAE,IAAZ;AAAkBM,YAAAA,MAAM,EAAEe;AAA1B,WAAD,CAAR;AACA;;AACF,aAAKO,yCAAoBC,aAAzB;AACElB,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,GAjCD,EAiCG,CAACT,EAAD,CAjCH;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';\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.onAdEvent((type, error, data) => {\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: error });\n break;\n case RewardedAdEventType.LOADED:\n setState({ isLoaded: true, reward: data });\n break;\n case RewardedAdEventType.EARNED_REWARD:\n setState({ isEarnedReward: true, reward: data });\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"]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useInterstitialAd = useInterstitialAd;
7
+
8
+ var _react = require("react");
9
+
10
+ var _useDeepCompareEffect = _interopRequireDefault(require("use-deep-compare-effect"));
11
+
12
+ var _InterstitialAd = require("../ads/InterstitialAd");
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 Interstitial Ad.
37
+ *
38
+ * @param adUnitId The Ad Unit ID for the 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 useInterstitialAd(adUnitId) {
42
+ let requestOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
43
+ const [interstitialAd, setInterstitialAd] = (0, _react.useState)(null);
44
+ (0, _useDeepCompareEffect.default)(() => {
45
+ setInterstitialAd(() => {
46
+ return adUnitId ? _InterstitialAd.InterstitialAd.createForAdRequest(adUnitId, requestOptions) : null;
47
+ });
48
+ }, [adUnitId, requestOptions]);
49
+ return (0, _useFullScreenAd.useFullScreenAd)(interstitialAd);
50
+ }
51
+ //# sourceMappingURL=useInterstitialAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useInterstitialAd.ts"],"names":["useInterstitialAd","adUnitId","requestOptions","interstitialAd","setInterstitialAd","InterstitialAd","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,iBAAT,CACLC,QADK,EAG4B;AAAA,MADjCC,cACiC,uEADA,EACA;AACjC,QAAM,CAACC,cAAD,EAAiBC,iBAAjB,IAAsC,qBAAgC,IAAhC,CAA5C;AAEA,qCAAqB,MAAM;AACzBA,IAAAA,iBAAiB,CAAC,MAAM;AACtB,aAAOH,QAAQ,GAAGI,+BAAeC,kBAAf,CAAkCL,QAAlC,EAA4CC,cAA5C,CAAH,GAAiE,IAAhF;AACD,KAFgB,CAAjB;AAGD,GAJD,EAIG,CAACD,QAAD,EAAWC,cAAX,CAJH;AAMA,SAAO,sCAAgBC,cAAhB,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 { InterstitialAd } from '../ads/InterstitialAd';\nimport { AdHookReturns } from '../types/AdStates';\nimport { RequestOptions } from '../types/RequestOptions';\n\nimport { useFullScreenAd } from './useFullScreenAd';\n\n/**\n * React Hook for Interstitial Ad.\n *\n * @param adUnitId The Ad Unit ID for the 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 useInterstitialAd(\n adUnitId: string | null,\n requestOptions: RequestOptions = {},\n): Omit<AdHookReturns, 'adReward'> {\n const [interstitialAd, setInterstitialAd] = useState<InterstitialAd | null>(null);\n\n useDeepCompareEffect(() => {\n setInterstitialAd(() => {\n return adUnitId ? InterstitialAd.createForAdRequest(adUnitId, requestOptions) : null;\n });\n }, [adUnitId, requestOptions]);\n\n return useFullScreenAd(interstitialAd);\n}\n"]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useRewardedAd = useRewardedAd;
7
+
8
+ var _react = require("react");
9
+
10
+ var _useDeepCompareEffect = _interopRequireDefault(require("use-deep-compare-effect"));
11
+
12
+ var _RewardedAd = require("../ads/RewardedAd");
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 Ad.
37
+ *
38
+ * @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.
39
+ * @param requestOptions Optional RequestOptions used to load the ad.
40
+ */
41
+ function useRewardedAd(adUnitId) {
42
+ let requestOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
43
+ const [rewardedAd, setRewardedAd] = (0, _react.useState)(null);
44
+ (0, _useDeepCompareEffect.default)(() => {
45
+ setRewardedAd(() => {
46
+ return adUnitId ? _RewardedAd.RewardedAd.createForAdRequest(adUnitId, requestOptions) : null;
47
+ });
48
+ }, [adUnitId, requestOptions]);
49
+ return (0, _useFullScreenAd.useFullScreenAd)(rewardedAd);
50
+ }
51
+ //# sourceMappingURL=useRewardedAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useRewardedAd.ts"],"names":["useRewardedAd","adUnitId","requestOptions","rewardedAd","setRewardedAd","RewardedAd","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,aAAT,CACLC,QADK,EAG4B;AAAA,MADjCC,cACiC,uEADA,EACA;AACjC,QAAM,CAACC,UAAD,EAAaC,aAAb,IAA8B,qBAA4B,IAA5B,CAApC;AAEA,qCAAqB,MAAM;AACzBA,IAAAA,aAAa,CAAC,MAAM;AAClB,aAAOH,QAAQ,GAAGI,uBAAWC,kBAAX,CAA8BL,QAA9B,EAAwCC,cAAxC,CAAH,GAA6D,IAA5E;AACD,KAFY,CAAb;AAGD,GAJD,EAIG,CAACD,QAAD,EAAWC,cAAX,CAJH;AAMA,SAAO,sCAAgBC,UAAhB,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 { 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"]}
@@ -21,6 +21,18 @@ Object.defineProperty(exports, "AdsConsentDebugGeography", {
21
21
  return _AdsConsentDebugGeography.AdsConsentDebugGeography;
22
22
  }
23
23
  });
24
+ Object.defineProperty(exports, "AdsConsentPurposes", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _AdsConsentPurposes.AdsConsentPurposes;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "AdsConsentSpecialFeatures", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _AdsConsentSpecialFeatures.AdsConsentSpecialFeatures;
34
+ }
35
+ });
24
36
  Object.defineProperty(exports, "AdsConsentStatus", {
25
37
  enumerable: true,
26
38
  get: function () {
@@ -88,6 +100,24 @@ Object.defineProperty(exports, "default", {
88
100
  return _MobileAds.default;
89
101
  }
90
102
  });
103
+ Object.defineProperty(exports, "useAppOpenAd", {
104
+ enumerable: true,
105
+ get: function () {
106
+ return _useAppOpenAd.useAppOpenAd;
107
+ }
108
+ });
109
+ Object.defineProperty(exports, "useInterstitialAd", {
110
+ enumerable: true,
111
+ get: function () {
112
+ return _useInterstitialAd.useInterstitialAd;
113
+ }
114
+ });
115
+ Object.defineProperty(exports, "useRewardedAd", {
116
+ enumerable: true,
117
+ get: function () {
118
+ return _useRewardedAd.useRewardedAd;
119
+ }
120
+ });
91
121
 
92
122
  var _version = require("./version");
93
123
 
@@ -95,6 +125,10 @@ var _MobileAds = _interopRequireWildcard(require("./MobileAds"));
95
125
 
96
126
  var _AdsConsentDebugGeography = require("./AdsConsentDebugGeography");
97
127
 
128
+ var _AdsConsentPurposes = require("./AdsConsentPurposes");
129
+
130
+ var _AdsConsentSpecialFeatures = require("./AdsConsentSpecialFeatures");
131
+
98
132
  var _AdsConsentStatus = require("./AdsConsentStatus");
99
133
 
100
134
  var _MaxAdContentRating = require("./MaxAdContentRating");
@@ -117,6 +151,12 @@ var _RewardedAd = require("./ads/RewardedAd");
117
151
 
118
152
  var _BannerAd = require("./ads/BannerAd");
119
153
 
154
+ var _useAppOpenAd = require("./hooks/useAppOpenAd");
155
+
156
+ var _useInterstitialAd = require("./hooks/useInterstitialAd");
157
+
158
+ var _useRewardedAd = require("./hooks/useRewardedAd");
159
+
120
160
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
121
161
 
122
162
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -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;;;;;;AAlCA;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 { AdsConsentStatus } from './AdsConsentStatus';\nexport { MaxAdContentRating } from './MaxAdContentRating';\nexport { TestIds } from './TestIds';\nexport { AdEventType } from './AdEventType';\nexport { BannerAdSize } from './BannerAdSize';\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';\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;;;;;;AAvCA;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 { 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 { useAppOpenAd } from './hooks/useAppOpenAd';\nexport { useInterstitialAd } from './hooks/useInterstitialAd';\nexport { useRewardedAd } from './hooks/useRewardedAd';\n"]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=AdStates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = void 0;
7
7
  // generated by genversion
8
- const version = '4.2.0';
8
+ const version = '5.1.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 = '4.2.0';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '5.1.0';\n"]}
@@ -14,134 +14,92 @@
14
14
  * limitations under the License.
15
15
  *
16
16
  */
17
- import { hasOwnProperty, isArray, isBoolean, isObject, isString, isUndefined, isValidUrl } from './common';
17
+ import { TCModel, TCString } from '@iabtcf/core';
18
18
  import { NativeModules } from 'react-native';
19
19
  import { AdsConsentDebugGeography } from './AdsConsentDebugGeography';
20
- import { AdsConsentStatus } from './AdsConsentStatus';
20
+ import { AdsConsentPurposes } from './AdsConsentPurposes';
21
+ import { AdsConsentSpecialFeatures } from './AdsConsentSpecialFeatures';
22
+ import { hasOwnProperty, isArray, isBoolean, isObject, isString } from './common';
21
23
  const native = NativeModules.RNGoogleMobileAdsConsentModule;
22
24
  export const AdsConsent = {
23
- /**
24
- *
25
- * @param publisherIds
26
- * @returns {*}
27
- */
28
- requestInfoUpdate(publisherIds) {
29
- if (!isArray(publisherIds)) {
30
- throw new Error("AdsConsent.requestInfoUpdate(*) 'publisherIds' expected an array of string values.");
31
- }
32
-
33
- if (publisherIds.length === 0) {
34
- throw new Error("AdsConsent.requestInfoUpdate(*) 'publisherIds' list of publisher IDs cannot be empty.");
35
- }
36
-
37
- for (let i = 0; i < publisherIds.length; i++) {
38
- if (!isString(publisherIds[i])) {
39
- throw new Error(`AdsConsent.requestInfoUpdate(*) 'publisherIds[${i}]' expected a string value.`);
40
- }
41
- }
42
-
43
- return native.requestInfoUpdate(publisherIds);
44
- },
25
+ requestInfoUpdate() {
26
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
45
27
 
46
- /**
47
- *
48
- * @param options
49
- * @returns {*}
50
- */
51
- showForm(options) {
52
- if (!isUndefined(options) && !isObject(options)) {
53
- throw new Error("AdsConsent.showForm(*) 'options' expected an object value.");
28
+ if (!isObject(options)) {
29
+ throw new Error("AdsConsent.requestInfoUpdate(*) 'options' expected an object value.");
54
30
  }
55
31
 
56
- if (!isValidUrl(options.privacyPolicy)) {
57
- throw new Error("AdsConsent.showForm(*) 'options.privacyPolicy' expected a valid HTTP or HTTPS URL.");
32
+ if (hasOwnProperty(options, 'debugGeography') && options.debugGeography !== AdsConsentDebugGeography.DISABLED && options.debugGeography !== AdsConsentDebugGeography.EEA && options.debugGeography !== AdsConsentDebugGeography.NOT_EEA) {
33
+ throw new Error("AdsConsent.requestInfoUpdate(*) 'options.debugGeography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.");
58
34
  }
59
35
 
60
- if (hasOwnProperty(options, 'withPersonalizedAds') && !isBoolean(options.withPersonalizedAds)) {
61
- throw new Error("AdsConsent.showForm(*) 'options.withPersonalizedAds' expected a boolean value.");
36
+ if (hasOwnProperty(options, 'tagForUnderAgeOfConsent') && !isBoolean(options.tagForUnderAgeOfConsent)) {
37
+ throw new Error("AdsConsent.requestInfoUpdate(*) 'options.tagForUnderAgeOfConsent' expected a boolean value.");
62
38
  }
63
39
 
64
- if (hasOwnProperty(options, 'withNonPersonalizedAds') && !isBoolean(options.withNonPersonalizedAds)) {
65
- throw new Error("AdsConsent.showForm(*) 'options.withNonPersonalizedAds' expected a boolean value.");
66
- }
40
+ if (hasOwnProperty(options, 'testDeviceIdentifiers')) {
41
+ if (!isArray(options.testDeviceIdentifiers)) {
42
+ throw new Error("AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.");
43
+ }
67
44
 
68
- if (hasOwnProperty(options, 'withAdFree') && !isBoolean(options.withAdFree)) {
69
- throw new Error("AdsConsent.showForm(*) 'options.withAdFree' expected a boolean value.");
70
- }
45
+ for (const deviceId of (_options$testDeviceId = options.testDeviceIdentifiers) !== null && _options$testDeviceId !== void 0 ? _options$testDeviceId : []) {
46
+ var _options$testDeviceId;
71
47
 
72
- if (!options.withPersonalizedAds && !options.withNonPersonalizedAds && !options.withAdFree) {
73
- throw new Error("AdsConsent.showForm(*) 'options' form requires at least one option to be enabled.");
48
+ if (!isString(deviceId)) {
49
+ throw new Error("AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.");
50
+ }
51
+ }
74
52
  }
75
53
 
76
- return native.showForm(options);
54
+ return native.requestInfoUpdate(options);
77
55
  },
78
56
 
79
- /**
80
- *
81
- */
82
- getAdProviders() {
83
- return native.getAdProviders();
57
+ showForm() {
58
+ return native.showForm();
84
59
  },
85
60
 
86
- /**
87
- *
88
- * @param geography
89
- */
90
- setDebugGeography(geography) {
91
- if (geography !== AdsConsentDebugGeography.DISABLED && geography !== AdsConsentDebugGeography.EEA && geography !== AdsConsentDebugGeography.NOT_EEA) {
92
- throw new Error("AdsConsent.setDebugGeography(*) 'geography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.");
93
- }
94
-
95
- return native.setDebugGeography(geography);
61
+ reset() {
62
+ return native.reset();
96
63
  },
97
64
 
98
- /**
99
- *
100
- */
101
- getStatus() {
102
- return native.getStatus();
65
+ getTCString() {
66
+ return native.getTCString();
103
67
  },
104
68
 
105
- /**
106
- *
107
- * @param status
108
- */
109
- setStatus(status) {
110
- if (status !== AdsConsentStatus.UNKNOWN && status !== AdsConsentStatus.NON_PERSONALIZED && status !== AdsConsentStatus.PERSONALIZED) {
111
- throw new Error("AdsConsent.setStatus(*) 'status' expected one of AdsConsentStatus.UNKNOWN, AdsConsentStatus.NON_PERSONALIZED or AdsConsentStatus.PERSONALIZED.");
112
- }
113
-
114
- return native.setStatus(status);
69
+ async getTCModel() {
70
+ const tcString = await native.getTCString();
71
+ return TCString.decode(tcString);
115
72
  },
116
73
 
117
- /**
118
- *
119
- * @param tag
120
- */
121
- setTagForUnderAgeOfConsent(tag) {
122
- if (!isBoolean(tag)) {
123
- throw new Error("AdsConsent.setTagForUnderAgeOfConsent(*) 'tag' expected a boolean value.");
124
- }
74
+ async getUserChoices() {
75
+ const tcString = await native.getTCString();
76
+ let tcModel;
125
77
 
126
- return native.setTagForUnderAgeOfConsent(tag);
127
- },
128
-
129
- /**
130
- *
131
- * @param deviceIds
132
- */
133
- addTestDevices(deviceIds) {
134
- if (!isArray(deviceIds)) {
135
- throw new Error("AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values.");
136
- }
78
+ try {
79
+ tcModel = TCString.decode(tcString);
80
+ } catch (e) {
81
+ tcModel = new TCModel();
137
82
 
138
- for (let i = 0; i < deviceIds.length; i++) {
139
- if (!isString(deviceIds[i])) {
140
- throw new Error("AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values.");
83
+ if (__DEV__) {
84
+ // eslint-disable-next-line no-console
85
+ console.warn(`Failed to decode tcString ${tcString}:`, e);
141
86
  }
142
87
  }
143
88
 
144
- return native.addTestDevices(deviceIds);
89
+ return {
90
+ activelyScanDeviceCharacteristicsForIdentification: tcModel.specialFeatureOptins.has(AdsConsentSpecialFeatures.ACTIVELY_SCAN_DEVICE_CHARACTERISTICS_FOR_IDENTIFICATION),
91
+ applyMarketResearchToGenerateAudienceInsights: tcModel.purposeConsents.has(AdsConsentPurposes.APPLY_MARKET_RESEARCH_TO_GENERATE_AUDIENCE_INSIGHTS),
92
+ createAPersonalisedAdsProfile: tcModel.purposeConsents.has(AdsConsentPurposes.CREATE_A_PERSONALISED_ADS_PROFILE),
93
+ createAPersonalisedContentProfile: tcModel.purposeConsents.has(AdsConsentPurposes.CREATE_A_PERSONALISED_ADS_PROFILE),
94
+ developAndImproveProducts: tcModel.purposeConsents.has(AdsConsentPurposes.DEVELOP_AND_IMPROVE_PRODUCTS),
95
+ measureAdPerformance: tcModel.purposeConsents.has(AdsConsentPurposes.MEASURE_AD_PERFORMANCE),
96
+ measureContentPerformance: tcModel.purposeConsents.has(AdsConsentPurposes.MEASURE_CONTENT_PERFORMANCE),
97
+ selectBasicAds: tcModel.purposeConsents.has(AdsConsentPurposes.SELECT_BASIC_ADS),
98
+ selectPersonalisedAds: tcModel.purposeConsents.has(AdsConsentPurposes.SELECT_PERSONALISED_ADS),
99
+ selectPersonalisedContent: tcModel.purposeConsents.has(AdsConsentPurposes.SELECT_PERSONALISED_CONTENT),
100
+ storeAndAccessInformationOnDevice: tcModel.purposeConsents.has(AdsConsentPurposes.STORE_AND_ACCESS_INFORMATION_ON_DEVICE),
101
+ usePreciseGeolocationData: tcModel.specialFeatureOptins.has(AdsConsentSpecialFeatures.USE_PRECISE_GEOLOCATION_DATA)
102
+ };
145
103
  }
146
104
 
147
105
  };