react-native-applovin-max 3.3.0 → 4.0.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/build.gradle +4 -4
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdView.java +162 -61
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewManager.java +22 -165
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXModule.java +32 -9
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdView.java +365 -0
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdViewManager.java +148 -0
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXPackage.java +2 -1
- package/ios/AppLovinMAX.h +10 -0
- package/ios/AppLovinMAX.m +33 -5
- package/ios/AppLovinMAX.xcodeproj/project.pbxproj +20 -2
- package/ios/AppLovinMAX.xcworkspace/xcuserdata/thomasso.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/AppLovinMAX.xcworkspace/xcuserdata/thomasso.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +24 -0
- package/ios/AppLovinMAXAdView.h +16 -0
- package/ios/AppLovinMAXAdView.m +197 -0
- package/ios/AppLovinMAXAdViewManager.m +10 -280
- package/ios/AppLovinMAXNativeAdView.h +27 -0
- package/ios/AppLovinMAXNativeAdView.m +308 -0
- package/ios/AppLovinMAXNativeAdViewManager.h +19 -0
- package/ios/AppLovinMAXNativeAdViewManager.m +60 -0
- package/ios/Podfile +1 -1
- package/ios/Podfile.lock +5 -5
- package/package.json +1 -1
- package/react-native-applovin-max.podspec +2 -2
- package/src/AppLovinMAXAdView.js +35 -142
- package/src/NativeAdComponents.js +156 -0
- package/src/NativeAdView.js +118 -0
- package/src/NativeAdViewProvider.js +19 -0
- package/src/index.js +3 -1
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
package com.applovin.reactnative;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.text.TextUtils;
|
|
5
|
+
import android.view.View;
|
|
6
|
+
import android.view.ViewGroup;
|
|
7
|
+
import android.widget.ImageView;
|
|
8
|
+
|
|
9
|
+
import com.applovin.mediation.MaxAd;
|
|
10
|
+
import com.applovin.mediation.MaxError;
|
|
11
|
+
import com.applovin.mediation.nativeAds.MaxNativeAd;
|
|
12
|
+
import com.applovin.mediation.nativeAds.MaxNativeAd.MaxNativeAdImage;
|
|
13
|
+
import com.applovin.mediation.nativeAds.MaxNativeAdListener;
|
|
14
|
+
import com.applovin.mediation.nativeAds.MaxNativeAdLoader;
|
|
15
|
+
import com.applovin.mediation.nativeAds.MaxNativeAdView;
|
|
16
|
+
import com.facebook.react.bridge.Arguments;
|
|
17
|
+
import com.facebook.react.bridge.ReactContext;
|
|
18
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
19
|
+
import com.facebook.react.bridge.WritableMap;
|
|
20
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
|
21
|
+
import com.facebook.react.views.view.ReactViewGroup;
|
|
22
|
+
|
|
23
|
+
import java.util.ArrayList;
|
|
24
|
+
import java.util.List;
|
|
25
|
+
import java.util.Map;
|
|
26
|
+
import java.util.concurrent.atomic.AtomicBoolean;
|
|
27
|
+
|
|
28
|
+
import androidx.annotation.Nullable;
|
|
29
|
+
|
|
30
|
+
import static com.applovin.sdk.AppLovinSdkUtils.runOnUiThreadDelayed;
|
|
31
|
+
|
|
32
|
+
public class AppLovinMAXNativeAdView
|
|
33
|
+
extends ReactViewGroup
|
|
34
|
+
{
|
|
35
|
+
private final ReactContext reactContext;
|
|
36
|
+
@Nullable
|
|
37
|
+
private MaxNativeAdLoader adLoader;
|
|
38
|
+
@Nullable
|
|
39
|
+
private MaxAd nativeAd;
|
|
40
|
+
private final AtomicBoolean isLoading = new AtomicBoolean(); // Guard against repeated ad loads
|
|
41
|
+
|
|
42
|
+
// JavaScript properties
|
|
43
|
+
private String adUnitId;
|
|
44
|
+
@Nullable
|
|
45
|
+
private String placement;
|
|
46
|
+
@Nullable
|
|
47
|
+
private String customData;
|
|
48
|
+
@Nullable
|
|
49
|
+
private Map<String, Object> extraParameters;
|
|
50
|
+
|
|
51
|
+
// TODO: Allow publisher to select which views are clickable and which isn't via prop
|
|
52
|
+
private final List<View> clickableViews = new ArrayList<>();
|
|
53
|
+
|
|
54
|
+
public AppLovinMAXNativeAdView(final Context context)
|
|
55
|
+
{
|
|
56
|
+
super( context );
|
|
57
|
+
reactContext = (ReactContext) context;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public void destroy()
|
|
61
|
+
{
|
|
62
|
+
maybeDestroyCurrentAd();
|
|
63
|
+
|
|
64
|
+
if ( adLoader != null )
|
|
65
|
+
{
|
|
66
|
+
adLoader.destroy();
|
|
67
|
+
adLoader = null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public void setAdUnitId(final String value)
|
|
72
|
+
{
|
|
73
|
+
if ( TextUtils.isEmpty( value ) ) return;
|
|
74
|
+
|
|
75
|
+
adUnitId = value;
|
|
76
|
+
|
|
77
|
+
// Explicitly invoke ad load now that Ad Unit ID is set, but do so after 0.25s to allow other props to set
|
|
78
|
+
postDelayed( this::loadAd, 250 );
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public void setPlacement(@Nullable final String value)
|
|
82
|
+
{
|
|
83
|
+
placement = value;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public void setCustomData(@Nullable final String value)
|
|
87
|
+
{
|
|
88
|
+
customData = value;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public void setExtraParameters(@Nullable final ReadableMap readableMap)
|
|
92
|
+
{
|
|
93
|
+
if ( readableMap != null )
|
|
94
|
+
{
|
|
95
|
+
extraParameters = readableMap.toHashMap();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public void loadAd()
|
|
100
|
+
{
|
|
101
|
+
if ( isLoading.compareAndSet( false, true ) )
|
|
102
|
+
{
|
|
103
|
+
AppLovinMAXModule.d( "Loading a native ad for Ad Unit ID: " + adUnitId + "..." );
|
|
104
|
+
|
|
105
|
+
if ( adLoader == null || !adUnitId.equals( adLoader.getAdUnitId() ) )
|
|
106
|
+
{
|
|
107
|
+
adLoader = new MaxNativeAdLoader( adUnitId, AppLovinMAXModule.getInstance().getSdk(), reactContext );
|
|
108
|
+
adLoader.setRevenueListener( AppLovinMAXModule.getInstance() );
|
|
109
|
+
adLoader.setNativeAdListener( new NativeAdListener() );
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
adLoader.setPlacement( placement );
|
|
113
|
+
adLoader.setCustomData( customData );
|
|
114
|
+
|
|
115
|
+
if ( extraParameters != null )
|
|
116
|
+
{
|
|
117
|
+
for ( Map.Entry<String, Object> entry : extraParameters.entrySet() )
|
|
118
|
+
{
|
|
119
|
+
adLoader.setExtraParameter( entry.getKey(), (String) entry.getValue() );
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
adLoader.loadAd();
|
|
124
|
+
}
|
|
125
|
+
else
|
|
126
|
+
{
|
|
127
|
+
AppLovinMAXModule.e( "Ignoring request to load native ad for Ad Unit ID " + adUnitId + ", another ad load in progress" );
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/// Views to Replace
|
|
132
|
+
|
|
133
|
+
public void setTitleView(final int tag)
|
|
134
|
+
{
|
|
135
|
+
if ( nativeAd.getNativeAd().getTitle() == null ) return;
|
|
136
|
+
|
|
137
|
+
View view = findViewById( tag );
|
|
138
|
+
view.setClickable( true );
|
|
139
|
+
|
|
140
|
+
clickableViews.add( view );
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public void setAdvertiserView(final int tag)
|
|
144
|
+
{
|
|
145
|
+
if ( nativeAd.getNativeAd().getAdvertiser() == null ) return;
|
|
146
|
+
|
|
147
|
+
View view = findViewById( tag );
|
|
148
|
+
view.setClickable( true );
|
|
149
|
+
|
|
150
|
+
clickableViews.add( view );
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
public void setBodyView(final int tag)
|
|
154
|
+
{
|
|
155
|
+
if ( nativeAd.getNativeAd().getBody() == null ) return;
|
|
156
|
+
|
|
157
|
+
View view = findViewById( tag );
|
|
158
|
+
view.setClickable( true );
|
|
159
|
+
|
|
160
|
+
clickableViews.add( view );
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
public void setCallToActionView(final int tag)
|
|
164
|
+
{
|
|
165
|
+
if ( nativeAd.getNativeAd().getCallToAction() == null ) return;
|
|
166
|
+
|
|
167
|
+
View view = findViewById( tag );
|
|
168
|
+
view.setClickable( true );
|
|
169
|
+
|
|
170
|
+
clickableViews.add( view );
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
public void setMediaView(final int tag)
|
|
174
|
+
{
|
|
175
|
+
View mediaView = nativeAd.getNativeAd().getMediaView();
|
|
176
|
+
if ( mediaView == null ) return;
|
|
177
|
+
|
|
178
|
+
ViewGroup view = findViewById( tag );
|
|
179
|
+
if ( view == null )
|
|
180
|
+
{
|
|
181
|
+
AppLovinMAXModule.e( "Cannot find a media view with tag \"" + tag + "\" for " + adUnitId );
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
clickableViews.add( view );
|
|
186
|
+
|
|
187
|
+
mediaView.measure( MeasureSpec.makeMeasureSpec( view.getWidth(), MeasureSpec.EXACTLY ),
|
|
188
|
+
MeasureSpec.makeMeasureSpec( view.getHeight(), MeasureSpec.EXACTLY ) );
|
|
189
|
+
mediaView.layout( 0, 0, view.getWidth(), view.getHeight() );
|
|
190
|
+
view.addView( mediaView );
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
public void setOptionsView(final int tag)
|
|
194
|
+
{
|
|
195
|
+
View optionsView = nativeAd.getNativeAd().getOptionsView();
|
|
196
|
+
if ( optionsView == null ) return;
|
|
197
|
+
|
|
198
|
+
ViewGroup view = findViewById( tag );
|
|
199
|
+
if ( view == null )
|
|
200
|
+
{
|
|
201
|
+
AppLovinMAXModule.e( "Cannot find an options view with tag \"" + tag + "\" for " + adUnitId );
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
optionsView.measure( MeasureSpec.makeMeasureSpec( view.getWidth(), MeasureSpec.EXACTLY ),
|
|
206
|
+
MeasureSpec.makeMeasureSpec( view.getHeight(), MeasureSpec.EXACTLY ) );
|
|
207
|
+
optionsView.layout( 0, 0, view.getWidth(), view.getHeight() );
|
|
208
|
+
view.addView( optionsView );
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
public void setIconView(final int tag)
|
|
212
|
+
{
|
|
213
|
+
ImageView view = findViewById( tag );
|
|
214
|
+
if ( view == null )
|
|
215
|
+
{
|
|
216
|
+
AppLovinMAXModule.e( "Cannot find an icon image with tag \"" + tag + "\" for " + adUnitId );
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
view.setClickable( true );
|
|
221
|
+
clickableViews.add( view );
|
|
222
|
+
|
|
223
|
+
MaxNativeAdImage icon = nativeAd.getNativeAd().getIcon();
|
|
224
|
+
|
|
225
|
+
// Check if "URL" was missing and therefore need to set the image data
|
|
226
|
+
if ( icon.getUri() == null && icon.getDrawable() != null )
|
|
227
|
+
{
|
|
228
|
+
view.setImageDrawable( nativeAd.getNativeAd().getIcon().getDrawable() );
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/// Ad Loader Callback
|
|
233
|
+
|
|
234
|
+
class NativeAdListener
|
|
235
|
+
extends MaxNativeAdListener
|
|
236
|
+
{
|
|
237
|
+
@Override
|
|
238
|
+
public void onNativeAdLoaded(@Nullable final MaxNativeAdView nativeAdView, final MaxAd ad)
|
|
239
|
+
{
|
|
240
|
+
AppLovinMAXModule.d( "Native ad loaded: " + ad );
|
|
241
|
+
|
|
242
|
+
// 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
|
|
243
|
+
if ( nativeAdView != null )
|
|
244
|
+
{
|
|
245
|
+
isLoading.set( false );
|
|
246
|
+
|
|
247
|
+
AppLovinMAXModule.e( "Native ad is of template type, failing ad load..." );
|
|
248
|
+
AppLovinMAXModule.getInstance().handleNativeAdLoadFailureForAdUnitId( adUnitId, null );
|
|
249
|
+
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
maybeDestroyCurrentAd();
|
|
254
|
+
|
|
255
|
+
nativeAd = ad;
|
|
256
|
+
|
|
257
|
+
// Notify `AppLovinNativeAdView.js`
|
|
258
|
+
sendAdLoadedReactNativeEventForAd( ad.getNativeAd() );
|
|
259
|
+
|
|
260
|
+
// After notifying the RN layer - have slight delay to let views bind to this layer in `clickableViews` before registering
|
|
261
|
+
runOnUiThreadDelayed( () -> {
|
|
262
|
+
// Notify publisher
|
|
263
|
+
AppLovinMAXModule.getInstance().onAdLoaded( ad );
|
|
264
|
+
|
|
265
|
+
adLoader.a( clickableViews, AppLovinMAXNativeAdView.this, ad );
|
|
266
|
+
adLoader.b( ad );
|
|
267
|
+
|
|
268
|
+
isLoading.set( false );
|
|
269
|
+
}, 500L );
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
@Override
|
|
273
|
+
public void onNativeAdLoadFailed(final String adUnitId, final MaxError error)
|
|
274
|
+
{
|
|
275
|
+
isLoading.set( false );
|
|
276
|
+
|
|
277
|
+
AppLovinMAXModule.e( "Failed to load native ad for Ad Unit ID " + adUnitId + " with error: " + error );
|
|
278
|
+
|
|
279
|
+
// Notify publisher
|
|
280
|
+
AppLovinMAXModule.getInstance().handleNativeAdLoadFailureForAdUnitId( adUnitId, error );
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
@Override
|
|
284
|
+
public void onNativeAdClicked(final MaxAd ad)
|
|
285
|
+
{
|
|
286
|
+
AppLovinMAXModule.getInstance().onAdClicked( ad );
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
private void sendAdLoadedReactNativeEventForAd(final MaxNativeAd ad)
|
|
291
|
+
{
|
|
292
|
+
WritableMap jsNativeAd = Arguments.createMap();
|
|
293
|
+
|
|
294
|
+
jsNativeAd.putString( "title", ad.getTitle() );
|
|
295
|
+
if ( ad.getAdvertiser() != null )
|
|
296
|
+
{
|
|
297
|
+
jsNativeAd.putString( "advertiser", ad.getAdvertiser() );
|
|
298
|
+
}
|
|
299
|
+
if ( ad.getBody() != null )
|
|
300
|
+
{
|
|
301
|
+
jsNativeAd.putString( "body", ad.getBody() );
|
|
302
|
+
}
|
|
303
|
+
if ( ad.getCallToAction() != null )
|
|
304
|
+
{
|
|
305
|
+
jsNativeAd.putString( "callToAction", ad.getCallToAction() );
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
MaxNativeAdImage icon = ad.getIcon();
|
|
309
|
+
if ( icon != null )
|
|
310
|
+
{
|
|
311
|
+
if ( icon.getUri() != null )
|
|
312
|
+
{
|
|
313
|
+
jsNativeAd.putString( "url", icon.getUri().toString() );
|
|
314
|
+
}
|
|
315
|
+
else if ( icon.getDrawable() != null )
|
|
316
|
+
{
|
|
317
|
+
jsNativeAd.putBoolean( "image", true );
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
float aspectRatio = ad.getMediaContentAspectRatio();
|
|
322
|
+
if ( !Float.isNaN( aspectRatio ) )
|
|
323
|
+
{
|
|
324
|
+
jsNativeAd.putDouble( "mediaContentAspectRatio", aspectRatio );
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// Send to `AppLovinNativeAdView.js` to render the views
|
|
328
|
+
reactContext.getJSModule( RCTEventEmitter.class ).receiveEvent( getId(), "onAdLoaded", jsNativeAd );
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
private void maybeDestroyCurrentAd()
|
|
332
|
+
{
|
|
333
|
+
if ( nativeAd != null )
|
|
334
|
+
{
|
|
335
|
+
if ( nativeAd.getNativeAd() != null )
|
|
336
|
+
{
|
|
337
|
+
View view = nativeAd.getNativeAd().getMediaView();
|
|
338
|
+
if ( view != null )
|
|
339
|
+
{
|
|
340
|
+
ViewGroup parentView = (ViewGroup) view.getParent();
|
|
341
|
+
if ( parentView != null )
|
|
342
|
+
{
|
|
343
|
+
parentView.removeView( view );
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
view = nativeAd.getNativeAd().getOptionsView();
|
|
348
|
+
if ( view != null )
|
|
349
|
+
{
|
|
350
|
+
ViewGroup parentView = (ViewGroup) view.getParent();
|
|
351
|
+
if ( parentView != null )
|
|
352
|
+
{
|
|
353
|
+
parentView.removeView( view );
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
adLoader.destroy( nativeAd );
|
|
359
|
+
|
|
360
|
+
nativeAd = null;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
clickableViews.clear();
|
|
364
|
+
}
|
|
365
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
package com.applovin.reactnative;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
6
|
+
import com.facebook.react.common.MapBuilder;
|
|
7
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
8
|
+
import com.facebook.react.uimanager.ViewGroupManager;
|
|
9
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
10
|
+
|
|
11
|
+
import java.util.Map;
|
|
12
|
+
|
|
13
|
+
import androidx.annotation.NonNull;
|
|
14
|
+
import androidx.annotation.Nullable;
|
|
15
|
+
|
|
16
|
+
public class AppLovinMAXNativeAdViewManager
|
|
17
|
+
extends ViewGroupManager<AppLovinMAXNativeAdView>
|
|
18
|
+
{
|
|
19
|
+
public static final String REACT_CLASS = "AppLovinMAXNativeAdView";
|
|
20
|
+
|
|
21
|
+
public final int COMMAND_LOAD_AD = 1;
|
|
22
|
+
|
|
23
|
+
public AppLovinMAXNativeAdViewManager(final ReactApplicationContext callerContext) { }
|
|
24
|
+
|
|
25
|
+
@NonNull
|
|
26
|
+
@Override
|
|
27
|
+
protected AppLovinMAXNativeAdView createViewInstance(@NonNull final ThemedReactContext reactContext)
|
|
28
|
+
{
|
|
29
|
+
return new AppLovinMAXNativeAdView( reactContext );
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@NonNull
|
|
33
|
+
@Override
|
|
34
|
+
public String getName()
|
|
35
|
+
{
|
|
36
|
+
return REACT_CLASS;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/// Callback to JavaScript
|
|
40
|
+
|
|
41
|
+
@Nullable
|
|
42
|
+
@Override
|
|
43
|
+
public Map<String, Object> getExportedCustomDirectEventTypeConstants()
|
|
44
|
+
{
|
|
45
|
+
return MapBuilder.<String, Object>builder()
|
|
46
|
+
.put( "onAdLoaded", MapBuilder.of( "registrationName", "onAdLoaded" ) )
|
|
47
|
+
.build();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/// Call from JavaScript
|
|
51
|
+
|
|
52
|
+
@Nullable
|
|
53
|
+
@Override
|
|
54
|
+
public Map<String, Integer> getCommandsMap()
|
|
55
|
+
{
|
|
56
|
+
return MapBuilder.of(
|
|
57
|
+
"loadAd", COMMAND_LOAD_AD
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// NOTE: the method is deprecated but the new version won't work
|
|
62
|
+
@Override
|
|
63
|
+
public void receiveCommand(@NonNull final AppLovinMAXNativeAdView root, final int commandId, @Nullable final ReadableArray args)
|
|
64
|
+
{
|
|
65
|
+
switch ( commandId )
|
|
66
|
+
{
|
|
67
|
+
case COMMAND_LOAD_AD:
|
|
68
|
+
root.loadAd();
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/// Property Setters
|
|
74
|
+
|
|
75
|
+
@ReactProp(name = "adUnitId")
|
|
76
|
+
public void setAdUnitId(final AppLovinMAXNativeAdView view, final String value)
|
|
77
|
+
{
|
|
78
|
+
view.setAdUnitId( value );
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@ReactProp(name = "placement")
|
|
82
|
+
public void setPlacement(final AppLovinMAXNativeAdView view, @Nullable final String value)
|
|
83
|
+
{
|
|
84
|
+
view.setPlacement( value );
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@ReactProp(name = "customData")
|
|
88
|
+
public void setCustomData(final AppLovinMAXNativeAdView view, @Nullable final String value)
|
|
89
|
+
{
|
|
90
|
+
view.setCustomData( value );
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@ReactProp(name = "extraParameters")
|
|
94
|
+
public void setExtraParameters(final AppLovinMAXNativeAdView view, @Nullable final ReadableMap value)
|
|
95
|
+
{
|
|
96
|
+
view.setExtraParameters( value );
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@ReactProp(name = "titleView")
|
|
100
|
+
public void setTitleView(final AppLovinMAXNativeAdView view, final int value)
|
|
101
|
+
{
|
|
102
|
+
view.setTitleView( value );
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@ReactProp(name = "advertiserView")
|
|
106
|
+
public void setAdvertiserView(final AppLovinMAXNativeAdView view, final int value)
|
|
107
|
+
{
|
|
108
|
+
view.setAdvertiserView( value );
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@ReactProp(name = "bodyView")
|
|
112
|
+
public void setBodyView(final AppLovinMAXNativeAdView view, final int value)
|
|
113
|
+
{
|
|
114
|
+
view.setBodyView( value );
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@ReactProp(name = "callToActionView")
|
|
118
|
+
public void setCallToActionView(final AppLovinMAXNativeAdView view, final int value)
|
|
119
|
+
{
|
|
120
|
+
view.setCallToActionView( value );
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@ReactProp(name = "mediaView")
|
|
124
|
+
public void setMediaView(final AppLovinMAXNativeAdView view, final int value)
|
|
125
|
+
{
|
|
126
|
+
view.setMediaView( value );
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@ReactProp(name = "optionsView")
|
|
130
|
+
public void setOptionsView(final AppLovinMAXNativeAdView view, final int value)
|
|
131
|
+
{
|
|
132
|
+
view.setOptionsView( value );
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@ReactProp(name = "iconView")
|
|
136
|
+
public void setIconView(final AppLovinMAXNativeAdView view, final int value)
|
|
137
|
+
{
|
|
138
|
+
view.setIconView( value );
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
@Override
|
|
142
|
+
public void onDropViewInstance(@NonNull final AppLovinMAXNativeAdView view)
|
|
143
|
+
{
|
|
144
|
+
view.destroy();
|
|
145
|
+
|
|
146
|
+
super.onDropViewInstance( view );
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -27,8 +27,9 @@ public class AppLovinMAXPackage
|
|
|
27
27
|
@Override
|
|
28
28
|
public @NonNull List<ViewManager> createViewManagers(@NonNull final ReactApplicationContext reactContext)
|
|
29
29
|
{
|
|
30
|
-
List<ViewManager> viewManagers = new ArrayList<>(
|
|
30
|
+
List<ViewManager> viewManagers = new ArrayList<>( 2 );
|
|
31
31
|
viewManagers.add( new AppLovinMAXAdViewManager( reactContext ) );
|
|
32
|
+
viewManagers.add( new AppLovinMAXNativeAdViewManager( reactContext ) );
|
|
32
33
|
return viewManagers;
|
|
33
34
|
}
|
|
34
35
|
}
|
package/ios/AppLovinMAX.h
CHANGED
|
@@ -31,6 +31,16 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
31
31
|
*/
|
|
32
32
|
@property (nonatomic, weak, readonly) ALSdk *sdk;
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Convenience method for unified logging in the AppLovin module.
|
|
36
|
+
*/
|
|
37
|
+
- (void)log:(NSString *)format, ...;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Convenience method for invoking a native ad load failure event.
|
|
41
|
+
*/
|
|
42
|
+
- (void)handleNativeAdLoadFailureForAdUnitIdentifier:(NSString *)adUnitIdentifier error:(nullable MAError *)error;
|
|
43
|
+
|
|
34
44
|
@end
|
|
35
45
|
|
|
36
46
|
NS_ASSUME_NONNULL_END
|
package/ios/AppLovinMAX.m
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
//
|
|
8
8
|
|
|
9
9
|
#import "AppLovinMAX.h"
|
|
10
|
+
#import "AppLovinMAXNativeAdView.h"
|
|
10
11
|
|
|
11
12
|
#define ROOT_VIEW_CONTROLLER (UIApplication.sharedApplication.keyWindow.rootViewController)
|
|
12
13
|
|
|
@@ -187,7 +188,7 @@ RCT_EXPORT_METHOD(initialize:(NSString *)pluginVersion :(NSString *)sdkKey :(RCT
|
|
|
187
188
|
// Set verbose logging state if needed
|
|
188
189
|
if ( self.verboseLoggingToSet )
|
|
189
190
|
{
|
|
190
|
-
self.sdk.settings.
|
|
191
|
+
self.sdk.settings.verboseLoggingEnabled = self.verboseLoggingToSet.boolValue;
|
|
191
192
|
self.verboseLoggingToSet = nil;
|
|
192
193
|
}
|
|
193
194
|
|
|
@@ -207,8 +208,8 @@ RCT_EXPORT_METHOD(initialize:(NSString *)pluginVersion :(NSString *)sdkKey :(RCT
|
|
|
207
208
|
|
|
208
209
|
[self setPendingExtraParametersIfNeeded: self.sdk.settings];
|
|
209
210
|
|
|
210
|
-
[self.sdk initializeSdkWithCompletionHandler:^(ALSdkConfiguration *configuration)
|
|
211
|
-
|
|
211
|
+
[self.sdk initializeSdkWithCompletionHandler:^(ALSdkConfiguration *configuration) {
|
|
212
|
+
|
|
212
213
|
[self log: @"SDK initialized"];
|
|
213
214
|
|
|
214
215
|
self.sdkConfiguration = configuration;
|
|
@@ -312,7 +313,7 @@ RCT_EXPORT_METHOD(setVerboseLogging:(BOOL)enabled)
|
|
|
312
313
|
{
|
|
313
314
|
if ( [self isPluginInitialized] )
|
|
314
315
|
{
|
|
315
|
-
self.sdk.settings.
|
|
316
|
+
self.sdk.settings.verboseLoggingEnabled = enabled;
|
|
316
317
|
self.verboseLoggingToSet = nil;
|
|
317
318
|
}
|
|
318
319
|
else
|
|
@@ -731,6 +732,10 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
731
732
|
{
|
|
732
733
|
name = @"OnRewardedAdLoadedEvent";
|
|
733
734
|
}
|
|
735
|
+
else if ( MAAdFormat.native == adFormat )
|
|
736
|
+
{
|
|
737
|
+
name = @"OnNativeAdLoadedEvent";
|
|
738
|
+
}
|
|
734
739
|
else
|
|
735
740
|
{
|
|
736
741
|
[self logInvalidAdFormat: adFormat];
|
|
@@ -740,6 +745,16 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
740
745
|
[self sendReactNativeEventWithName: name body: [self adInfoForAd: ad]];
|
|
741
746
|
}
|
|
742
747
|
|
|
748
|
+
- (void)handleNativeAdLoadFailureForAdUnitIdentifier:(NSString *)adUnitIdentifier error:(nullable MAError *)error
|
|
749
|
+
{
|
|
750
|
+
[self sendReactNativeEventWithName: @"OnNativeAdLoadFailedEvent"
|
|
751
|
+
body: @{@"adUnitId" : adUnitIdentifier,
|
|
752
|
+
@"code" : @(error.code),
|
|
753
|
+
@"message" : error.message,
|
|
754
|
+
@"adLoadFailureInfo" : error.adLoadFailureInfo ?: @"",
|
|
755
|
+
@"waterfall": [self createAdWaterfallInfo: error.waterfall]}];
|
|
756
|
+
}
|
|
757
|
+
|
|
743
758
|
- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error
|
|
744
759
|
{
|
|
745
760
|
if ( !adUnitIdentifier )
|
|
@@ -794,6 +809,10 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
794
809
|
{
|
|
795
810
|
name = @"OnRewardedAdClickedEvent";
|
|
796
811
|
}
|
|
812
|
+
else if ( MAAdFormat.native == adFormat )
|
|
813
|
+
{
|
|
814
|
+
name = @"OnNativeAdClickedEvent";
|
|
815
|
+
}
|
|
797
816
|
else
|
|
798
817
|
{
|
|
799
818
|
[self logInvalidAdFormat: adFormat];
|
|
@@ -910,6 +929,10 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
910
929
|
{
|
|
911
930
|
name = @"OnRewardedAdRevenuePaid";
|
|
912
931
|
}
|
|
932
|
+
else if ( MAAdFormat.native == adFormat )
|
|
933
|
+
{
|
|
934
|
+
name = @"OnNativeAdRevenuePaid";
|
|
935
|
+
}
|
|
913
936
|
else
|
|
914
937
|
{
|
|
915
938
|
[self logInvalidAdFormat: adFormat];
|
|
@@ -1574,7 +1597,12 @@ RCT_EXPORT_METHOD(setRewardedAdExtraParameter:(NSString *)adUnitIdentifier :(NSS
|
|
|
1574
1597
|
@"OnRewardedAdFailedToDisplayEvent",
|
|
1575
1598
|
@"OnRewardedAdHiddenEvent",
|
|
1576
1599
|
@"OnRewardedAdReceivedRewardEvent",
|
|
1577
|
-
@"OnRewardedAdRevenuePaid"
|
|
1600
|
+
@"OnRewardedAdRevenuePaid",
|
|
1601
|
+
|
|
1602
|
+
@"OnNativeAdLoadedEvent",
|
|
1603
|
+
@"OnNativeAdLoadFailedEvent",
|
|
1604
|
+
@"OnNativeAdClickedEvent",
|
|
1605
|
+
@"OnNativeAdRevenuePaid"];
|
|
1578
1606
|
}
|
|
1579
1607
|
|
|
1580
1608
|
- (void)startObserving
|
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
/* Begin PBXBuildFile section */
|
|
10
10
|
1D2890F5251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D2890F4251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m */; };
|
|
11
|
+
1D3CC34128C18441003E5A07 /* AppLovinMAXAdView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3CC34028C18441003E5A07 /* AppLovinMAXAdView.m */; };
|
|
11
12
|
1DEA13CD24B9258700D42847 /* AppLovinMAX.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DEA13CC24B9258700D42847 /* AppLovinMAX.m */; };
|
|
13
|
+
7A47215228D8968100854002 /* AppLovinMAXNativeAdViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A47214F28D8968100854002 /* AppLovinMAXNativeAdViewManager.m */; };
|
|
14
|
+
7A47215728D8968800854002 /* AppLovinMAXNativeAdView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A47215328D8968800854002 /* AppLovinMAXNativeAdView.m */; };
|
|
12
15
|
DE4E5A3D46DDFAE766DFFE58 /* libPods-AppLovinMAX.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EF1B4EBC7187611714984C78 /* libPods-AppLovinMAX.a */; };
|
|
13
16
|
/* End PBXBuildFile section */
|
|
14
17
|
|
|
@@ -29,7 +32,13 @@
|
|
|
29
32
|
134814201AA4EA6300B7C361 /* libAppLovinMAX.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAppLovinMAX.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
30
33
|
1D2890F3251ABC83004F1CC4 /* AppLovinMAXAdViewManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppLovinMAXAdViewManager.h; sourceTree = "<group>"; };
|
|
31
34
|
1D2890F4251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppLovinMAXAdViewManager.m; sourceTree = "<group>"; };
|
|
35
|
+
1D3CC33F28C18440003E5A07 /* AppLovinMAXAdView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppLovinMAXAdView.h; sourceTree = "<group>"; };
|
|
36
|
+
1D3CC34028C18441003E5A07 /* AppLovinMAXAdView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppLovinMAXAdView.m; sourceTree = "<group>"; };
|
|
32
37
|
1DEA13CC24B9258700D42847 /* AppLovinMAX.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppLovinMAX.m; sourceTree = "<group>"; };
|
|
38
|
+
7A47214F28D8968100854002 /* AppLovinMAXNativeAdViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppLovinMAXNativeAdViewManager.m; sourceTree = "<group>"; };
|
|
39
|
+
7A47215128D8968100854002 /* AppLovinMAXNativeAdViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppLovinMAXNativeAdViewManager.h; sourceTree = "<group>"; };
|
|
40
|
+
7A47215328D8968800854002 /* AppLovinMAXNativeAdView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppLovinMAXNativeAdView.m; sourceTree = "<group>"; };
|
|
41
|
+
7A47215428D8968800854002 /* AppLovinMAXNativeAdView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppLovinMAXNativeAdView.h; sourceTree = "<group>"; };
|
|
33
42
|
B3E7B5881CC2AC0600A0062D /* AppLovinMAX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppLovinMAX.h; sourceTree = "<group>"; };
|
|
34
43
|
EF1B4EBC7187611714984C78 /* libPods-AppLovinMAX.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AppLovinMAX.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
35
44
|
F80C453A02323F11AB9FD612 /* Pods-AppLovinMAX.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AppLovinMAX.release.xcconfig"; path = "Target Support Files/Pods-AppLovinMAX/Pods-AppLovinMAX.release.xcconfig"; sourceTree = "<group>"; };
|
|
@@ -68,11 +77,17 @@
|
|
|
68
77
|
children = (
|
|
69
78
|
B3E7B5881CC2AC0600A0062D /* AppLovinMAX.h */,
|
|
70
79
|
1DEA13CC24B9258700D42847 /* AppLovinMAX.m */,
|
|
80
|
+
1D3CC33F28C18440003E5A07 /* AppLovinMAXAdView.h */,
|
|
81
|
+
1D3CC34028C18441003E5A07 /* AppLovinMAXAdView.m */,
|
|
71
82
|
1D2890F3251ABC83004F1CC4 /* AppLovinMAXAdViewManager.h */,
|
|
72
83
|
1D2890F4251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m */,
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
7A47215428D8968800854002 /* AppLovinMAXNativeAdView.h */,
|
|
85
|
+
7A47215328D8968800854002 /* AppLovinMAXNativeAdView.m */,
|
|
86
|
+
7A47215128D8968100854002 /* AppLovinMAXNativeAdViewManager.h */,
|
|
87
|
+
7A47214F28D8968100854002 /* AppLovinMAXNativeAdViewManager.m */,
|
|
75
88
|
1E696A0F28A9ED7C75EC4EC0 /* Frameworks */,
|
|
89
|
+
B20EE642686C6BAEB6C5B87A /* Pods */,
|
|
90
|
+
134814211AA4EA7D00B7C361 /* Products */,
|
|
76
91
|
);
|
|
77
92
|
sourceTree = "<group>";
|
|
78
93
|
};
|
|
@@ -168,7 +183,10 @@
|
|
|
168
183
|
isa = PBXSourcesBuildPhase;
|
|
169
184
|
buildActionMask = 2147483647;
|
|
170
185
|
files = (
|
|
186
|
+
7A47215228D8968100854002 /* AppLovinMAXNativeAdViewManager.m in Sources */,
|
|
171
187
|
1D2890F5251ABC83004F1CC4 /* AppLovinMAXAdViewManager.m in Sources */,
|
|
188
|
+
7A47215728D8968800854002 /* AppLovinMAXNativeAdView.m in Sources */,
|
|
189
|
+
1D3CC34128C18441003E5A07 /* AppLovinMAXAdView.m in Sources */,
|
|
172
190
|
1DEA13CD24B9258700D42847 /* AppLovinMAX.m in Sources */,
|
|
173
191
|
);
|
|
174
192
|
runOnlyForDeploymentPostprocessing = 0;
|