react-native-applovin-max 5.5.1 → 5.5.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.
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdView.java +1 -1
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdView.java +93 -94
- package/package.json +1 -1
- package/react-native-applovin-max.podspec +1 -1
- package/src/AppLovinMAXAdView.js +9 -9
- package/src/NativeAdView.js +1 -1
- package/src/index.js +1 -1
package/android/build.gradle
CHANGED
|
@@ -252,7 +252,7 @@ class AppLovinMAXAdView
|
|
|
252
252
|
{
|
|
253
253
|
for ( Map.Entry<String, Object> entry : localExtraParameters.entrySet() )
|
|
254
254
|
{
|
|
255
|
-
adView.setLocalExtraParameter( entry.getKey(),
|
|
255
|
+
adView.setLocalExtraParameter( entry.getKey(), entry.getValue() );
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
|
|
@@ -167,7 +167,86 @@ public class AppLovinMAXNativeAdView
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
///
|
|
170
|
+
/// Ad Loader Listener
|
|
171
|
+
|
|
172
|
+
private class NativeAdListener
|
|
173
|
+
extends MaxNativeAdListener
|
|
174
|
+
{
|
|
175
|
+
@Override
|
|
176
|
+
public void onNativeAdLoaded(@Nullable final MaxNativeAdView nativeAdView, final MaxAd ad)
|
|
177
|
+
{
|
|
178
|
+
AppLovinMAXModule.d( "Native ad loaded: " + ad );
|
|
179
|
+
|
|
180
|
+
// Log a warning if it is a template native ad returned - as our plugin will be responsible for re-rendering the native ad's assets
|
|
181
|
+
if ( nativeAdView != null )
|
|
182
|
+
{
|
|
183
|
+
isLoading.set( false );
|
|
184
|
+
|
|
185
|
+
AppLovinMAXModule.e( "Native ad is of template type, failing ad load..." );
|
|
186
|
+
|
|
187
|
+
WritableMap loadFailedInfo = AppLovinMAXModule.getInstance().getAdLoadFailedInfo( adUnitId, null );
|
|
188
|
+
reactContext.getJSModule( RCTEventEmitter.class ).receiveEvent( getId(), "onAdLoadFailedEvent", loadFailedInfo );
|
|
189
|
+
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
maybeDestroyCurrentAd();
|
|
194
|
+
|
|
195
|
+
nativeAd = ad;
|
|
196
|
+
|
|
197
|
+
// Notify `AppLovinNativeAdView.js`
|
|
198
|
+
sendAdLoadedReactNativeEventForAd( ad.getNativeAd() );
|
|
199
|
+
|
|
200
|
+
// After notifying the RN layer - have slight delay to let views bind to this layer in `clickableViews` before registering
|
|
201
|
+
runOnUiThreadDelayed( () -> {
|
|
202
|
+
|
|
203
|
+
// Loader can be null when the user hides before the properties are fully set
|
|
204
|
+
if ( adLoader != null )
|
|
205
|
+
{
|
|
206
|
+
adLoader.a( clickableViews, AppLovinMAXNativeAdView.this, ad );
|
|
207
|
+
adLoader.b( ad );
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Reassure the size of `mediaView` and its children for the networks, such as
|
|
211
|
+
// LINE, where the actual ad contents are loaded after `mediaView` is sized.
|
|
212
|
+
if ( mediaView != null && mediaView.getParent() != null )
|
|
213
|
+
{
|
|
214
|
+
sizeToFit( mediaView, (View) mediaView.getParent() );
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
isLoading.set( false );
|
|
218
|
+
}, 500L );
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
@Override
|
|
222
|
+
public void onNativeAdLoadFailed(final String adUnitId, final MaxError error)
|
|
223
|
+
{
|
|
224
|
+
isLoading.set( false );
|
|
225
|
+
|
|
226
|
+
AppLovinMAXModule.e( "Failed to load native ad for Ad Unit ID " + adUnitId + " with error: " + error );
|
|
227
|
+
|
|
228
|
+
WritableMap loadFailedInfo = AppLovinMAXModule.getInstance().getAdLoadFailedInfo( adUnitId, error );
|
|
229
|
+
reactContext.getJSModule( RCTEventEmitter.class ).receiveEvent( getId(), "onAdLoadFailedEvent", loadFailedInfo );
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
@Override
|
|
233
|
+
public void onNativeAdClicked(final MaxAd ad)
|
|
234
|
+
{
|
|
235
|
+
WritableMap adInfo = AppLovinMAXModule.getInstance().getAdInfo( ad );
|
|
236
|
+
reactContext.getJSModule( RCTEventEmitter.class ).receiveEvent( getId(), "onAdClickedEvent", adInfo );
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/// Ad Revenue Listener
|
|
241
|
+
|
|
242
|
+
@Override
|
|
243
|
+
public void onAdRevenuePaid(final MaxAd ad)
|
|
244
|
+
{
|
|
245
|
+
WritableMap adRevenueInfo = AppLovinMAXModule.getInstance().getAdRevenueInfo( ad );
|
|
246
|
+
reactContext.getJSModule( RCTEventEmitter.class ).receiveEvent( getId(), "onAdRevenuePaidEvent", adRevenueInfo );
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/// Native Ad Component Methods
|
|
171
250
|
|
|
172
251
|
public void setTitleView(final int tag)
|
|
173
252
|
{
|
|
@@ -351,84 +430,7 @@ public class AppLovinMAXNativeAdView
|
|
|
351
430
|
}
|
|
352
431
|
}
|
|
353
432
|
|
|
354
|
-
///
|
|
355
|
-
|
|
356
|
-
@Override
|
|
357
|
-
public void onAdRevenuePaid(final MaxAd ad)
|
|
358
|
-
{
|
|
359
|
-
WritableMap adRevenueInfo = AppLovinMAXModule.getInstance().getAdRevenueInfo( ad );
|
|
360
|
-
reactContext.getJSModule( RCTEventEmitter.class ).receiveEvent( getId(), "onAdRevenuePaidEvent", adRevenueInfo );
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
/// Ad Loader Callback
|
|
364
|
-
|
|
365
|
-
class NativeAdListener
|
|
366
|
-
extends MaxNativeAdListener
|
|
367
|
-
{
|
|
368
|
-
@Override
|
|
369
|
-
public void onNativeAdLoaded(@Nullable final MaxNativeAdView nativeAdView, final MaxAd ad)
|
|
370
|
-
{
|
|
371
|
-
AppLovinMAXModule.d( "Native ad loaded: " + ad );
|
|
372
|
-
|
|
373
|
-
// Log a warning if it is a template native ad returned - as our plugin will be responsible for re-rendering the native ad's assets
|
|
374
|
-
if ( nativeAdView != null )
|
|
375
|
-
{
|
|
376
|
-
isLoading.set( false );
|
|
377
|
-
|
|
378
|
-
AppLovinMAXModule.e( "Native ad is of template type, failing ad load..." );
|
|
379
|
-
WritableMap loadFailedInfo = AppLovinMAXModule.getInstance().getAdLoadFailedInfo( adUnitId, null );
|
|
380
|
-
reactContext.getJSModule( RCTEventEmitter.class ).receiveEvent( getId(), "onAdLoadFailedEvent", loadFailedInfo );
|
|
381
|
-
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
maybeDestroyCurrentAd();
|
|
386
|
-
|
|
387
|
-
nativeAd = ad;
|
|
388
|
-
|
|
389
|
-
// Notify `AppLovinNativeAdView.js`
|
|
390
|
-
sendAdLoadedReactNativeEventForAd( ad.getNativeAd() );
|
|
391
|
-
|
|
392
|
-
// After notifying the RN layer - have slight delay to let views bind to this layer in `clickableViews` before registering
|
|
393
|
-
runOnUiThreadDelayed( () -> {
|
|
394
|
-
|
|
395
|
-
// Loader can be null when the user hides before the properties are fully set
|
|
396
|
-
if ( adLoader != null )
|
|
397
|
-
{
|
|
398
|
-
adLoader.a( clickableViews, AppLovinMAXNativeAdView.this, ad );
|
|
399
|
-
adLoader.b( ad );
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
// Reassure the size of `mediaView` and its children for the networks, such as
|
|
403
|
-
// LINE, where the actual ad contents are loaded after `mediaView` is sized.
|
|
404
|
-
if ( mediaView != null )
|
|
405
|
-
{
|
|
406
|
-
sizeToFit( mediaView, (View) mediaView.getParent() );
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
isLoading.set( false );
|
|
410
|
-
}, 500L );
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
@Override
|
|
414
|
-
public void onNativeAdLoadFailed(final String adUnitId, final MaxError error)
|
|
415
|
-
{
|
|
416
|
-
isLoading.set( false );
|
|
417
|
-
|
|
418
|
-
AppLovinMAXModule.e( "Failed to load native ad for Ad Unit ID " + adUnitId + " with error: " + error );
|
|
419
|
-
|
|
420
|
-
// Notify publisher
|
|
421
|
-
WritableMap loadFailedInfo = AppLovinMAXModule.getInstance().getAdLoadFailedInfo( adUnitId, error );
|
|
422
|
-
reactContext.getJSModule( RCTEventEmitter.class ).receiveEvent( getId(), "onAdLoadFailedEvent", loadFailedInfo );
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
@Override
|
|
426
|
-
public void onNativeAdClicked(final MaxAd ad)
|
|
427
|
-
{
|
|
428
|
-
WritableMap adInfo = AppLovinMAXModule.getInstance().getAdInfo( ad );
|
|
429
|
-
reactContext.getJSModule( RCTEventEmitter.class ).receiveEvent( getId(), "onAdClickedEvent", adInfo );
|
|
430
|
-
}
|
|
431
|
-
}
|
|
433
|
+
/// Utility Methods
|
|
432
434
|
|
|
433
435
|
private void sendAdLoadedReactNativeEventForAd(final MaxNativeAd ad)
|
|
434
436
|
{
|
|
@@ -500,26 +502,23 @@ public class AppLovinMAXNativeAdView
|
|
|
500
502
|
{
|
|
501
503
|
if ( nativeAd != null )
|
|
502
504
|
{
|
|
503
|
-
if (
|
|
505
|
+
if ( mediaView != null )
|
|
504
506
|
{
|
|
505
|
-
|
|
507
|
+
ViewGroup parentView = (ViewGroup) mediaView.getParent();
|
|
508
|
+
if ( parentView != null )
|
|
506
509
|
{
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
{
|
|
510
|
-
parentView.removeOnLayoutChangeListener( AppLovinMAXNativeAdView.this );
|
|
511
|
-
parentView.removeView( mediaView );
|
|
512
|
-
}
|
|
510
|
+
parentView.removeOnLayoutChangeListener( AppLovinMAXNativeAdView.this );
|
|
511
|
+
parentView.removeView( mediaView );
|
|
513
512
|
}
|
|
513
|
+
}
|
|
514
514
|
|
|
515
|
-
|
|
515
|
+
if ( optionsView != null )
|
|
516
|
+
{
|
|
517
|
+
ViewGroup parentView = (ViewGroup) optionsView.getParent();
|
|
518
|
+
if ( parentView != null )
|
|
516
519
|
{
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
{
|
|
520
|
-
parentView.removeOnLayoutChangeListener( AppLovinMAXNativeAdView.this );
|
|
521
|
-
parentView.removeView( optionsView );
|
|
522
|
-
}
|
|
520
|
+
parentView.removeOnLayoutChangeListener( AppLovinMAXNativeAdView.this );
|
|
521
|
+
parentView.removeView( optionsView );
|
|
523
522
|
}
|
|
524
523
|
}
|
|
525
524
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-applovin-max",
|
|
3
3
|
"author": "AppLovin Corporation",
|
|
4
|
-
"version": "5.5.
|
|
4
|
+
"version": "5.5.3",
|
|
5
5
|
"description": "AppLovin MAX React Native Plugin for Android and iOS",
|
|
6
6
|
"homepage": "https://github.com/AppLovin/AppLovin-MAX-React-Native",
|
|
7
7
|
"license": "MIT",
|
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.authors = package["author"]
|
|
12
12
|
|
|
13
13
|
s.platforms = { :ios => "10.0" }
|
|
14
|
-
s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "
|
|
14
|
+
s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_5_5_3" }
|
|
15
15
|
|
|
16
16
|
s.source_files = "ios/AppLovinMAX*.{h,m}"
|
|
17
17
|
|
package/src/AppLovinMAXAdView.js
CHANGED
|
@@ -50,20 +50,20 @@ const AdView = (props) => {
|
|
|
50
50
|
} else {
|
|
51
51
|
height = isTablet ? 90 : 50;
|
|
52
52
|
}
|
|
53
|
-
setDimensions({width: (style
|
|
54
|
-
height: (style
|
|
53
|
+
setDimensions({width: (style?.width && style.width !== 'auto') ? style.width : width,
|
|
54
|
+
height: (style?.height && style.height !== 'auto') ? style.height : height});
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// Check whether or not app specifies both width and height but not with 'auto'
|
|
58
|
-
const isSizeSpecified = ((style
|
|
59
|
-
(style
|
|
58
|
+
const isSizeSpecified = ((style?.width && style.width !== 'auto') &&
|
|
59
|
+
(style?.height && style.height !== 'auto'));
|
|
60
60
|
|
|
61
61
|
if (!isSizeSpecified) {
|
|
62
62
|
if (props.adFormat === AdFormat.BANNER) {
|
|
63
63
|
sizeForBannerFormat();
|
|
64
64
|
} else {
|
|
65
|
-
setDimensions({width: (style
|
|
66
|
-
height: (style
|
|
65
|
+
setDimensions({width: (style?.width && style.width !== 'auto') ? style.width : 300,
|
|
66
|
+
height: (style?.height && style.height !== 'auto') ? style.height : 250});
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
}, []);
|
|
@@ -115,8 +115,8 @@ const AdView = (props) => {
|
|
|
115
115
|
};
|
|
116
116
|
|
|
117
117
|
{
|
|
118
|
-
const isSizeSpecified = ((style
|
|
119
|
-
(style
|
|
118
|
+
const isSizeSpecified = ((style?.width && style.width !== 'auto') &&
|
|
119
|
+
(style?.height && style.height !== 'auto'));
|
|
120
120
|
const isDimensionsSet = (Object.keys(dimensions).length > 0);
|
|
121
121
|
|
|
122
122
|
// Not sized yet
|
|
@@ -129,7 +129,7 @@ const AdView = (props) => {
|
|
|
129
129
|
<AppLovinMAXAdView
|
|
130
130
|
style={{...style, ...dimensions}}
|
|
131
131
|
extraParameters={sanitizeExtraParameters('extraParameters', extraParameters)}
|
|
132
|
-
localExtraParameters={
|
|
132
|
+
localExtraParameters={localExtraParameters}
|
|
133
133
|
onAdLoadedEvent={onAdLoadedEvent}
|
|
134
134
|
onAdLoadFailedEvent={onAdLoadFailedEvent}
|
|
135
135
|
onAdDisplayFailedEvent={onAdDisplayFailedEvent}
|
package/src/NativeAdView.js
CHANGED
|
@@ -92,7 +92,7 @@ const NativeAdView = forwardRef((props, ref) => {
|
|
|
92
92
|
<AppLovinMAXNativeAdView
|
|
93
93
|
ref={saveElement}
|
|
94
94
|
extraParameters={sanitizeExtraParameters('extraParameters', extraParameters)}
|
|
95
|
-
localExtraParameters={
|
|
95
|
+
localExtraParameters={localExtraParameters}
|
|
96
96
|
onAdLoadedEvent={onAdLoadedEvent}
|
|
97
97
|
onAdLoadFailedEvent={onAdLoadFailedEvent}
|
|
98
98
|
onAdClickedEvent={onAdClickedEvent}
|