react-native-google-mobile-ads 5.1.1 → 6.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 (176) hide show
  1. package/__tests__/interstitial.test.ts +32 -5
  2. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsAppOpenModule.java +2 -1
  3. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsBannerAdViewManager.java +110 -68
  4. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java +5 -11
  5. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsEvent.java +3 -0
  6. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsInterstitialModule.java +38 -20
  7. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsModule.java +45 -0
  8. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsPackage.java +1 -0
  9. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsRewardedInterstitialModule.java +199 -0
  10. package/docs/ad-inspector.mdx +39 -0
  11. package/docs/displaying-ads-hook.mdx +1 -1
  12. package/docs/displaying-ads.mdx +178 -26
  13. package/docs/migrating-to-v6.mdx +111 -0
  14. package/docs.json +3 -1
  15. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.m +1 -0
  16. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerViewManager.m +63 -8
  17. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.h +4 -0
  18. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m +10 -7
  19. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.h +2 -1
  20. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.m +17 -2
  21. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.m +44 -30
  22. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.m +19 -0
  23. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedInterstitialModule.h +25 -0
  24. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedInterstitialModule.m +173 -0
  25. package/lib/commonjs/AdEventType.js.map +1 -1
  26. package/lib/commonjs/GAMAdEventType.js +30 -0
  27. package/lib/commonjs/GAMAdEventType.js.map +1 -0
  28. package/lib/commonjs/MobileAds.js +9 -2
  29. package/lib/commonjs/MobileAds.js.map +1 -1
  30. package/lib/commonjs/RewardedAdEventType.js.map +1 -1
  31. package/lib/commonjs/TestIds.js +11 -2
  32. package/lib/commonjs/TestIds.js.map +1 -1
  33. package/lib/commonjs/ads/AppOpenAd.js +8 -53
  34. package/lib/commonjs/ads/AppOpenAd.js.map +1 -1
  35. package/lib/commonjs/ads/BannerAd.js +7 -110
  36. package/lib/commonjs/ads/BannerAd.js.map +1 -1
  37. package/lib/commonjs/ads/BaseAd.js +144 -0
  38. package/lib/commonjs/ads/BaseAd.js.map +1 -0
  39. package/lib/commonjs/ads/GAMBannerAd.js +42 -0
  40. package/lib/commonjs/ads/GAMBannerAd.js.map +1 -0
  41. package/lib/commonjs/ads/GAMInterstitialAd.js +48 -0
  42. package/lib/commonjs/ads/GAMInterstitialAd.js.map +1 -0
  43. package/lib/commonjs/ads/InterstitialAd.js +13 -64
  44. package/lib/commonjs/ads/InterstitialAd.js.map +1 -1
  45. package/lib/commonjs/ads/MobileAd.js +131 -12
  46. package/lib/commonjs/ads/MobileAd.js.map +1 -1
  47. package/lib/commonjs/ads/RewardedAd.js +23 -65
  48. package/lib/commonjs/ads/RewardedAd.js.map +1 -1
  49. package/lib/commonjs/ads/RewardedInterstitialAd.js +127 -0
  50. package/lib/commonjs/ads/RewardedInterstitialAd.js.map +1 -0
  51. package/lib/commonjs/hooks/useAppOpenAd.js.map +1 -1
  52. package/lib/commonjs/hooks/useFullScreenAd.js +9 -4
  53. package/lib/commonjs/hooks/useFullScreenAd.js.map +1 -1
  54. package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -1
  55. package/lib/commonjs/hooks/useRewardedAd.js.map +1 -1
  56. package/lib/commonjs/hooks/useRewardedInterstitialAd.js +51 -0
  57. package/lib/commonjs/hooks/useRewardedInterstitialAd.js.map +1 -0
  58. package/lib/commonjs/index.js +80 -0
  59. package/lib/commonjs/index.js.map +1 -1
  60. package/lib/commonjs/types/AdEventsListener.js +6 -0
  61. package/lib/commonjs/types/AdEventsListener.js.map +1 -0
  62. package/lib/commonjs/types/AppEvent.js +2 -0
  63. package/lib/commonjs/types/AppEvent.js.map +1 -0
  64. package/lib/commonjs/types/index.js +149 -0
  65. package/lib/commonjs/types/index.js.map +1 -0
  66. package/lib/commonjs/validateAdRequestOptions.js +0 -38
  67. package/lib/commonjs/validateAdRequestOptions.js.map +1 -1
  68. package/lib/commonjs/version.js +2 -2
  69. package/lib/commonjs/version.js.map +1 -1
  70. package/lib/module/AdEventType.js.map +1 -1
  71. package/lib/module/GAMAdEventType.js +22 -0
  72. package/lib/module/GAMAdEventType.js.map +1 -0
  73. package/lib/module/MobileAds.js +9 -2
  74. package/lib/module/MobileAds.js.map +1 -1
  75. package/lib/module/RewardedAdEventType.js.map +1 -1
  76. package/lib/module/TestIds.js +11 -2
  77. package/lib/module/TestIds.js.map +1 -1
  78. package/lib/module/ads/AppOpenAd.js +10 -37
  79. package/lib/module/ads/AppOpenAd.js.map +1 -1
  80. package/lib/module/ads/BannerAd.js +7 -85
  81. package/lib/module/ads/BannerAd.js.map +1 -1
  82. package/lib/module/ads/BaseAd.js +124 -0
  83. package/lib/module/ads/BaseAd.js.map +1 -0
  84. package/lib/module/ads/GAMBannerAd.js +42 -0
  85. package/lib/module/ads/GAMBannerAd.js.map +1 -0
  86. package/lib/module/ads/GAMInterstitialAd.js +38 -0
  87. package/lib/module/ads/GAMInterstitialAd.js.map +1 -0
  88. package/lib/module/ads/InterstitialAd.js +15 -48
  89. package/lib/module/ads/InterstitialAd.js.map +1 -1
  90. package/lib/module/ads/MobileAd.js +128 -12
  91. package/lib/module/ads/MobileAd.js.map +1 -1
  92. package/lib/module/ads/RewardedAd.js +24 -49
  93. package/lib/module/ads/RewardedAd.js.map +1 -1
  94. package/lib/module/ads/RewardedInterstitialAd.js +130 -0
  95. package/lib/module/ads/RewardedInterstitialAd.js.map +1 -0
  96. package/lib/module/hooks/useAppOpenAd.js.map +1 -1
  97. package/lib/module/hooks/useFullScreenAd.js +9 -4
  98. package/lib/module/hooks/useFullScreenAd.js.map +1 -1
  99. package/lib/module/hooks/useInterstitialAd.js.map +1 -1
  100. package/lib/module/hooks/useRewardedAd.js.map +1 -1
  101. package/lib/module/hooks/useRewardedInterstitialAd.js +38 -0
  102. package/lib/module/hooks/useRewardedInterstitialAd.js.map +1 -0
  103. package/lib/module/index.js +6 -0
  104. package/lib/module/index.js.map +1 -1
  105. package/lib/module/types/AdEventsListener.js +2 -0
  106. package/lib/module/types/AdEventsListener.js.map +1 -0
  107. package/lib/module/types/AppEvent.js +2 -0
  108. package/lib/module/types/AppEvent.js.map +1 -0
  109. package/lib/module/types/index.js +28 -0
  110. package/lib/module/types/index.js.map +1 -0
  111. package/lib/module/validateAdRequestOptions.js +1 -39
  112. package/lib/module/validateAdRequestOptions.js.map +1 -1
  113. package/lib/module/version.js +2 -2
  114. package/lib/module/version.js.map +1 -1
  115. package/lib/typescript/AdEventType.d.ts +4 -8
  116. package/lib/typescript/GAMAdEventType.d.ts +20 -0
  117. package/lib/typescript/MobileAds.d.ts +2 -1
  118. package/lib/typescript/RewardedAdEventType.d.ts +7 -11
  119. package/lib/typescript/TestIds.d.ts +7 -0
  120. package/lib/typescript/ads/AppOpenAd.d.ts +6 -6
  121. package/lib/typescript/ads/BannerAd.d.ts +1 -1
  122. package/lib/typescript/ads/BaseAd.d.ts +35 -0
  123. package/lib/typescript/ads/GAMBannerAd.d.ts +7 -0
  124. package/lib/typescript/ads/GAMInterstitialAd.d.ts +33 -0
  125. package/lib/typescript/ads/InterstitialAd.d.ts +10 -16
  126. package/lib/typescript/ads/MobileAd.d.ts +35 -16
  127. package/lib/typescript/ads/RewardedAd.d.ts +17 -19
  128. package/lib/typescript/ads/RewardedInterstitialAd.d.ts +82 -0
  129. package/lib/typescript/hooks/useAppOpenAd.d.ts +1 -1
  130. package/lib/typescript/hooks/useFullScreenAd.d.ts +2 -1
  131. package/lib/typescript/hooks/useInterstitialAd.d.ts +1 -1
  132. package/lib/typescript/hooks/useRewardedAd.d.ts +1 -1
  133. package/lib/typescript/hooks/useRewardedInterstitialAd.d.ts +9 -0
  134. package/lib/typescript/index.d.ts +7 -1
  135. package/lib/typescript/types/AdEventListener.d.ts +5 -9
  136. package/lib/typescript/types/AdEventsListener.d.ts +8 -0
  137. package/lib/typescript/types/AppEvent.d.ts +13 -0
  138. package/lib/typescript/types/BannerAdProps.d.ts +81 -4
  139. package/lib/typescript/types/GoogleMobileAdsNativeModule.d.ts +12 -6
  140. package/lib/typescript/types/MobileAd.interface.d.ts +37 -12
  141. package/lib/typescript/types/MobileAdsModule.interface.d.ts +9 -0
  142. package/lib/typescript/types/RequestOptions.d.ts +0 -22
  143. package/lib/typescript/types/index.d.ts +11 -0
  144. package/lib/typescript/version.d.ts +1 -1
  145. package/package.json +50 -49
  146. package/src/AdEventType.ts +4 -8
  147. package/src/GAMAdEventType.ts +37 -0
  148. package/src/MobileAds.ts +13 -0
  149. package/src/RewardedAdEventType.ts +7 -11
  150. package/src/TestIds.ts +9 -0
  151. package/src/ads/AppOpenAd.ts +11 -41
  152. package/src/ads/BannerAd.tsx +4 -106
  153. package/src/ads/BaseAd.tsx +156 -0
  154. package/src/ads/GAMBannerAd.tsx +37 -0
  155. package/src/ads/GAMInterstitialAd.ts +45 -0
  156. package/src/ads/InterstitialAd.ts +15 -56
  157. package/src/ads/MobileAd.ts +153 -30
  158. package/src/ads/RewardedAd.ts +29 -55
  159. package/src/ads/RewardedInterstitialAd.ts +143 -0
  160. package/src/hooks/useAppOpenAd.ts +1 -1
  161. package/src/hooks/useFullScreenAd.ts +9 -7
  162. package/src/hooks/useInterstitialAd.ts +1 -1
  163. package/src/hooks/useRewardedAd.ts +1 -1
  164. package/src/hooks/useRewardedInterstitialAd.ts +47 -0
  165. package/src/index.ts +6 -0
  166. package/src/types/AdEventListener.ts +31 -13
  167. package/src/types/AdEventsListener.ts +24 -0
  168. package/src/types/AppEvent.ts +14 -0
  169. package/src/types/BannerAdProps.ts +81 -4
  170. package/src/types/GoogleMobileAdsNativeModule.ts +16 -6
  171. package/src/types/MobileAd.interface.ts +56 -12
  172. package/src/types/MobileAdsModule.interface.ts +10 -0
  173. package/src/types/RequestOptions.ts +0 -24
  174. package/src/types/index.ts +28 -0
  175. package/src/validateAdRequestOptions.ts +0 -45
  176. package/src/version.ts +2 -2
