react-native-google-mobile-ads 4.1.2 → 4.1.3

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.
@@ -17,6 +17,7 @@ package io.invertase.googlemobileads;
17
17
  *
18
18
  */
19
19
 
20
+ import static io.invertase.googlemobileads.ReactNativeGoogleMobileAdsCommon.buildAdRequest;
20
21
  import static io.invertase.googlemobileads.ReactNativeGoogleMobileAdsCommon.getCodeAndMessageFromAdError;
21
22
  import static io.invertase.googlemobileads.ReactNativeGoogleMobileAdsCommon.sendAdEvent;
22
23
  import static io.invertase.googlemobileads.ReactNativeGoogleMobileAdsEvent.GOOGLE_MOBILE_ADS_EVENT_APP_OPEN;
@@ -34,7 +35,6 @@ import com.facebook.react.bridge.ReactApplicationContext;
34
35
  import com.facebook.react.bridge.ReactMethod;
35
36
  import com.facebook.react.bridge.ReadableMap;
36
37
  import com.facebook.react.bridge.WritableMap;
37
- import com.google.android.gms.ads.AdRequest;
38
38
  import com.google.android.gms.ads.FullScreenContentCallback;
39
39
  import com.google.android.gms.ads.LoadAdError;
40
40
  import com.google.android.gms.ads.appopen.AppOpenAd;
@@ -67,9 +67,6 @@ public class ReactNativeGoogleMobileAdsAppOpenModule extends ReactNativeModule {
67
67
  }
68
68
  currentActivity.runOnUiThread(
69
69
  () -> {
70
- AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
71
- AdRequest adRequest = adRequestBuilder.build();
72
-
73
70
  AppOpenAd.AppOpenAdLoadCallback appOpenAdLoadCallback =
74
71
  new AppOpenAd.AppOpenAdLoadCallback() {
75
72
 
@@ -115,7 +112,7 @@ public class ReactNativeGoogleMobileAdsAppOpenModule extends ReactNativeModule {
115
112
  AppOpenAd.load(
116
113
  currentActivity,
117
114
  adUnitId,
118
- adRequest,
115
+ buildAdRequest(adRequestOptions),
119
116
  AppOpenAd.APP_OPEN_AD_ORIENTATION_PORTRAIT,
120
117
  appOpenAdLoadCallback);
121
118
  });
@@ -17,6 +17,7 @@ package io.invertase.googlemobileads;
17
17
  *
18
18
  */
19
19
 
20
+ import static io.invertase.googlemobileads.ReactNativeGoogleMobileAdsCommon.buildAdRequest;
20
21
  import static io.invertase.googlemobileads.ReactNativeGoogleMobileAdsCommon.getCodeAndMessageFromAdError;
21
22
  import static io.invertase.googlemobileads.ReactNativeGoogleMobileAdsCommon.sendAdEvent;
22
23
  import static io.invertase.googlemobileads.ReactNativeGoogleMobileAdsEvent.GOOGLE_MOBILE_ADS_EVENT_CLICKED;
@@ -35,7 +36,6 @@ import com.facebook.react.bridge.ReactApplicationContext;
35
36
  import com.facebook.react.bridge.ReactMethod;
36
37
  import com.facebook.react.bridge.ReadableMap;
37
38
  import com.facebook.react.bridge.WritableMap;
38
- import com.google.android.gms.ads.AdRequest;
39
39
  import com.google.android.gms.ads.FullScreenContentCallback;
40
40
  import com.google.android.gms.ads.LoadAdError;
41
41
  import com.google.android.gms.ads.interstitial.InterstitialAd;
@@ -69,9 +69,6 @@ public class ReactNativeGoogleMobileAdsInterstitialModule extends ReactNativeMod
69
69
  }
70
70
  currentActivity.runOnUiThread(
71
71
  () -> {
72
- AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
73
- AdRequest adRequest = adRequestBuilder.build();
74
-
75
72
  InterstitialAdLoadCallback interstitialAdLoadCallback =
76
73
  new InterstitialAdLoadCallback() {
77
74
 
@@ -114,7 +111,11 @@ public class ReactNativeGoogleMobileAdsInterstitialModule extends ReactNativeMod
114
111
  }
115
112
  };
116
113
 
117
- InterstitialAd.load(currentActivity, adUnitId, adRequest, interstitialAdLoadCallback);
114
+ InterstitialAd.load(
115
+ currentActivity,
116
+ adUnitId,
117
+ buildAdRequest(adRequestOptions),
118
+ interstitialAdLoadCallback);
118
119
  });
119
120
  }
120
121
 
@@ -1,5 +1,6 @@
1
1
  package io.invertase.googlemobileads;
2
2
 
3
+ import static io.invertase.googlemobileads.ReactNativeGoogleMobileAdsCommon.buildAdRequest;
3
4
  import static io.invertase.googlemobileads.ReactNativeGoogleMobileAdsCommon.getCodeAndMessageFromAdError;
