Skip to content

Commit

Permalink
Add support for latest SDKs v10.3.0 with new callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasmso committed May 26, 2021
1 parent 6c594b0 commit 2d781c8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Versions

## x.x.x
* Add support for latest SDKs v10.3.0 with new callbacks.
* Fallback to SDK key in Android Manifest and Info.plist if not passed programmatically.
## 1.0.4
* Pass `"countryCode"` in initialization callback.
Expand Down
17 changes: 13 additions & 4 deletions plugin/src/android/AppLovinMAX.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.applovin.mediation.MaxAdFormat;
import com.applovin.mediation.MaxAdListener;
import com.applovin.mediation.MaxAdViewAdListener;
import com.applovin.mediation.MaxError;
import com.applovin.mediation.MaxReward;
import com.applovin.mediation.MaxRewardedAdListener;
import com.applovin.mediation.ads.MaxAdView;
Expand Down Expand Up @@ -517,7 +518,7 @@ else if ( MaxAdFormat.REWARDED == adFormat )
}

@Override
public void onAdLoadFailed(final String adUnitId, final int errorCode)
public void onAdLoadFailed(final String adUnitId, final MaxError error)
{
if ( TextUtils.isEmpty( adUnitId ) )
{
Expand Down Expand Up @@ -548,7 +549,8 @@ else if ( mRewardedAds.containsKey( adUnitId ) )
{
JSONObject params = new JSONObject();
params.put( "adUnitId", adUnitId );
params.put( "errorCode", Integer.toString( errorCode ) );
params.put( "errorCode", Integer.toString( error.getCode() ) );
// TODO: Add "code", "message", and "adLoadFailureInfo"
fireWindowEvent( name, params );
}
catch ( Throwable ignored ) { }
Expand Down Expand Up @@ -605,7 +607,7 @@ public void onAdDisplayed(final MaxAd ad)
}

@Override
public void onAdDisplayFailed(final MaxAd ad, final int errorCode)
public void onAdDisplayFailed(final MaxAd ad, final MaxError error)
{
// BMLs do not support [DISPLAY] events
final MaxAdFormat adFormat = ad.getFormat();
Expand All @@ -624,7 +626,8 @@ public void onAdDisplayFailed(final MaxAd ad, final int errorCode)
try
{
JSONObject params = getAdInfo( ad );
params.put( "errorCode", Integer.toString( errorCode ) );
params.put( "errorCode", Integer.toString( error.getCode() ) );
// TODO: Add "code", "message"
fireWindowEvent( name, params );
}
catch ( Throwable ignored ) { }
Expand Down Expand Up @@ -711,6 +714,12 @@ public void onUserRewarded(final MaxAd ad, final MaxReward reward)
catch ( Throwable ignored ) { }
}

@Override
public void onAdRevenuePaid(final MaxAd ad)
{
// TODO: Add Support
}

// INTERNAL METHODS

private void createAdView(final String adUnitId, final MaxAdFormat adFormat, final String adViewPosition, final CallbackContext callbackContext)
Expand Down
15 changes: 11 additions & 4 deletions plugin/src/ios/AppLovinMAX.m
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ - (void)didLoadAd:(MAAd *)ad
[self fireWindowEventWithName: name body: [self adInfoForAd: ad]];
}

- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withErrorCode:(NSInteger)errorCode
- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error
{
if ( !adUnitIdentifier )
{
Expand All @@ -558,7 +558,8 @@ - (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withErro
return;
}

NSString *errorCodeStr = [@(errorCode) stringValue];
// TODO: Add "code", "message", and "adLoadFailureInfo"
NSString *errorCodeStr = [@(error.code) stringValue];
[self fireWindowEventWithName: name body: @{@"adUnitId" : adUnitIdentifier,
@"errorCode" : errorCodeStr}];
}
Expand Down Expand Up @@ -611,7 +612,7 @@ - (void)didDisplayAd:(MAAd *)ad
[self fireWindowEventWithName: name body: [self adInfoForAd: ad]];
}

- (void)didFailToDisplayAd:(MAAd *)ad withErrorCode:(NSInteger)errorCode
- (void)didFailToDisplayAd:(MAAd *)ad withError:(MAError *)error
{
// BMLs do not support [DISPLAY] events in Unity
MAAdFormat *adFormat = ad.format;
Expand All @@ -627,7 +628,8 @@ - (void)didFailToDisplayAd:(MAAd *)ad withErrorCode:(NSInteger)errorCode
name = @"OnRewardedAdFailedToDisplayEvent";
}

NSMutableDictionary *body = [@{@"errorCode" : @(errorCode)} mutableCopy];
// TODO: Add "code", "message"
NSMutableDictionary *body = [@{@"errorCode" : @(error.code)} mutableCopy];
[body addEntriesFromDictionary: [self adInfoForAd: ad]];

[self fireWindowEventWithName: name body: body];
Expand Down Expand Up @@ -708,6 +710,11 @@ - (void)didRewardUserForAd:(MAAd *)ad withReward:(MAReward *)reward
[self fireWindowEventWithName: @"OnRewardedAdReceivedRewardEvent" body: body];
}

- (void)didPayRevenueForAd:(MAAd *)ad
{
// TODO: Implement
}

#pragma mark - Internal Methods

- (void)createAdViewWithAdUnitIdentifier:(NSString *)adUnitIdentifier adFormat:(MAAdFormat *)adFormat atPosition:(NSString *)adViewPosition command:(CDVInvokedUrlCommand *)command
Expand Down

0 comments on commit 2d781c8

Please sign in to comment.