@@ -1,16 +1,34 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
1
18
  import { AdEventType } from '../AdEventType';
2
- import { RewardedAdReward } from './RewardedAdReward';
19
+ import { GAMAdEventType } from '../GAMAdEventType';
3
20
  import { RewardedAdEventType } from '../RewardedAdEventType';
21
+ import { AppEvent } from './AppEvent';
22
+ import { RewardedAdReward } from './RewardedAdReward';
4
23
 
5
- /**
6
- * A callback interface for all ad events.
7
- *
8
- * @param type The event type, e.g. `AdEventType.LOADED`.
9
- * @param error An optional JavaScript Error containing the error code and message.
10
- * @param data Optional data for the event, e.g. reward type and amount
11
- */
12
- export type AdEventListener = (
13
- type: AdEventType | RewardedAdEventType,
14
- error?: Error,
15
- data?: RewardedAdReward,
16
- ) => void;
24
+ export type AdEventPayload<T extends AdEventType | RewardedAdEventType | GAMAdEventType = never> =
25
+ T extends AdEventType.ERROR
26
+ ? Error
27
+ : T extends RewardedAdEventType
28
+ ? RewardedAdReward
29
+ : T extends GAMAdEventType
30
+ ? AppEvent
31
+ : undefined;
32
+
33
+ export type AdEventListener<T extends AdEventType | RewardedAdEventType | GAMAdEventType = never> =
34
+ (payload: AdEventPayload<T>) => void;
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ import { AdEventType } from '../AdEventType';
19
+ import { GAMAdEventType } from '../GAMAdEventType';
20
+ import { RewardedAdEventType } from '../RewardedAdEventType';
21
+ import { AdEventPayload } from './AdEventListener';
22
+
23
+ export type AdEventsListener<T extends AdEventType | RewardedAdEventType | GAMAdEventType = never> =
24
+ (eventInfo: { type: T; payload: AdEventPayload<T> }) => void;
@@ -0,0 +1,14 @@
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
+ /**
11
+ * The data received with the app event.
12
+ */
13
+ data?: string;
14
+ }
@@ -1,4 +1,5 @@
1
1
  import { BannerAdSize } from '../BannerAdSize';