4
5
  import static io.invertase.googlemobileads.ReactNativeGoogleMobileAdsCommon.sendAdEvent;
5
6
  import static io.invertase.googlemobileads.ReactNativeGoogleMobileAdsEvent.GOOGLE_MOBILE_ADS_EVENT_CLOSED;
@@ -18,7 +19,6 @@ import com.facebook.react.bridge.ReactApplicationContext;
18
19
  import com.facebook.react.bridge.ReactMethod;
19
20
  import com.facebook.react.bridge.ReadableMap;
20
21
  import com.facebook.react.bridge.WritableMap;
21
- import com.google.android.gms.ads.AdRequest;
22
22
  import com.google.android.gms.ads.FullScreenContentCallback;
23
23
  import com.google.android.gms.ads.LoadAdError;
24
24
  import com.google.android.gms.ads.OnUserEarnedRewardListener;
@@ -64,8 +64,6 @@ public class ReactNativeGoogleMobileAdsRewardedModule extends ReactNativeModule
64
64
  }
65
65
  activity.runOnUiThread(
66
66
  () -> {
67
- AdRequest adRequest = new AdRequest.Builder().build();
68
-
69
67
  RewardedAdLoadCallback rewardedAdLoadCallback =
70
68
  new RewardedAdLoadCallback() {
71
69
  @Override
@@ -129,7 +127,8 @@ public class ReactNativeGoogleMobileAdsRewardedModule extends ReactNativeModule
129
127
  }
130
128
  };
131
129
 
132
- RewardedAd.load(activity, adUnitId, adRequest, rewardedAdLoadCallback);
130
+ RewardedAd.load(
131
+ activity, adUnitId, buildAdRequest(adRequestOptions), rewardedAdLoadCallback);
133
132
  });
134
133
  }
135
134
 
