react-native-google-mobile-ads 5.1.0 → 6.0.1

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 (155) hide show
  1. package/RNGoogleMobileAds.podspec +1 -1
  2. package/__tests__/interstitial.test.ts +32 -5
  3. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsAppOpenModule.java +2 -1
  4. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsBannerAdViewManager.java +110 -68
  5. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java +5 -11
  6. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsEvent.java +1 -0
  7. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsInterstitialModule.java +38 -20
  8. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsModule.java +45 -0
  9. package/docs/ad-inspector.mdx +39 -0
  10. package/docs/displaying-ads.mdx +46 -25
  11. package/docs/migrating-to-v6.mdx +111 -0
  12. package/docs.json +3 -1
  13. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.m +1 -0
  14. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerViewManager.m +63 -8
  15. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.h +3 -0
  16. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m +8 -7
  17. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.h +2 -1
  18. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.m +17 -2
  19. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.m +44 -30
  20. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.m +19 -0
  21. package/lib/commonjs/AdEventType.js.map +1 -1
  22. package/lib/commonjs/GAMAdEventType.js +30 -0
  23. package/lib/commonjs/GAMAdEventType.js.map +1 -0
  24. package/lib/commonjs/MobileAds.js +4 -0
  25. package/lib/commonjs/MobileAds.js.map +1 -1
  26. package/lib/commonjs/RewardedAdEventType.js.map +1 -1
  27. package/lib/commonjs/TestIds.js +5 -0
  28. package/lib/commonjs/TestIds.js.map +1 -1
  29. package/lib/commonjs/ads/AppOpenAd.js +8 -53
  30. package/lib/commonjs/ads/AppOpenAd.js.map +1 -1
  31. package/lib/commonjs/ads/BannerAd.js +7 -110
  32. package/lib/commonjs/ads/BannerAd.js.map +1 -1
  33. package/lib/commonjs/ads/BaseAd.js +144 -0
  34. package/lib/commonjs/ads/BaseAd.js.map +1 -0
  35. package/lib/commonjs/ads/GAMBannerAd.js +42 -0
  36. package/lib/commonjs/ads/GAMBannerAd.js.map +1 -0
  37. package/lib/commonjs/ads/GAMInterstitialAd.js +48 -0
  38. package/lib/commonjs/ads/GAMInterstitialAd.js.map +1 -0
  39. package/lib/commonjs/ads/InterstitialAd.js +13 -64
  40. package/lib/commonjs/ads/InterstitialAd.js.map +1 -1
  41. package/lib/commonjs/ads/MobileAd.js +119 -12
  42. package/lib/commonjs/ads/MobileAd.js.map +1 -1
  43. package/lib/commonjs/ads/RewardedAd.js +23 -65
  44. package/lib/commonjs/ads/RewardedAd.js.map +1 -1
  45. package/lib/commonjs/hooks/useAppOpenAd.js.map +1 -1
  46. package/lib/commonjs/hooks/useFullScreenAd.js +9 -4
  47. package/lib/commonjs/hooks/useFullScreenAd.js.map +1 -1
  48. package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -1
  49. package/lib/commonjs/index.js +62 -0
  50. package/lib/commonjs/index.js.map +1 -1
  51. package/lib/commonjs/types/AdEventsListener.js +6 -0
  52. package/lib/commonjs/types/AdEventsListener.js.map +1 -0
  53. package/lib/commonjs/types/AppEvent.js +2 -0
  54. package/lib/commonjs/types/AppEvent.js.map +1 -0
  55. package/lib/commonjs/types/index.js +149 -0
  56. package/lib/commonjs/types/index.js.map +1 -0
  57. package/lib/commonjs/validateAdRequestOptions.js +0 -38
  58. package/lib/commonjs/validateAdRequestOptions.js.map +1 -1
  59. package/lib/commonjs/version.js +2 -2
  60. package/lib/commonjs/version.js.map +1 -1
  61. package/lib/module/AdEventType.js.map +1 -1
  62. package/lib/module/GAMAdEventType.js +22 -0
  63. package/lib/module/GAMAdEventType.js.map +1 -0
  64. package/lib/module/MobileAds.js +4 -0
  65. package/lib/module/MobileAds.js.map +1 -1
  66. package/lib/module/RewardedAdEventType.js.map +1 -1
  67. package/lib/module/TestIds.js +5 -0
  68. package/lib/module/TestIds.js.map +1 -1
  69. package/lib/module/ads/AppOpenAd.js +10 -37
  70. package/lib/module/ads/AppOpenAd.js.map +1 -1
  71. package/lib/module/ads/BannerAd.js +7 -85
  72. package/lib/module/ads/BannerAd.js.map +1 -1
  73. package/lib/module/ads/BaseAd.js +124 -0
  74. package/lib/module/ads/BaseAd.js.map +1 -0
  75. package/lib/module/ads/GAMBannerAd.js +42 -0
  76. package/lib/module/ads/GAMBannerAd.js.map +1 -0
  77. package/lib/module/ads/GAMInterstitialAd.js +38 -0
  78. package/lib/module/ads/GAMInterstitialAd.js.map +1 -0
  79. package/lib/module/ads/InterstitialAd.js +15 -48
  80. package/lib/module/ads/InterstitialAd.js.map +1 -1
  81. package/lib/module/ads/MobileAd.js +116 -12
  82. package/lib/module/ads/MobileAd.js.map +1 -1
  83. package/lib/module/ads/RewardedAd.js +24 -49
  84. package/lib/module/ads/RewardedAd.js.map +1 -1
  85. package/lib/module/hooks/useAppOpenAd.js.map +1 -1
  86. package/lib/module/hooks/useFullScreenAd.js +9 -4
  87. package/lib/module/hooks/useFullScreenAd.js.map +1 -1
  88. package/lib/module/hooks/useInterstitialAd.js.map +1 -1
  89. package/lib/module/index.js +4 -0
  90. package/lib/module/index.js.map +1 -1
  91. package/lib/module/types/AdEventsListener.js +2 -0
  92. package/lib/module/types/AdEventsListener.js.map +1 -0
  93. package/lib/module/types/AppEvent.js +2 -0
  94. package/lib/module/types/AppEvent.js.map +1 -0
  95. package/lib/module/types/index.js +28 -0
  96. package/lib/module/types/index.js.map +1 -0
  97. package/lib/module/validateAdRequestOptions.js +1 -39
  98. package/lib/module/validateAdRequestOptions.js.map +1 -1
  99. package/lib/module/version.js +2 -2
  100. package/lib/module/version.js.map +1 -1
  101. package/lib/typescript/AdEventType.d.ts +4 -8
  102. package/lib/typescript/GAMAdEventType.d.ts +20 -0
  103. package/lib/typescript/MobileAds.d.ts +2 -1
  104. package/lib/typescript/RewardedAdEventType.d.ts +7 -11
  105. package/lib/typescript/TestIds.d.ts +5 -0
  106. package/lib/typescript/ads/AppOpenAd.d.ts +6 -6
  107. package/lib/typescript/ads/BannerAd.d.ts +1 -1
  108. package/lib/typescript/ads/BaseAd.d.ts +35 -0
  109. package/lib/typescript/ads/GAMBannerAd.d.ts +7 -0
  110. package/lib/typescript/ads/GAMInterstitialAd.d.ts +33 -0
  111. package/lib/typescript/ads/InterstitialAd.d.ts +10 -16
  112. package/lib/typescript/ads/MobileAd.d.ts +34 -16
  113. package/lib/typescript/ads/RewardedAd.d.ts +17 -19
  114. package/lib/typescript/hooks/useAppOpenAd.d.ts +1 -1
  115. package/lib/typescript/hooks/useInterstitialAd.d.ts +1 -1
  116. package/lib/typescript/index.d.ts +5 -1
  117. package/lib/typescript/types/AdEventListener.d.ts +5 -9
  118. package/lib/typescript/types/AdEventsListener.d.ts +8 -0
  119. package/lib/typescript/types/AppEvent.d.ts +13 -0
  120. package/lib/typescript/types/BannerAdProps.d.ts +81 -4
  121. package/lib/typescript/types/GoogleMobileAdsNativeModule.d.ts +3 -2
  122. package/lib/typescript/types/MobileAd.interface.d.ts +37 -12
  123. package/lib/typescript/types/MobileAdsModule.interface.d.ts +9 -0
  124. package/lib/typescript/types/RequestOptions.d.ts +0 -22
  125. package/lib/typescript/types/index.d.ts +11 -0
  126. package/lib/typescript/version.d.ts +1 -1
  127. package/package.json +50 -49
  128. package/src/AdEventType.ts +4 -8
  129. package/src/GAMAdEventType.ts +37 -0
  130. package/src/MobileAds.ts +4 -0
  131. package/src/RewardedAdEventType.ts +7 -11
  132. package/src/TestIds.ts +5 -0
  133. package/src/ads/AppOpenAd.ts +11 -41
  134. package/src/ads/BannerAd.tsx +4 -106
  135. package/src/ads/BaseAd.tsx +156 -0
  136. package/src/ads/GAMBannerAd.tsx +37 -0
  137. package/src/ads/GAMInterstitialAd.ts +45 -0
  138. package/src/ads/InterstitialAd.ts +15 -56
  139. package/src/ads/MobileAd.ts +142 -29
  140. package/src/ads/RewardedAd.ts +29 -55
  141. package/src/hooks/useAppOpenAd.ts +1 -1
  142. package/src/hooks/useFullScreenAd.ts +5 -4
  143. package/src/hooks/useInterstitialAd.ts +1 -1
  144. package/src/index.ts +4 -0
  145. package/src/types/AdEventListener.ts +31 -13
  146. package/src/types/AdEventsListener.ts +24 -0
  147. package/src/types/AppEvent.ts +14 -0
  148. package/src/types/BannerAdProps.ts +81 -4
  149. package/src/types/GoogleMobileAdsNativeModule.ts +3 -2
  150. package/src/types/MobileAd.interface.ts +56 -12
  151. package/src/types/MobileAdsModule.interface.ts +10 -0
  152. package/src/types/RequestOptions.ts +0 -24
  153. package/src/types/index.ts +28 -0
  154. package/src/validateAdRequestOptions.ts +0 -45
  155. package/src/version.ts +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["validateAdRequestOptions.ts"],"names":["hasOwnProperty","isArray","isBoolean","isNumber","isObject","isString","isUndefined","isValidUrl","validateAdRequestOptions","options","out","Error","requestNonPersonalizedAdsOnly","networkExtras","Object","entries","forEach","key","value","keywords","i","length","keyword","contentUrl","location","error","latitude","longitude","locationAccuracy","requestAgent","serverSideVerificationOptions","ssvOptions","userId","customData","customTargeting"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SACEA,cADF,EAEEC,OAFF,EAGEC,SAHF,EAIEC,QAJF,EAKEC,QALF,EAMEC,QANF,EAOEC,WAPF,EAQEC,UARF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AlC,EAAuD;AACrD,YAAM,IAAIrB,KAAJ,CAAU,wEAAV,CAAN;AACD;;AAED,QAAIoB,UAAU,CAACE,UAAX,IAAyB,CAAC5B,QAAQ,CAAC0B,UAAU,CAACE,UAAZ,CAAtC,EAA+D;AAC7D,YAAM,IAAItB,KAAJ,CAAU,4EAAV,CAAN;AACD;;AAEDD,IAAAA,GAAG,CAACoB,6BAAJ,GAAoCrB,OAAO,CAACqB,6BAA5C;AACD;;AAED,MAAIrB,OAAO,CAACyB,eAAZ,EAA6B;AAC3B,QAAI,CAAC9B,QAAQ,CAACK,OAAO,CAACyB,eAAT,CAAb,EAAwC;AACtC,YAAM,IAAIvB,KAAJ,CAAU,iEAAV,CAAN;AACD;;AACDD,IAAAA,GAAG,CAACwB,eAAJ,GAAsBzB,OAAO,CAACyB,eAA9B;AACD;;AAED,SAAOxB,GAAP;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 {\n hasOwnProperty,\n isArray,\n isBoolean,\n isNumber,\n isObject,\n isString,\n isUndefined,\n isValidUrl,\n} from './common';\nimport { RequestOptions } from './types/RequestOptions';\n\nexport function validateAdRequestOptions(options?: RequestOptions) {\n const out: RequestOptions = {};\n\n if (isUndefined(options)) {\n return out;\n }\n\n if (!isObject(options)) {\n throw new Error(\"'options' expected an object value\");\n }\n\n if (hasOwnProperty(options, 'requestNonPersonalizedAdsOnly')) {\n if (!isBoolean(options.requestNonPersonalizedAdsOnly)) {\n throw new Error(\"'options.requestNonPersonalizedAdsOnly' expected a boolean value\");\n }\n\n out.requestNonPersonalizedAdsOnly = options.requestNonPersonalizedAdsOnly;\n }\n\n if (options.networkExtras) {\n if (!isObject(options.networkExtras)) {\n throw new Error(\"'options.networkExtras' expected an object of key/value pairs\");\n }\n\n Object.entries(options.networkExtras).forEach(([key, value]) => {\n if (!isString(value)) {\n throw new Error(`'options.networkExtras' expected a string value for object key \"${key}\"`);\n }\n });\n\n out.networkExtras = options.networkExtras;\n }\n\n if (options.keywords) {\n if (!isArray(options.keywords)) {\n throw new Error(\"'options.keywords' expected an array containing string values\");\n }\n\n for (let i = 0; i < options.keywords.length; i++) {\n const keyword = options.keywords[i];\n\n if (!isString(keyword)) {\n throw new Error(\"'options.keywords' expected an array containing string values\");\n }\n }\n\n out.keywords = options.keywords;\n }\n\n if (options.contentUrl) {\n if (!isString(options.contentUrl)) {\n throw new Error(\"'options.contentUrl' expected a string value\");\n }\n\n if (!isValidUrl(options.contentUrl)) {\n throw new Error(\"'options.contentUrl' expected a valid HTTP or HTTPS url.\");\n }\n\n if (options.contentUrl.length > 512) {\n throw new Error(\"'options.contentUrl' maximum length of a content URL is 512 characters.\");\n }\n\n out.contentUrl = options.contentUrl;\n }\n\n if (options.location) {\n const error = new Error(\n \"'options.location' expected an array value containing a latitude & longitude number value.\",\n );\n\n if (!isArray(options.location)) {\n throw error;\n }\n\n const [latitude, longitude] = options.location;\n\n if (!isNumber(latitude) || !isNumber(longitude)) {\n throw error;\n }\n\n if (latitude < -90 || latitude > 90) {\n throw new Error(\n `'options.location' latitude value must be a number between -90 and 90, but was: ${latitude}`,\n );\n }\n\n if (longitude < -180 || longitude > 180) {\n throw new Error(\n `'options.location' longitude value must be a number between -180 and 180, but was: ${latitude}`,\n );\n }\n\n out.location = [latitude, longitude];\n }\n\n if (hasOwnProperty(options, 'locationAccuracy')) {\n if (!isNumber(options.locationAccuracy)) {\n throw new Error(\"'options.locationAccuracy' expected a number value.\");\n }\n\n if (isNumber(options.locationAccuracy) && options.locationAccuracy < 0) {\n throw new Error(\"'options.locationAccuracy' expected a number greater than 0.\");\n }\n\n out.locationAccuracy = options.locationAccuracy;\n } else {\n out.locationAccuracy = 5;\n }\n\n if (options.requestAgent) {\n if (!isString(options.requestAgent)) {\n throw new Error(\"'options.requestAgent' expected a string value\");\n }\n\n out.requestAgent = options.requestAgent;\n }\n\n if (options.serverSideVerificationOptions) {\n if (!isObject(options.serverSideVerificationOptions)) {\n throw new Error(\n \"'options.serverSideVerificationOptions' expected an object of key/value pairs\",\n );\n }\n\n const ssvOptions = options.serverSideVerificationOptions;\n\n if (ssvOptions.userId && !isString(ssvOptions.userId)) {\n throw new Error(\"'options.serverSideVerificationOptions.userId' expected a string value\");\n }\n\n if (ssvOptions.customData && !isString(ssvOptions.customData)) {\n throw new Error(\"'options.serverSideVerificationOptions.customData' expected a string value\");\n }\n\n out.serverSideVerificationOptions = options.serverSideVerificationOptions;\n }\n\n if (options.customTargeting) {\n if (!isObject(options.customTargeting)) {\n throw new Error(\"'options.customTargeting' expected an object of key/value pairs\");\n }\n out.customTargeting = options.customTargeting;\n }\n\n return out;\n}\n"]}
1
+ {"version":3,"sources":["validateAdRequestOptions.ts"],"names":["hasOwnProperty","isArray","isBoolean","isObject","isString","isUndefined","isValidUrl","validateAdRequestOptions","options","out","Error","requestNonPersonalizedAdsOnly","networkExtras","Object","entries","forEach","key","value","keywords","i","length","keyword","contentUrl","requestAgent","serverSideVerificationOptions","ssvOptions","userId","customData","customTargeting"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SACEA,cADF,EAEEC,OAFF,EAGEC,SAHF,EAIEC,QAJF,EAKEC,QALF,EAMEC,WANF,EAOEC,UAPF,QAQO,UARP;AAWA,OAAO,SAASC,wBAAT,CAAkCC,OAAlC,EAA4D;AACjE,QAAMC,GAAmB,GAAG,EAA5B;;AAEA,MAAIJ,WAAW,CAACG,OAAD,CAAf,EAA0B;AACxB,WAAOC,GAAP;AACD;;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AA+D;AAC7D,YAAM,IAAIjB,KAAJ,CAAU,4EAAV,CAAN;AACD;;AAEDD,IAAAA,GAAG,CAACe,6BAAJ,GAAoChB,OAAO,CAACgB,6BAA5C;AACD;;AAED,MAAIhB,OAAO,CAACoB,eAAZ,EAA6B;AAC3B,QAAI,CAACzB,QAAQ,CAACK,OAAO,CAACoB,eAAT,CAAb,EAAwC;AACtC,YAAM,IAAIlB,KAAJ,CAAU,iEAAV,CAAN;AACD;;AACDD,IAAAA,GAAG,CAACmB,eAAJ,GAAsBpB,OAAO,CAACoB,eAA9B;AACD;;AAED,SAAOnB,GAAP;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 {\n hasOwnProperty,\n isArray,\n isBoolean,\n isObject,\n isString,\n isUndefined,\n isValidUrl,\n} from './common';\nimport { RequestOptions } from './types/RequestOptions';\n\nexport function validateAdRequestOptions(options?: RequestOptions) {\n const out: RequestOptions = {};\n\n if (isUndefined(options)) {\n return out;\n }\n\n if (!isObject(options)) {\n throw new Error(\"'options' expected an object value\");\n }\n\n if (hasOwnProperty(options, 'requestNonPersonalizedAdsOnly')) {\n if (!isBoolean(options.requestNonPersonalizedAdsOnly)) {\n throw new Error(\"'options.requestNonPersonalizedAdsOnly' expected a boolean value\");\n }\n\n out.requestNonPersonalizedAdsOnly = options.requestNonPersonalizedAdsOnly;\n }\n\n if (options.networkExtras) {\n if (!isObject(options.networkExtras)) {\n throw new Error(\"'options.networkExtras' expected an object of key/value pairs\");\n }\n\n Object.entries(options.networkExtras).forEach(([key, value]) => {\n if (!isString(value)) {\n throw new Error(`'options.networkExtras' expected a string value for object key \"${key}\"`);\n }\n });\n\n out.networkExtras = options.networkExtras;\n }\n\n if (options.keywords) {\n if (!isArray(options.keywords)) {\n throw new Error(\"'options.keywords' expected an array containing string values\");\n }\n\n for (let i = 0; i < options.keywords.length; i++) {\n const keyword = options.keywords[i];\n\n if (!isString(keyword)) {\n throw new Error(\"'options.keywords' expected an array containing string values\");\n }\n }\n\n out.keywords = options.keywords;\n }\n\n if (options.contentUrl) {\n if (!isString(options.contentUrl)) {\n throw new Error(\"'options.contentUrl' expected a string value\");\n }\n\n if (!isValidUrl(options.contentUrl)) {\n throw new Error(\"'options.contentUrl' expected a valid HTTP or HTTPS url.\");\n }\n\n if (options.contentUrl.length > 512) {\n throw new Error(\"'options.contentUrl' maximum length of a content URL is 512 characters.\");\n }\n\n out.contentUrl = options.contentUrl;\n }\n\n if (options.requestAgent) {\n if (!isString(options.requestAgent)) {\n throw new Error(\"'options.requestAgent' expected a string value\");\n }\n\n out.requestAgent = options.requestAgent;\n }\n\n if (options.serverSideVerificationOptions) {\n if (!isObject(options.serverSideVerificationOptions)) {\n throw new Error(\n \"'options.serverSideVerificationOptions' expected an object of key/value pairs\",\n );\n }\n\n const ssvOptions = options.serverSideVerificationOptions;\n\n if (ssvOptions.userId && !isString(ssvOptions.userId)) {\n throw new Error(\"'options.serverSideVerificationOptions.userId' expected a string value\");\n }\n\n if (ssvOptions.customData && !isString(ssvOptions.customData)) {\n throw new Error(\"'options.serverSideVerificationOptions.customData' expected a string value\");\n }\n\n out.serverSideVerificationOptions = options.serverSideVerificationOptions;\n }\n\n if (options.customTargeting) {\n if (!isObject(options.customTargeting)) {\n throw new Error(\"'options.customTargeting' expected an object of key/value pairs\");\n }\n out.customTargeting = options.customTargeting;\n }\n\n return out;\n}\n"]}
@@ -1,3 +1,3 @@
1
- // generated by genversion
2
- export const version = '5.1.0';
1
+ // Generated by genversion.
2
+ export const version = '6.0.1';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '5.1.0';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// Generated by genversion.\nexport const version = '6.0.1';\n"]}
@@ -7,10 +7,8 @@ export declare enum AdEventType {
7
7
  * ```js
8
8
  * import { AdEventType } from 'react-native-google-mobile-ads';
9
9
  *
10
- * advert.onAdEvent((type,error,data) => {
11
- * if (type === AdEventType.LOADED) {
12
- * advert.show();
13
- * }
10
+ * advert.addEventListener(AdEventType.LOADED, () => {
11
+ * advert.show();
14
12
  * });
15
13
  * ```
16
14
  */
@@ -23,10 +21,8 @@ export declare enum AdEventType {
23
21
  * ```js
24
22
  * import { AdEventType } from 'react-native-google-mobile-ads';
25
23
  *
26
- * advert.onAdEvent((type, error, data) => {
27
- * if (type === AdEventType.ERROR) {
28
- * console.log('Ad error:', error);
29
- * }
24
+ * advert.addEventListener(AdEventType.ERROR, (error) => {
25
+ * console.log('Ad error:', error);
30
26
  * });
31
27
  * ```
32
28
  */
@@ -0,0 +1,20 @@
1
+ export declare enum GAMAdEventType {
2
+ /**
3
+ * An event fired when the ad received Ad Manager specific app event.
4
+ *
5
+ * The app event contains a `name` and `data`. `data` could be undefeined.
6
+ *
7
+ * #### Example
8
+ *
9
+ * ```js
10
+ * import { GAMAdEventType } from 'react-native-google-mobile-ads';
11
+ *
12
+ * interstitialAd.onAdEvent((type, error, data) => {
13
+ * if (type === GAMAdEventType.APP_EVENT) {
14
+ * console.log(`Received app event: ${data.name} with data: ${data.data}`);
15
+ * }
16
+ * });
17
+ * ```
18
+ */
19
+ APP_EVENT = "app_event"
20
+ }
@@ -4,8 +4,9 @@ import { RequestConfiguration } from './types/RequestConfiguration';
4
4
  import { App, Config } from './types/Module.interface';
5
5
  declare class MobileAdsModule extends Module implements MobileAdsModuleInterface {
6
6
  constructor(app: App, config: Config);
7
- initialize(): Promise<import("./types/AdapterStatus").AdapterStatus[]>;
7
+ initialize(): Promise<import("./types").AdapterStatus[]>;
8
8
  setRequestConfiguration(requestConfiguration: RequestConfiguration): Promise<void>;
9
+ openAdInspector(): Promise<void>;
9
10
  }
10
11
  export declare const MobileAds: () => MobileAdsModule;
11
12
  export default MobileAds;
@@ -13,12 +13,10 @@ export declare enum RewardedAdEventType {
13
13
  * ```js
14
14
  * import { RewardedAdEventType } from 'react-native-google-mobile-ads';
15
15
  *
16
- * rewardedAd.onAdEvent((type, error, data) => {
17
- * if (type === RewardedAdEventType.LOADED) {
18
- * console.log(`Rewarded Ad loaded with ${data.amount} ${data.type} as reward`);
19
- * // E.g. "Rewarded Ad loaded with 50 coins as reward"
20
- * rewardedAd.show();
21
- * }
16
+ * rewardedAd.addEventListener(RewardedAdEventType.LOADED, (reward) => {
17
+ * console.log(`Rewarded Ad loaded with ${data.amount} ${data.type} as reward`);
18
+ * // E.g. "Rewarded Ad loaded with 50 coins as reward"
19
+ * rewardedAd.show();
22
20
  * });
23
21
  * ```
24
22
  */
@@ -34,11 +32,9 @@ export declare enum RewardedAdEventType {
34
32
  * ```js
35
33
  * import { RewardedAdEventType } from 'react-native-google-mobile-ads';
36
34
  *
37
- * rewardedAd.onAdEvent((type, error, data) => {
38
- * if (type === RewardedAdEventType.EARNED_REWARD) {
39
- * console.log(`User earned ${data.amount} ${data.type}`);
40
- * // E.g. "User earned 50 coins"
41
- * }
35
+ * rewardedAd.addEventListener(RewardedAdEventType.EARNED_REWARD, (reward) => {
36
+ * console.log(`User earned ${data.amount} ${data.type}`);
37
+ * // E.g. "User earned 50 coins"
42
38
  * });
43
39
  * ```
44
40
  */
@@ -3,4 +3,9 @@ export declare const TestIds: {
3
3
  BANNER: string;
4
4
  INTERSTITIAL: string;
5
5
  REWARDED: string;
6
+ GAM_APP_OPEN: string;
7
+ GAM_BANNER: string;
8
+ GAM_INTERSTITIAL: string;
9
+ GAM_REWARDED: string;
10
+ GAM_NATIVE: string;
6
11
  };
@@ -1,11 +1,11 @@
1
1
  import { MobileAd } from './MobileAd';
2
+ import { AdEventType } from '../AdEventType';
2
3
  import { AdEventListener } from '../types/AdEventListener';
3
- import { AdShowOptions } from '../types/AdShowOptions';
4
+ import { AdEventsListener } from '../types/AdEventsListener';
4
5
  import { RequestOptions } from '../types/RequestOptions';
5
- import { MobileAdInterface } from '../types/MobileAd.interface';
6
- export declare class AppOpenAd extends MobileAd implements MobileAdInterface {
6
+ export declare class AppOpenAd extends MobileAd {
7
+ protected static _appOpenRequest: number;
7
8
  static createForAdRequest(adUnitId: string, requestOptions?: RequestOptions): AppOpenAd;
8
- load(): void;
9
- onAdEvent(handler: AdEventListener): () => null;
10
- show(showOptions?: AdShowOptions): Promise<void>;
9
+ addAdEventsListener<T extends AdEventType>(listener: AdEventsListener<T>): () => void;
10
+ addAdEventListener<T extends AdEventType>(type: T, listener: AdEventListener<T>): () => void;
11
11
  }
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { BannerAdProps } from '../types/BannerAdProps';
3
- export declare function BannerAd({ unitId, size, requestOptions, ...props }: BannerAdProps): JSX.Element;
3
+ export declare function BannerAd({ size, ...props }: BannerAdProps): JSX.Element;
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { NativeMethods } from 'react-native';
3
+ import { GAMBannerAdProps } from '../types/BannerAdProps';
4
+ import { RequestOptions } from '../types/RequestOptions';
5
+ declare type NativeEvent = {
6
+ type: 'onAdLoaded' | 'onSizeChange';
7
+ width: number;
8
+ height: number;
9
+ } | {
10
+ type: 'onAdOpened' | 'onAdClosed';
11
+ } | {
12
+ type: 'onAdFailedToLoad';
13
+ code: string;
14
+ message: string;
15
+ } | {
16
+ type: 'onAppEvent';
17
+ name: string;
18
+ data?: string;
19
+ };
20
+ export declare const BaseAd: React.ForwardRefExoticComponent<GAMBannerAdProps & React.RefAttributes<GoogleMobileAdsBannerView>>;
21
+ interface NativeBannerProps {
22
+ sizes: GAMBannerAdProps['sizes'];
23
+ style: {
24
+ width?: number | string;
25
+ height?: number | string;
26
+ };
27
+ unitId: string;
28
+ request: RequestOptions;
29
+ manualImpressionsEnabled: boolean;
30
+ onNativeEvent: (event: {
31
+ nativeEvent: NativeEvent;
32
+ }) => void;
33
+ }
34
+ export declare type GoogleMobileAdsBannerView = React.Component<NativeBannerProps> & NativeMethods;
35
+ export {};
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { GAMBannerAdProps } from '../types/BannerAdProps';
3
+ export declare class GAMBannerAd extends React.Component<GAMBannerAdProps> {
4
+ private ref;
5
+ recordManualImpression(): void;
6
+ render(): JSX.Element;
7
+ }
@@ -0,0 +1,33 @@
1
+ import { AdEventType } from '../AdEventType';
2
+ import { GAMAdEventType } from '../GAMAdEventType';
3
+ import { AdEventListener } from '../types/AdEventListener';
4
+ import { AdEventsListener } from '../types/AdEventsListener';
5
+ import { RequestOptions } from '../types/RequestOptions';
6
+ import { InterstitialAd } from './InterstitialAd';
7
+ export declare class GAMInterstitialAd extends InterstitialAd {
8
+ /**
9
+ * Creates a new GAMInterstitialAd instance.
10
+ *
11
+ * #### Example
12
+ *
13
+ * ```js
14
+ * import { GAMInterstitialAd, AdEventType, TestIds } from 'react-native-google-mobile-ads';
15
+ *
16
+ * const interstitialAd = await GAMInterstitialAd.createForAdRequest(TestIds.GAM_INTERSTITIAL, {
17
+ * requestAgent: 'CoolAds',
18
+ * });
19
+ *
20
+ * interstitialAd.addAdEventListener(AdEventType.Loaded, () => {
21
+ * interstitialAd.show();
22
+ * });
23
+ *
24
+ * interstitialAd.load();
25
+ * ```
26
+ *
27
+ * @param adUnitId The Ad Unit ID for the Interstitial. You can find this on your Google Mobile Ads dashboard.
28
+ * @param requestOptions Optional RequestOptions used to load the ad.
29
+ */
30
+ static createForAdRequest(adUnitId: string, requestOptions?: RequestOptions): GAMInterstitialAd;
31
+ addAdEventsListener<T extends AdEventType | GAMAdEventType>(listener: AdEventsListener<T>): () => void;
32
+ addAdEventListener<T extends AdEventType | GAMAdEventType>(type: T, listener: AdEventListener<T>): () => void;
33
+ }
@@ -1,8 +1,8 @@
1
1
  import { MobileAd } from './MobileAd';
2
+ import { AdEventType } from '../AdEventType';
2
3
  import { AdEventListener } from '../types/AdEventListener';
3
- import { AdShowOptions } from '../types/AdShowOptions';
4
+ import { AdEventsListener } from '../types/AdEventsListener';
4
5
  import { RequestOptions } from '../types/RequestOptions';
5
- import { MobileAdInterface } from '../types/MobileAd.interface';
6
6
  /**
7
7
  * A class for interacting and showing Interstitial Ads.
8
8
  *
@@ -32,10 +32,8 @@ import { MobileAdInterface } from '../types/MobileAd.interface';
32
32
  * ```js
33
33
  * import { AdEventType } from 'react-native-google-mobile-ads';
34
34
  *
35
- * interstitial.onAdEvent((type) => {
36
- * if (type === AdEventType.LOADED) {
37
- * interstitial.show();
38
- * }
35
+ * interstitialAd.addAdEventListener(AdEventType.Loaded, () => {
36
+ * interstitialAd.show();
39
37
  * });
40
38
  *
41
39
  * interstitial.load();
@@ -44,7 +42,8 @@ import { MobileAdInterface } from '../types/MobileAd.interface';
44
42
  * The advert will be presented to the user, and several more events can be triggered such as the user clicking the
45
43
  * advert or closing it.
46
44
  */
47
- export declare class InterstitialAd extends MobileAd implements MobileAdInterface {
45
+ export declare class InterstitialAd extends MobileAd {
46
+ protected static _interstitialRequest: number;
48
47
  /**
49
48
  * Creates a new InterstitialAd instance.
50
49
  *
@@ -57,12 +56,8 @@ export declare class InterstitialAd extends MobileAd implements MobileAdInterfac
57
56
  * requestAgent: 'CoolAds',
58
57
  * });
59
58
  *
60
- * interstitialAd.onAdEvent((type, error) => {
61
- * console.log('New event: ', type, error);
62
- *
63
- * if (type === AdEventType.LOADED) {
64
- * interstitialAd.show();
65
- * }
59
+ * interstitialAd.addAdEventListener(AdEventType.Loaded, () => {
60
+ * interstitialAd.show();
66
61
  * });
67
62
  *
68
63
  * interstitialAd.load();
@@ -72,7 +67,6 @@ export declare class InterstitialAd extends MobileAd implements MobileAdInterfac
72
67
  * @param requestOptions Optional RequestOptions used to load the ad.
73
68
  */
74
69
  static createForAdRequest(adUnitId: string, requestOptions?: RequestOptions): InterstitialAd;
75
- load(): void;
76
- onAdEvent(handler: AdEventListener): () => null;
77
- show(showOptions?: AdShowOptions): Promise<void>;
70
+ addAdEventsListener<T extends AdEventType>(listener: AdEventsListener<T>): () => void;
71
+ addAdEventListener<T extends AdEventType>(type: T, listener: AdEventListener<T>): () => void;
78
72
  }
@@ -1,32 +1,50 @@
1
1
  import { EmitterSubscription } from 'react-native';
2
- import { RewardedAdEventType } from '../RewardedAdEventType';
3
2
  import { AdEventType } from '../AdEventType';
3
+ import { RewardedAdEventType } from '../RewardedAdEventType';
4
4
  import { AdEventListener } from '../types/AdEventListener';
5
+ import { AdEventsListener } from '../types/AdEventsListener';
6
+ import { AdShowOptions } from '../types/AdShowOptions';
5
7
  import { RequestOptions } from '../types/RequestOptions';
8
+ import { MobileAdInterface } from '../types/MobileAd.interface';
6
9
  import { MobileAdsModuleInterface } from '../types/MobileAdsModule.interface';
7
10
  import { RewardedAdReward } from '../types/RewardedAdReward';
8
- export declare class MobileAd {
9
- _type: 'app_open' | 'interstitial' | 'rewarded';
10
- _googleMobileAds: MobileAdsModuleInterface;
11
- _requestId: number;
12
- _adUnitId: string;
13
- _requestOptions: RequestOptions;
14
- _loaded: boolean;
15
- _isLoadCalled: boolean;
16
- _onAdEventHandler: AdEventListener | null;
17
- _nativeListener: EmitterSubscription;
18
- constructor(type: 'app_open' | 'interstitial' | 'rewarded', googleMobileAds: MobileAdsModuleInterface, requestId: number, adUnitId: string, requestOptions: RequestOptions);
19
- _handleAdEvent(event: {
11
+ import { GAMAdEventType } from '../GAMAdEventType';
12
+ import { AppEvent } from '../types/AppEvent';
13
+ declare type EventType = AdEventType | RewardedAdEventType | GAMAdEventType;
14
+ export declare abstract class MobileAd implements MobileAdInterface {
15
+ protected _type: 'app_open' | 'interstitial' | 'rewarded';
16
+ protected _googleMobileAds: MobileAdsModuleInterface;
17
+ protected _requestId: number;
18
+ protected _adUnitId: string;
19
+ protected _requestOptions: RequestOptions;
20
+ protected _loaded: boolean;
21
+ protected _isLoadCalled: boolean;
22
+ protected _adEventsListeners: Map<number, AdEventsListener<EventType>>;
23
+ protected _adEventListenersMap: Map<EventType, Map<number, AdEventListener<EventType>>>;
24
+ protected _adEventsListenerId: number;
25
+ protected _adEventListenerId: number;
26
+ protected _nativeListener: EmitterSubscription;
27
+ protected constructor(type: 'app_open' | 'interstitial' | 'rewarded', googleMobileAds: MobileAdsModuleInterface, requestId: number, adUnitId: string, requestOptions: RequestOptions);
28
+ protected _handleAdEvent(event: {
20
29
  body: {
21
- type: AdEventType | RewardedAdEventType;
30
+ type: EventType;
22
31
  error?: {
23
32
  code: string;
24
33
  message: string;
25
34
  };
26
- data?: RewardedAdReward;
35
+ data?: RewardedAdReward | AppEvent;
27
36
  };
28
37
  }): void;
29
- _setAdEventHandler(handler: AdEventListener): () => null;
38
+ protected _addAdEventsListener<T extends EventType>(listener: AdEventsListener<T>): () => void;
39
+ protected _addAdEventListener<T extends EventType>(type: T, listener: AdEventListener<T>): () => void;
40
+ protected _getAdEventListeners<T extends EventType>(type: T): Map<number, AdEventListener<T>>;
41
+ protected get _className(): string;
42
+ load(): void;
43
+ show(showOptions?: AdShowOptions): Promise<void>;
44
+ abstract addAdEventsListener<T extends never>(listener: AdEventsListener<T>): () => void;
45
+ abstract addAdEventListener<T extends never>(type: T, listener: AdEventListener<T>): void;
46
+ removeAllListeners(): void;
30
47
  get adUnitId(): string;
31
48
  get loaded(): boolean;
32
49
  }
50
+ export {};
@@ -1,8 +1,9 @@
1
1
  import { MobileAd } from './MobileAd';
2
+ import { AdEventType } from '../AdEventType';
3
+ import { RewardedAdEventType } from '../RewardedAdEventType';
2
4
  import { AdEventListener } from '../types/AdEventListener';
3
- import { AdShowOptions } from '../types/AdShowOptions';
5
+ import { AdEventsListener } from '../types/AdEventsListener';
4
6
  import { RequestOptions } from '../types/RequestOptions';
5
- import { MobileAdInterface } from '../types/MobileAd.interface';
6
7
  /**
7
8
  * A class for interacting and showing Rewarded Ads.
8
9
  *
@@ -35,13 +36,11 @@ import { MobileAdInterface } from '../types/MobileAd.interface';
35
36
  * ```js
36
37
  * import { RewardedAdEventType } from 'react-native-google-mobile-ads';
37
38
  *
38
- * rewarded.onAdEvent((type, error, reward) => {
39
- * if (type === RewardedAdEventType.LOADED) {
40
- * rewarded.show();
41
- * }
42
- * if (type === RewardedAdEventType.EARNED_REWARD) {
43
- * console.log('User earned reward of ', reward);
44
- * }
39
+ * rewarded.addAdEventListener(RewardedAdEventType.LOADED. () => {
40
+ * rewarded.show();
41
+ * });
42
+ * rewarded.addAdEventListener(RewardedAdEventType.EARNED_REWARD. (reward) => {
43
+ * console.log('User earned reward of ', reward);
45
44
  * });
46
45
  *
47
46
  * rewarded.load();
@@ -50,7 +49,8 @@ import { MobileAdInterface } from '../types/MobileAd.interface';
50
49
  * The rewarded advert will be presented to the user, and several more events can be triggered such as the user clicking the
51
50
  * advert, closing it or completing the action.
52
51
  */
53
- export declare class RewardedAd extends MobileAd implements MobileAdInterface {
52
+ export declare class RewardedAd extends MobileAd {
53
+ protected static _rewardedRequest: number;
54
54
  /**
55
55
  * Creates a new RewardedAd instance.
56
56
  *
@@ -63,12 +63,11 @@ export declare class RewardedAd extends MobileAd implements MobileAdInterface {
63
63
  * requestAgent: 'CoolAds',
64
64
  * });
65
65
  *
66
- * rewardedAd.onAdEvent((type, error, data) => {
67
- * console.log('New event: ', type, error);
68
- *
69
- * if (type === RewardedAdEventType.LOADED) {
70
- * rewardedAd.show();
71
- * }
66
+ * rewarded.addAdEventListener(RewardedAdEventType.LOADED. () => {
67
+ * rewarded.show();
68
+ * });
69
+ * rewarded.addAdEventListener(RewardedAdEventType.EARNED_REWARD. (reward) => {
70
+ * console.log('User earned reward of ', reward);
72
71
  * });
73
72
  *
74
73
  * rewardedAd.load();
@@ -78,7 +77,6 @@ export declare class RewardedAd extends MobileAd implements MobileAdInterface {
78
77
  * @param requestOptions Optional RequestOptions used to load the ad.
79
78
  */
80
79
  static createForAdRequest(adUnitId: string, requestOptions?: RequestOptions): RewardedAd;
81
- load(): void;
82
- onAdEvent(handler: AdEventListener): () => null;
83
- show(showOptions?: AdShowOptions): Promise<void>;
80
+ addAdEventsListener<T extends AdEventType | RewardedAdEventType>(listener: AdEventsListener<T>): () => void;
81
+ addAdEventListener<T extends AdEventType | RewardedAdEventType>(type: T, listener: AdEventListener<T>): () => void;
84
82
  }
@@ -6,4 +6,4 @@ import { RequestOptions } from '../types/RequestOptions';
6
6
  * @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.
7
7
  * @param requestOptions Optional RequestOptions used to load the ad.
8
8
  */
9
- export declare function useAppOpenAd(adUnitId: string | null, requestOptions?: RequestOptions): Omit<AdHookReturns, 'adReward'>;
9
+ export declare function useAppOpenAd(adUnitId: string | null, requestOptions?: RequestOptions): Omit<AdHookReturns, 'reward' | 'isEarnedReward'>;
@@ -6,4 +6,4 @@ import { RequestOptions } from '../types/RequestOptions';
6
6
  * @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.
7
7
  * @param requestOptions Optional RequestOptions used to load the ad.
8
8
  */
9
- export declare function useInterstitialAd(adUnitId: string | null, requestOptions?: RequestOptions): Omit<AdHookReturns, 'adReward'>;
9
+ export declare function useInterstitialAd(adUnitId: string | null, requestOptions?: RequestOptions): Omit<AdHookReturns, 'reward' | 'isEarnedReward'>;
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "5.1.0";
1
+ export declare const SDK_VERSION = "6.0.1";
2
2
  export { default, MobileAds } from './MobileAds';
3
3
  export { AdsConsentDebugGeography } from './AdsConsentDebugGeography';
4
4
  export { AdsConsentPurposes } from './AdsConsentPurposes';
@@ -8,12 +8,16 @@ export { MaxAdContentRating } from './MaxAdContentRating';
8
8
  export { TestIds } from './TestIds';
9
9
  export { AdEventType } from './AdEventType';
10
10
  export { BannerAdSize } from './BannerAdSize';
11
+ export { GAMAdEventType } from './GAMAdEventType';
11
12
  export { RewardedAdEventType } from './RewardedAdEventType';
12
13
  export { AdsConsent } from './AdsConsent';
13
14
  export { AppOpenAd } from './ads/AppOpenAd';
14
15
  export { InterstitialAd } from './ads/InterstitialAd';
15
16
  export { RewardedAd } from './ads/RewardedAd';
16
17
  export { BannerAd } from './ads/BannerAd';
18
+ export { GAMBannerAd } from './ads/GAMBannerAd';
19
+ export { GAMInterstitialAd } from './ads/GAMInterstitialAd';
17
20
  export { useAppOpenAd } from './hooks/useAppOpenAd';
18
21
  export { useInterstitialAd } from './hooks/useInterstitialAd';
19
22
  export { useRewardedAd } from './hooks/useRewardedAd';
23
+ export * from './types';
@@ -1,11 +1,7 @@
1
1
  import { AdEventType } from '../AdEventType';
2
- import { RewardedAdReward } from './RewardedAdReward';
2
+ import { GAMAdEventType } from '../GAMAdEventType';
3
3
  import { RewardedAdEventType } from '../RewardedAdEventType';
4
- /**
5
- * A callback interface for all ad events.
6
- *
7
- * @param type The event type, e.g. `AdEventType.LOADED`.
8
- * @param error An optional JavaScript Error containing the error code and message.
9
- * @param data Optional data for the event, e.g. reward type and amount
10
- */
11
- export declare type AdEventListener = (type: AdEventType | RewardedAdEventType, error?: Error, data?: RewardedAdReward) => void;
4
+ import { AppEvent } from './AppEvent';
5
+ import { RewardedAdReward } from './RewardedAdReward';
6
+ export declare type AdEventPayload<T extends AdEventType | RewardedAdEventType | GAMAdEventType = never> = T extends AdEventType.ERROR ? Error : T extends RewardedAdEventType ? RewardedAdReward : T extends GAMAdEventType ? AppEvent : undefined;
7
+ export declare type AdEventListener<T extends AdEventType | RewardedAdEventType | GAMAdEventType = never> = (payload: AdEventPayload<T>) => void;
@@ -0,0 +1,8 @@
1
+ import { AdEventType } from '../AdEventType';
2
+ import { GAMAdEventType } from '../GAMAdEventType';
3
+ import { RewardedAdEventType } from '../RewardedAdEventType';
4
+ import { AdEventPayload } from './AdEventListener';
5
+ export declare type AdEventsListener<T extends AdEventType | RewardedAdEventType | GAMAdEventType = never> = (eventInfo: {
6
+ type: T;
7
+ payload: AdEventPayload<T>;
8
+ }) => void;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * An app event received from Google Ad Manager ads.
3
+ */
4
+ export interface AppEvent {
5
+ /**
6
+ * The event name.
7
+ */
8
+ name: string;
9
+ /**
10
+ * The data received with the app event.
11
+ */
12
+ data?: string;
13
+ }