2
+ import { AppEvent } from './AppEvent';
2
3
  import { RequestOptions } from './RequestOptions';
3
4
 
4
5
  /**
@@ -33,7 +34,7 @@ import { RequestOptions } from './RequestOptions';
33
34
  * }
34
35
  * ```
35
36
  */
36
- export type BannerAdProps = {
37
+ export interface BannerAdProps {
37
38
  /**
38
39
  * The Google Mobile Ads unit ID for the banner.
39
40
  */
@@ -44,7 +45,7 @@ export type BannerAdProps = {
44
45
  *
45
46
  * Inventory must be available for the banner size specified, otherwise a no-fill error will be sent to `onAdFailedToLoad`.
46
47
  */
47
- size: BannerAdSize;
48
+ size: BannerAdSize | string;
48
49
 
49
50
  /**
50
51
  * The request options for this banner.
@@ -54,7 +55,7 @@ export type BannerAdProps = {
54
55
  /**
55
56
  * When an ad has finished loading.
56
57
  */
57
- onAdLoaded?: () => void;
58
+ onAdLoaded?: (dimensions: { width: number; height: number }) => void;
58
59
 
59
60
  /**
60
61
  * When an ad has failed to load. Callback contains an Error.
@@ -70,4 +71,80 @@ export type BannerAdProps = {
70
71
  * Called when the user is about to return to the app after tapping on an ad.
71
72
  */
72
73
  onAdClosed?: () => void;
73
- };
74
+ }
75
+
76
+ /**
77
+ * An interface for a GAM Banner advert component.
78
+ *
79
+ * #### Example
80
+ *
81
+ * The `GAMBannerAd` interface is exposed as a React component, allowing you to integrate ads within your existing React
82
+ * Native code base. The component itself is isolated, meaning any standard `View` props (e.g. `style`) are not
83
+ * forwarded on. It is recommended you wrap the `GAMBannerAd` within your own `View` if you wish to apply custom props for use-cases
84
+ * such as positioning.
85
+ *
86
+ * ```js
87
+ * import { GAMBannerAd, BannerAdSize, TestIds } from 'react-native-google-mobile-ads';
88
+ *
89
+ * function HomeScreen() {
90
+ * return (
91
+ * <GAMBannerAd
92
+ * unitId={TestIds.GAM_BANNER}
93
+ * sizes={[BannerAdSize.FULL_BANNER]}
94
+ * requestOptions={{
95
+ * requestNonPersonalizedAdsOnly: true,
96
+ * }}
97
+ * onAdLoaded={() => {
98
+ * console.log('Advert loaded');
99
+ * }}
100
+ * onAdFailedToLoad={(error) => {
101
+ * console.error('Advert failed to load: ', error);
102
+ * }}
103
+ * />
104
+ * );
105
+ * }
106
+ * ```
107
+ */
108
+ export interface GAMBannerAdProps extends Omit<BannerAdProps, 'size'> {
109
+ /**
110
+ * The available sizes of the banner. Can be a array of predefined sizes via `BannerAdSize` or custom dimensions, e.g. `300x200`.
111
+ *
112
+ * Inventory must be available for the banner sizes specified, otherwise a no-fill error will be sent to `onAdFailedToLoad`.
113
+ */
114
+ sizes: BannerAdSize[] | string[];
115
+
116
+ /**
117
+ * Whether to enable the manual impression counting.
118
+ *
119
+ * #### Example
120
+ *
121
+ * After setting this value to `true`, call `recordManualImpression()` from the ref object.
122
+ *
123
+ * ```js
124
+ * import { GAMBannerAd, BannerAdSize, TestIds } from 'react-native-google-mobile-ads';
125
+ *
126
+ * function HomeScreen() {
127
+ * const ref = useRef<GAMBannerAd>(null);
128
+ *
129
+ * const recordManualImpression = () => {
130
+ * ref.current?.recordManualImpression();
131
+ * }
132
+ *
133
+ * return (
134
+ * <GAMBannerAd
135
+ * ref={ref}
136
+ * unitId={TestIds.GAM_BANNER}
137
+ * sizes={[BannerAdSize.FULL_BANNER]}
138
+ * manualImpressionsEnabled={true}
139
+ * />
140
+ * );
141
+ * }
142
+ * ```
143
+ */
144
+ manualImpressionsEnabled?: boolean;
145
+
146
+ /**
147
+ * When an ad received Ad Manager specific app events.
148
+ */
149
+ onAppEvent?: (appEvent: AppEvent) => void;
150
+ }
@@ -3,13 +3,23 @@ import { RequestConfiguration } from './RequestConfiguration';
3
3
  import { RequestOptions } from './RequestOptions';
4
4
  import { AdShowOptions } from './AdShowOptions';
5
5
 
6
+ type AdLoadFunction = (requestId: number, adUnitId: string, requestOptions: RequestOptions) => void;
7
+ type AdShowFunction = (
8
+ requestId: number,
9
+ adUnitId: string,
10
+ showOptions?: AdShowOptions,
11
+ ) => Promise<void>;
12
+
6
13
  export interface GoogleMobileAdsNativeModule {
7
14
  initialize(): Promise<AdapterStatus[]>;
8
15
  setRequestConfiguration(requestConfiguration?: RequestConfiguration): Promise<void>;
9
- appOpenLoad(requestId: number, adUnitId: string, requestOptions: RequestOptions): void;
10
- appOpenShow(requestId: number, showOptions?: AdShowOptions): Promise<void>;
11
- interstitialLoad(requestId: number, adUnitId: string, requestOptions: RequestOptions): void;
12
- interstitialShow(requestId: number, showOptions?: AdShowOptions): Promise<void>;
13
- rewardedLoad(requestId: number, adUnitId: string, requestOptions: RequestOptions): void;
14
- rewardedShow(requestId: number, adUnitId: string, showOptions?: AdShowOptions): Promise<void>;
16
+ openAdInspector(): Promise<void>;
17
+ appOpenLoad: AdLoadFunction;
18
+ appOpenShow: AdShowFunction;
19
+ interstitialLoad: AdLoadFunction;
20
+ interstitialShow: AdShowFunction;
21
+ rewardedLoad: AdLoadFunction;
22
+ rewardedShow: AdShowFunction;
23
+ rewardedInterstitialLoad: AdLoadFunction;
24
+ rewardedInterstitialShow: AdShowFunction;
15
25
  }
@@ -1,4 +1,22 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
1
18
  import { AdEventListener } from './AdEventListener';
19
+ import { AdEventsListener } from './AdEventsListener';
2
20
  import { AdShowOptions } from './AdShowOptions';
3
21
 
4
22
  /**
@@ -22,6 +40,26 @@ export interface MobileAdInterface {
22
40
  */
23
41
  load(): void;
24
42
 
43
+ /**
44
+ * Show the loaded advert to the user.
45
+ *
46
+ * #### Example
47
+ *
48
+ * ```js
49
+ * // Create InterstitialAd/RewardedAd
50
+ * const advert = InterstitialAd.createForAdRequest('...');
51
+ *
52
+ * advert.addAdEventListener(AdEventType.LOADED, () => {
53
+ * advert.show({
54
+ * immersiveModeEnabled: true,
55
+ * });
56
+ * });
57
+ * ```
58
+ *
59
+ * @param showOptions An optional `AdShowOptions` interface.
60
+ */
61
+ show(showOptions?: AdShowOptions): Promise<void>;
62
+
25
63
  /**
26
64
  * Listen to ad events. See AdEventTypes for more information.
27
65
  *
@@ -33,8 +71,7 @@ export interface MobileAdInterface {
33
71
  * // Create InterstitialAd/RewardedAd
34
72
  * const advert = InterstitialAd.createForAdRequest('...');
35
73
  *
36
- * const unsubscribe = advert.onAdEvent((type) => {
37
- *
74
+ * const unsubscribe = advert.addAdEventsListener(({ type, payload }) => {
38
75
  * });
39
76
  *
40
77
  * // Sometime later...
@@ -43,10 +80,12 @@ export interface MobileAdInterface {
43
80
  *
44
81
  * @param listener A listener callback containing a event type, error and data.
45
82
  */
46
- onAdEvent(listener: AdEventListener): () => void;
83
+ addAdEventsListener<T extends never>(listener: AdEventsListener<T>): () => void;
47
84
 
48
85
  /**
49
- * Show the loaded advert to the user.
86
+ * Listen to ad events. See AdEventTypes for more information.
87
+ *
88
+ * Returns an unsubscriber function to stop listening to further events.
50
89
  *
51
90
  * #### Example
52
91
  *
@@ -54,16 +93,21 @@ export interface MobileAdInterface {
54
93
  * // Create InterstitialAd/RewardedAd
55
94
  * const advert = InterstitialAd.createForAdRequest('...');
56
95
  *
57
- * advert.onAdEvent((type) => {
58
- * if (type === AdEventType.LOADED) {
59
- * advert.show({
60
- * immersiveModeEnabled: true,
61
- * });
62
- * }
96
+ * const unsubscribe = advert.addAdEventListener(AdEventType.Loaded, () => {
97
+ *
63
98
  * });
99
+ *
100
+ * // Sometime later...
101
+ * unsubscribe();
64
102
  * ```
65
103
  *
66
- * @param showOptions An optional `AdShowOptions` interface.
104
+ * @param type The event type, e.g. `AdEventType.LOADED`.
105
+ * @param listener A listener callback containing a event type, error and data.
67
106
  */
68
- show(showOptions?: AdShowOptions): Promise<void>;
107
+ addAdEventListener<T extends never>(type: T, listener: AdEventListener<T>): void;
108
+
109
+ /**
110
+ * Remove all registered event listeners.
111
+ */
112
+ removeAllListeners(): void;
69
113
  }
