react-native-google-mobile-ads 14.9.0 → 14.9.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.
@@ -3,12 +3,15 @@ package com.facebook.react.viewmanagers;
3
3
  import android.view.View;
4
4
  import androidx.annotation.NonNull;
5
5
  import androidx.annotation.Nullable;
6
+ import com.facebook.react.uimanager.BaseViewManager;
6
7
  import com.facebook.react.uimanager.BaseViewManagerDelegate;
7
- import com.facebook.react.uimanager.BaseViewManagerInterface;
8
+ import com.facebook.react.uimanager.LayoutShadowNode;
8
9
 
9
10
  public class RNGoogleMobileAdsMediaViewManagerDelegate<
10
11
  T extends View,
11
- U extends BaseViewManagerInterface<T> & RNGoogleMobileAdsMediaViewManagerInterface<T>>
12
+ U extends
13
+ BaseViewManager<T, ? extends LayoutShadowNode>
14
+ & RNGoogleMobileAdsMediaViewManagerInterface<T>>
12
15
  extends BaseViewManagerDelegate<T, U> {
13
16
  public RNGoogleMobileAdsMediaViewManagerDelegate(U viewManager) {
14
17
  super(viewManager);
@@ -4,12 +4,15 @@ import android.view.View;
4
4
  import androidx.annotation.NonNull;
5
5
  import androidx.annotation.Nullable;
6
6
  import com.facebook.react.bridge.ReadableArray;
7
+ import com.facebook.react.uimanager.BaseViewManager;
7
8
  import com.facebook.react.uimanager.BaseViewManagerDelegate;
8
- import com.facebook.react.uimanager.BaseViewManagerInterface;
9
+ import com.facebook.react.uimanager.LayoutShadowNode;
9
10
 
10
11
  public class RNGoogleMobileAdsNativeViewManagerDelegate<
11
12
  T extends View,
12
- U extends BaseViewManagerInterface<T> & RNGoogleMobileAdsNativeViewManagerInterface<T>>
13
+ U extends
14
+ BaseViewManager<T, ? extends LayoutShadowNode>
15
+ & RNGoogleMobileAdsNativeViewManagerInterface<T>>
13
16
  extends BaseViewManagerDelegate<T, U> {
14
17
  public RNGoogleMobileAdsNativeViewManagerDelegate(U viewManager) {
15
18
  super(viewManager);
@@ -198,27 +198,26 @@ The UMP SDK uses the consent status from the previous session.
198
198
  ```js
199
199
  import mobileAds, { AdsConsent, AdsConsentStatus } from 'react-native-google-mobile-ads';
200
200
 
201
- let isMobileAdsStartCalled = false;
202
-
203
- // Request consent information and load/present a consent form if necessary.
204
- AdsConsent.gatherConsent()
205
- .then(({canRequestAds}) => {
206
- if (canRequestAds) {
207
- startGoogleMobileAdsSDK()
208
- }
209
- })
210
- .catch((error) => console.error('Consent gathering failed:', error))
211
-
212
- // Check if you can initialize the Google Mobile Ads SDK in parallel
213
- // using consent obtained in the previous session.
214
- const {canRequestAds} = await AdsConsent.getConsentInfo()
215
- if (canRequestAds) {
216
- startGoogleMobileAdsSDK()
217
- }
201
+ const isMobileAdsStartCalledRef = useRef(false);
202
+
203
+ useEffect(() => {
204
+ // Request consent information and load/present a consent form if necessary.
205
+ AdsConsent.gatherConsent()
206
+ .then(startGoogleMobileAdsSDK)
207
+ .catch((error) => console.error('Consent gathering failed:', error));
208
+
209
+ // This sample attempts to load ads using consent obtained in the previous session.
210
+ // We intentionally use .then() chaining (instead of await) to ensure parallel execution.
211
+ startGoogleMobileAdsSDK();
212
+ }, []);
218
213
 
219
214
  async function startGoogleMobileAdsSDK() {
220
- if (isMobileAdsStartCalled) return;
221
- isMobileAdsStartCalled = true;
215
+ const {canRequestAds} = await AdsConsent.getConsentInfo();
216
+ if (!canRequestAds || isMobileAdsStartCalledRef.current) {
217
+ return;
218
+ }
219
+
220
+ isMobileAdsStartCalledRef.current = true;
222
221
 
223
222
  // (Optional, iOS) Handle Apple's App Tracking Transparency manually.
224
223
  const gdprApplies = await AdsConsent.getGdprApplies();
@@ -5,5 +5,5 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = void 0;
7
7
  // Generated by genversion.
8
- const version = exports.version = '14.9.0';
8
+ const version = exports.version = '14.9.1';
9
9
  //# sourceMappingURL=version.js.map
@@ -1,3 +1,3 @@
1
1
  // Generated by genversion.
2
- export const version = '14.9.0';
2
+ export const version = '14.9.1';
3
3
  //# sourceMappingURL=version.js.map
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "14.9.0";
1
+ export declare const SDK_VERSION = "14.9.1";
2
2
  export { default, MobileAds } from './MobileAds';
3
3
  export { AdsConsentDebugGeography, AdsConsentInfo, AdsConsentInfoOptions, AdsConsentInterface, AdsConsentPrivacyOptionsRequirementStatus, AdsConsentStatus, AdsConsentUserChoices, } from './specs/modules/NativeConsentModule';
4
4
  export { AdsConsentPurposes } from './AdsConsentPurposes';
@@ -1,2 +1,2 @@
1
- export declare const version = "14.9.0";
1
+ export declare const version = "14.9.1";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-google-mobile-ads",
3
- "version": "14.9.0",
3
+ "version": "14.9.1",
4
4
  "author": "Invertase <oss@invertase.io> (http://invertase.io)",
5
5
  "description": "React Native Google Mobile Ads is an easy way to monetize mobile apps with targeted, in-app advertising.",
6
6
  "main": "lib/commonjs/index.js",
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '14.9.0';
2
+ export const version = '14.9.1';