react-native-google-mobile-ads 8.0.0 → 8.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.
@@ -18,6 +18,7 @@ package io.invertase.googlemobileads
18
18
  */
19
19
 
20
20
  import android.app.Activity
21
+ import android.util.Log
21
22
  import android.util.SparseArray
22
23
  import com.facebook.react.bridge.*
23
24
  import com.google.android.gms.ads.AdLoadCallback
@@ -143,88 +144,104 @@ abstract class ReactNativeGoogleMobileAdsFullScreenAdModule<T>(
143
144
  private val adRequestOptions: ReadableMap
144
145
  ) : AdLoadCallback<T>() {
145
146
  override fun onAdLoaded(ad: T) {
146
- val adHelper = ReactNativeGoogleMobileAdsAdHelper(ad)
147
- var eventType = ReactNativeGoogleMobileAdsEvent.GOOGLE_MOBILE_ADS_EVENT_LOADED
148
- var data: WritableMap? = null
147
+ try {
148
+ val adHelper = ReactNativeGoogleMobileAdsAdHelper(ad)
149
+ var eventType = ReactNativeGoogleMobileAdsEvent.GOOGLE_MOBILE_ADS_EVENT_LOADED
150
+ var data: WritableMap? = null
149
151
 
150
- if (ad is RewardedAd || ad is RewardedInterstitialAd) {
151
- eventType = ReactNativeGoogleMobileAdsEvent.GOOGLE_MOBILE_ADS_EVENT_REWARDED_LOADED
152
+ if (ad is RewardedAd || ad is RewardedInterstitialAd) {
153
+ eventType = ReactNativeGoogleMobileAdsEvent.GOOGLE_MOBILE_ADS_EVENT_REWARDED_LOADED
152
154
 
153
- val rewardItem = adHelper.rewardItem
154
- data = Arguments.createMap()
155
- data.putString("type", rewardItem.type)
156
- data.putInt("amount", rewardItem.amount)
155
+ val rewardItem = adHelper.rewardItem
156
+ data = Arguments.createMap()
157
+ data.putString("type", rewardItem.type)
158
+ data.putInt("amount", rewardItem.amount)
157
159
 
158
- adRequestOptions.getMap("serverSideVerificationOptions")
159
- ?.let { serverSideVerificationOptions ->
160
- val options =
161
- ServerSideVerificationOptions.Builder()
162
- serverSideVerificationOptions.getString("userId")?.let {
163
- options.setUserId(it)
160
+ adRequestOptions.getMap("serverSideVerificationOptions")
161
+ ?.let { serverSideVerificationOptions ->
162
+ val options =
163
+ ServerSideVerificationOptions.Builder()
164
+ serverSideVerificationOptions.getString("userId")?.let {
165
+ options.setUserId(it)
166
+ }
167
+ serverSideVerificationOptions.getString("customData")?.let {
168
+ options.setCustomData(it)
169
+ }
170
+ adHelper.setServerSideVerificationOptions(options.build())
164
171
  }
165
- serverSideVerificationOptions.getString("customData")?.let {
166
- options.setCustomData(it)
167
- }
168
- adHelper.setServerSideVerificationOptions(options.build())
169
- }
170
- }
171
-
172
- if (ad is AdManagerInterstitialAd) {
173
- adHelper.setAppEventListener { name, eventData ->
174
- val payload = Arguments.createMap()
175
- payload.putString("name", name)
176
- payload.putString("data", eventData)
177
- sendAdEvent(
178
- GOOGLE_MOBILE_ADS_EVENT_APP_EVENT,
179
- requestId,
180
- adUnitId,
181
- null,
182
- payload
183
- )
184
172
  }
185
- }
186
-
187
- val fullScreenContentCallback: FullScreenContentCallback =
188
- object : FullScreenContentCallback() {
189
- override fun onAdShowedFullScreenContent() {
190
- sendAdEvent(ReactNativeGoogleMobileAdsEvent.GOOGLE_MOBILE_ADS_EVENT_OPENED)
191
- }
192
-
193
- override fun onAdDismissedFullScreenContent() {
194
- sendAdEvent(ReactNativeGoogleMobileAdsEvent.GOOGLE_MOBILE_ADS_EVENT_CLOSED)
195
- }
196
173
 
197
- override fun onAdClicked() {
198
- sendAdEvent(ReactNativeGoogleMobileAdsEvent.GOOGLE_MOBILE_ADS_EVENT_CLICKED)
199
- }
200
-
201
- override fun onAdImpression() {
202
- // Not Implemented Yet
203
- }
204
-
205
- private fun sendAdEvent(type: String) {
174
+ if (ad is AdManagerInterstitialAd) {
175
+ adHelper.setAppEventListener { name, eventData ->
176
+ val payload = Arguments.createMap()
177
+ payload.putString("name", name)
178
+ payload.putString("data", eventData)
206
179
  sendAdEvent(
207
- type,
180
+ GOOGLE_MOBILE_ADS_EVENT_APP_EVENT,
208
181
  requestId,
209
182
  adUnitId,
210
183
  null,
211
- null
184
+ payload
212
185
  )
213
186
  }
214
187
  }
215
- adHelper.setFullScreenContentCallback(fullScreenContentCallback)
216
188
 
217
- adArray.put(
218
- requestId,
219
- ad
220
- )
221
- sendAdEvent(
222
- eventType,
223
- requestId,
224
- adUnitId,
225
- null,
226
- data
227
- )
189
+ val fullScreenContentCallback: FullScreenContentCallback =
190
+ object : FullScreenContentCallback() {
191
+ override fun onAdShowedFullScreenContent() {
192
+ sendAdEvent(ReactNativeGoogleMobileAdsEvent.GOOGLE_MOBILE_ADS_EVENT_OPENED)
193
+ }
194
+
195
+ override fun onAdDismissedFullScreenContent() {
196
+ sendAdEvent(ReactNativeGoogleMobileAdsEvent.GOOGLE_MOBILE_ADS_EVENT_CLOSED)
197
+ }
198
+
199
+ override fun onAdClicked() {
200
+ sendAdEvent(ReactNativeGoogleMobileAdsEvent.GOOGLE_MOBILE_ADS_EVENT_CLICKED)
201
+ }
202
+
203
+ override fun onAdImpression() {
204
+ // Not Implemented Yet
205
+ }
206
+
207
+ private fun sendAdEvent(type: String) {
208
+ sendAdEvent(
209
+ type,
210
+ requestId,
211
+ adUnitId,
212
+ null,
213
+ null
214
+ )
215
+ }
216
+ }
217
+ adHelper.setFullScreenContentCallback(fullScreenContentCallback)
218
+
219
+ adArray.put(
220
+ requestId,
221
+ ad
222
+ )
223
+ sendAdEvent(
224
+ eventType,
225
+ requestId,
226
+ adUnitId,
227
+ null,
228
+ data
229
+ )
230
+ } catch (e: Exception) {
231
+ Log.w("RNGoogleMobileAds", "Unknown error on load")
232
+ Log.w("RNGoogleMobileAds", e)
233
+ val error = Arguments.createMap()
234
+ error.putString("code", "internal")
235
+ error.putString("message", e.message)
236
+ sendAdEvent(
237
+ ReactNativeGoogleMobileAdsEvent.GOOGLE_MOBILE_ADS_EVENT_ERROR,
238
+ requestId,
239
+ adUnitId,
240
+ error,
241
+ null
242
+ )
243
+
244
+ }
228
245
  }
229
246
 
230
247
  override fun onAdFailedToLoad(loadAdError: LoadAdError) {
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = void 0;
7
7
  // Generated by genversion.
8
- const version = '8.0.0';
8
+ const version = '8.0.1';
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 = '8.0.0';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// Generated by genversion.\nexport const version = '8.0.1';\n"]}
@@ -1,3 +1,3 @@
1
1
  // Generated by genversion.
2
- export const version = '8.0.0';
2
+ export const version = '8.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 = '8.0.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 = '8.0.1';\n"]}
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "8.0.0";
1
+ export declare const SDK_VERSION = "8.0.1";
2
2
  export { default, MobileAds } from './MobileAds';
3
3
  export { AdsConsentDebugGeography } from './AdsConsentDebugGeography';
4
4
  export { AdsConsentPurposes } from './AdsConsentPurposes';
@@ -1 +1 @@
1
- export declare const version = "8.0.0";
1
+ export declare const version = "8.0.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-google-mobile-ads",
3
- "version": "8.0.0",
3
+ "version": "8.0.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",
@@ -41,7 +41,7 @@
41
41
  ],
42
42
  "sdkVersions": {
43
43
  "ios": {
44
- "googleMobileAds": "9.6.0",
44
+ "googleMobileAds": "9.9.0",
45
45
  "googleUmp": "2.0.0"
46
46
  },
47
47
  "android": {
@@ -49,7 +49,7 @@
49
49
  "targetSdk": 30,
50
50
  "compileSdk": 31,
51
51
  "buildTools": "31.0.0",
52
- "googleMobileAds": "21.0.0",
52
+ "googleMobileAds": "21.1.0",
53
53
  "googleUmp": "2.0.0"
54
54
  }
55
55
  },
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '8.0.0';
2
+ export const version = '8.0.1';