react-native-google-mobile-ads 8.0.0 → 8.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.
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsFullScreenAdModule.kt +85 -68
- package/docs/displaying-ads-hook.mdx +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/version.ts +1 -1
|
@@ -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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
try {
|
|
148
|
+
val adHelper = ReactNativeGoogleMobileAdsAdHelper(ad)
|
|
149
|
+
var eventType = ReactNativeGoogleMobileAdsEvent.GOOGLE_MOBILE_ADS_EVENT_LOADED
|
|
150
|
+
var data: WritableMap? = null
|
|
149
151
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
if (ad is RewardedAd || ad is RewardedInterstitialAd) {
|
|
153
|
+
eventType = ReactNativeGoogleMobileAdsEvent.GOOGLE_MOBILE_ADS_EVENT_REWARDED_LOADED
|
|
152
154
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
val rewardItem = adHelper.rewardItem
|
|
156
|
+
data = Arguments.createMap()
|
|
157
|
+
data.putString("type", rewardItem.type)
|
|
158
|
+
data.putInt("amount", rewardItem.amount)
|
|
157
159
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
180
|
+
GOOGLE_MOBILE_ADS_EVENT_APP_EVENT,
|
|
208
181
|
requestId,
|
|
209
182
|
adUnitId,
|
|
210
183
|
null,
|
|
211
|
-
|
|
184
|
+
payload
|
|
212
185
|
)
|
|
213
186
|
}
|
|
214
187
|
}
|
|
215
|
-
adHelper.setFullScreenContentCallback(fullScreenContentCallback)
|
|
216
188
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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) {
|
|
@@ -38,7 +38,7 @@ The hook returns several states and functions to control ad.
|
|
|
38
38
|
import { useInterstitialAd, TestIds } from 'react-native-google-mobile-ads';
|
|
39
39
|
|
|
40
40
|
export default function App({ navigation }) {
|
|
41
|
-
const { isLoaded, isClosed, load, show } = useInterstitialAd(TestIds.
|
|
41
|
+
const { isLoaded, isClosed, load, show } = useInterstitialAd(TestIds.INTERSTITIAL, {
|
|
42
42
|
requestNonPersonalizedAdsOnly: true,
|
|
43
43
|
});
|
|
44
44
|
|
package/lib/commonjs/version.js
CHANGED
|
@@ -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.
|
|
1
|
+
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// Generated by genversion.\nexport const version = '8.1.0';\n"]}
|
package/lib/module/version.js
CHANGED
|
@@ -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.
|
|
1
|
+
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// Generated by genversion.\nexport const version = '8.1.0';\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "8.
|
|
1
|
+
export declare const SDK_VERSION = "8.1.0";
|
|
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.
|
|
1
|
+
export declare const version = "8.1.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-google-mobile-ads",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.0",
|
|
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.
|
|
44
|
+
"googleMobileAds": "9.10.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.
|
|
52
|
+
"googleMobileAds": "21.2.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.
|
|
2
|
+
export const version = '8.1.0';
|