@@ -31,6 +31,16 @@ export interface MobileAdsModuleInterface {
31
31
  */
32
32
  setRequestConfiguration(requestConfiguration: RequestConfiguration): Promise<void>;
33
33
 
34
+ /**
35
+ * Opens the Ad Inspector. Ad inspector is an in-app overlay that enables authorized devices to perform real-time analysis of test ad requests directly within a mobile app.
36
+ *
37
+ * The promise will resolve when the inspector is closed.
38
+ * Also, the promise will reject if ad inspector is closed due to an error.
39
+ *
40
+ * @see https://developers.google.com/ad-manager/mobile-ads-sdk/android/ad-inspector
41
+ */
42
+ openAdInspector(): Promise<void>;
43
+
34
44
  /**
35
45
  * The native module instance for the Google Mobile Ads service.
36
46
  */
@@ -72,30 +72,6 @@ export interface RequestOptions {
72
72
  */
73
73
  customTargeting?: { [key: string]: string };
74
74
 
75
- /**
76
- * The latitude and longitude location of the user.
77
- *
78
- * Ensure your app requests location permissions from the user.
79
- *
80
- * #### Example
81
- *
82
- * ```js
83
- * await Interstitial.createForAdRequest('ca-app-pub-3940256099942544/1033173712', {
84
- * location: [53.481073, -2.237074],
85
- * });
86
- * ```
87
- */
88
- location?: [number, number];
89
-
90
- /**
91
- * Sets the location accuracy if the location is set, in meters.
92
- *
93
- * This option is only applied to iOS devices. On Android, this option has no effect.
94
- *
95
- * @ios
96
- */
97
- locationAccuracy?: number;
98
-
99
75
  /**
100
76
  * Sets the request agent string to identify the ad request's origin. Third party libraries that reference the Mobile
101
77
  * Ads SDK should call this method to denote the platform from which the ad request originated. For example, if a
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ export * from './AdapterStatus';
19
+ export * from './AdEventListener';
20
+ export * from './AdEventsListener';
21
+ export * from './AdsConsent.interface';
22
+ export * from './AdShowOptions';
23
+ export * from './AdStates';
24
+ export * from './BannerAdProps';
25
+ export * from './RequestConfiguration';
26
+ export * from './RequestOptions';
27
+ export * from './RewardedAdReward';
28
+ export * from './AppEvent';
@@ -19,7 +19,6 @@ import {
19
19
  hasOwnProperty,
20
20
  isArray,
21
21
  isBoolean,
22
- isNumber,
23
22
  isObject,
24
23
  isString,
25
24
  isUndefined,
@@ -92,50 +91,6 @@ export function validateAdRequestOptions(options?: RequestOptions) {
92
91
  out.contentUrl = options.contentUrl;
93
92
  }
94
93
 
95
- if (options.location) {
96
- const error = new Error(
97
- "'options.location' expected an array value containing a latitude & longitude number value.",
98
- );
99
-
100
- if (!isArray(options.location)) {
101
- throw error;
102
- }
103
-
104
- const [latitude, longitude] = options.location;
105
-
106
- if (!isNumber(latitude) || !isNumber(longitude)) {
107
- throw error;
108
- }
109
-
110
- if (latitude < -90 || latitude > 90) {
111
- throw new Error(
112
- `'options.location' latitude value must be a number between -90 and 90, but was: ${latitude}`,
113
- );
114
- }
115
-
116
- if (longitude < -180 || longitude > 180) {
117
- throw new Error(
118
- `'options.location' longitude value must be a number between -180 and 180, but was: ${latitude}`,
119
- );
120
- }
121
-
122
- out.location = [latitude, longitude];
123
- }
124
-
125
- if (hasOwnProperty(options, 'locationAccuracy')) {
126
- if (!isNumber(options.locationAccuracy)) {
127
- throw new Error("'options.locationAccuracy' expected a number value.");
128
- }
129
-
130
- if (isNumber(options.locationAccuracy) && options.locationAccuracy < 0) {
131
- throw new Error("'options.locationAccuracy' expected a number greater than 0.");
132
- }
133
-
134
- out.locationAccuracy = options.locationAccuracy;
135
- } else {
136
- out.locationAccuracy = 5;
137
- }
138
-
139
94
  if (options.requestAgent) {
140
95
  if (!isString(options.requestAgent)) {
141
96
  throw new Error("'options.requestAgent' expected a string value");
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
- // generated by genversion
2
- export const version = '5.1.1';
1
+ // Generated by genversion.
2
+ export const version = '6.1.0';