@@ -0,0 +1,92 @@
1
+ # Common reasons for ads not showing
2
+
3
+ Use the following guide to understand common reasons why apps show few or no ads.
4
+
5
+ ## Did you recently create your AdMob account?
6
+
7
+ Your account must be approved before ad requests will succeed.
8
+ When you first sign up for AdMob, your account is reviewed before it’s approved.
9
+ This typically takes less than 24 hours, but in rare cases can take up to 2 weeks.
10
+ You'll be notified of approval or rejection via email after review.
11
+
12
+ ## Is your app or ad unit new?
13
+
14
+ New apps and ad units take some time to activate.
15
+ Here are common reasons you may not see live impressions immediately:
16
+ - It usually takes at least an hour after you create an app or ad unit
17
+ - Sometimes it can take a few days for ads to appear in new apps or ad units
18
+ - New iOS apps will not show Google ads until they’re listed in the Apple App Store
19
+
20
+ ## Test ads not showing up
21
+
22
+ If you set up an app-ads.txt file for your app, you need to also include this line in your app-ads.txt file in order to load ads using the demo ad units:
23
+ `google.com, pub-3940256099942544, DIRECT, f08c47fec0942fa0`
24
+
25
+ - Set up app-ads.txt [iOS](https://developers.google.com/admob/ios/app-ads), [Android](https://developers.google.com/admob/android/app-ads)
26
+ - Enabling test ads [iOS](https://developers.google.com/admob/ios/test-ads), [Android](https://developers.google.com/admob/android/test-ads)
27
+
28
+ Alternatively, you can enable test devices and use your own ad unit IDs instead.
29
+
30
+ ### Enable test devices
31
+
32
+ If you want to do more rigorous testing with production-looking ads, configure your device as a test device and use your own ad unit IDs that you've created in the AdMob UI.
33
+ Test devices can either be added in the AdMob UI or programmatically using the Google Mobile Ads SDK.
34
+
35
+ Follow the steps below to add your device as a test device.
36
+
37
+ #### Add your test device in the AdMob UI
38
+ For a simple, non-programmatic way to add a test device and test new or existing app builds, use the AdMob UI.
39
+ [Learn how](https://support.google.com/admob/answer/9691433).
40
+
41
+ #### Add your test device programmatically
42
+
43
+ If you want to test ads in your app as you're developing, follow the steps below to programmatically register your test device.
44
+
45
+ 1. Load your ads-integrated app and make an ad request.
46
+
47
+ 2. For **iOS** follow step 3, for **Android** skip to step 4.
48
+
49
+ 3. Check the console for a message that looks like this:
50
+
51
+ ```
52
+ GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers =
53
+ @[ @"2077ef9a63d2b398840261c8221a0c9b" ]; // Sample device ID
54
+ ```
55
+
56
+ Copy your test device ID to your clipboard.
57
+
58
+ 4. Check the logcat output for a message that looks like the one below, which shows you your device ID and how to add it as a test device:
59
+
60
+ ```
61
+ I/Ads: Use RequestConfiguration.Builder.setTestDeviceIds(Arrays.asList("33BE2250B43518CCDA7DE426D04EE231"))
62
+ to get test ads on this device."
63
+ ```
64
+
65
+ Copy your test device ID to your clipboard.
66
+
67
+ 5. Modify your code to set the test device ID through testDeviceIdentifiers
68
+
69
+ ```js
70
+ import mobileAds from 'react-native-google-mobile-ads';
71
+
72
+ mobileAds()
73
+ .setRequestConfiguration({
74
+ // An array of test device IDs to add to the allow list.
75
+ testDeviceIdentifiers: ["2077ef9a63d2b398840261c8221a0c9b", "EMULATOR"]
76
+ })
77
+ .then(() => {
78
+ // Request config successfully set!
79
+ });
80
+ ```
81
+
82
+ 5. Re-run your app. If the ad is a Google ad, you'll see a Test Ad label centered at the top of the ad.
83
+ Ads with this Test Ad label are safe to click. Requests, impressions, and clicks on test ads will not show up in your account's reports.
84
+
85
+ ## Emulator vs real device
86
+
87
+ In some cases ads won't show up on an emulator but will show up while testing on a real device.
88
+
89
+ ## Extra links
90
+
91
+ - Mobile Ads SDK [iOS](https://developers.google.com/admob/ios/quick-start), [Android](https://developers.google.com/admob/android/quick-start)
92
+ - [Common reasons for ads not showing](https://support.google.com/admob/answer/9469204)
package/docs.json CHANGED
@@ -4,6 +4,7 @@
4
4
  "sidebar": [
5
5
  ["Installation", "/"],
6
6
  ["Displaying Ads", "/displaying-ads"],
7
- ["European User Consent", "/european-user-consent"]
7
+ ["European User Consent", "/european-user-consent"],
8
+ ["Common Reasons For Ads Not Showing", "/common-reasons-for-ads-not-showing"]
8
9
  ]
9
10
  }
@@ -43,9 +43,8 @@ RCT_EXPORT_METHOD(appOpenLoad
43
43
  : (NSString *)adUnitId
44
44
  : (NSDictionary *)adRequestOptions) {
45
45
  self.appOpenAd = nil;
46
- GADRequest *request = [GADRequest request];
47
46
  [GADAppOpenAd loadWithAdUnitID:adUnitId
48
- request:request
47
+ request:[RNGoogleMobileAdsCommon buildAdRequest:adRequestOptions]
49
48
  orientation:UIInterfaceOrientationPortrait
50
49
  completionHandler:^(GADAppOpenAd *_Nullable appOpenAd, NSError *_Nullable error) {
51
50
  if (error) {
@@ -68,9 +68,8 @@ RCT_EXPORT_METHOD(interstitialLoad
68
68
  : (nonnull NSNumber *)requestId
69
69
  : (NSString *)adUnitId
70
70
  : (NSDictionary *)adRequestOptions) {
71
- GADRequest *request = [GADRequest request];
72
71
  [GADInterstitialAd loadWithAdUnitID:adUnitId
73
- request:request
72
+ request:[RNGoogleMobileAdsCommon buildAdRequest:adRequestOptions]
74
73
  completionHandler:^(GADInterstitialAd *ad, NSError *error) {
75
74
  if (error) {
76
75
  NSDictionary *codeAndMessage =
@@ -68,9 +68,8 @@ RCT_EXPORT_METHOD(rewardedLoad
68
68
  : (nonnull NSNumber *)requestId
69
69
  : (NSString *)adUnitId
70
70
  : (NSDictionary *)adRequestOptions) {
71
- GADRequest *request = [GADRequest request];
72
71
  [GADRewardedAd loadWithAdUnitID:adUnitId
73
- request:request
72
+ request:[RNGoogleMobileAdsCommon buildAdRequest:adRequestOptions]
74
73
  completionHandler:^(GADRewardedAd *ad, NSError *error) {
75
74
  if (error) {
76
75
  NSDictionary *codeAndMessage =
@@ -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.1.2';
8
+ const version = '4.1.3';
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.1.2';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '4.1.3';\n"]}
@@ -1,3 +1,3 @@
1
1
  // generated by genversion
2
- export const version = '4.1.2';
2
+ export const version = '4.1.3';
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 = '4.1.2';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '4.1.3';\n"]}
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "4.1.2";
1
+ export declare const SDK_VERSION = "4.1.3";
2
2
  export { default, MobileAds } from './MobileAds';
3
3
  export { AdsConsentDebugGeography } from './AdsConsentDebugGeography';
4
4
  export { AdsConsentStatus } from './AdsConsentStatus';
@@ -1 +1 @@
1
- export declare const version = "4.1.2";
1
+ export declare const version = "4.1.3";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-google-mobile-ads",
3
- "version": "4.1.2",
3
+ "version": "4.1.3",
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 = '4.1.2';
2
+ export const version = '4.1.3';