Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fyber support #1

Open
wants to merge 9 commits into
base: FyberNewAdapter
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions AdMob/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## Changelog
* 7.69.0.3
* Fix static banner size leaking to subsequent adapter instances.

* 7.69.0.2
* Add support for `fullscreenAdAdapterAdWillDismiss` when a fullscreen creative is about to close. Publishers must use v5.16.1 of the MoPub SDK at the minimum.

Expand Down
2 changes: 1 addition & 1 deletion AdMob/GoogleAdMobAdapterConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ + (void)updateInitializationParameters:(NSDictionary *)parameters {
#pragma mark - MPAdapterConfiguration

- (NSString *)adapterVersion {
return @"7.69.0.2";
return @"7.69.0.3";
}

- (NSString *)biddingToken {
Expand Down
16 changes: 7 additions & 9 deletions AdMob/MPGoogleAdMobBannerCustomEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ @interface MPGoogleAdMobBannerCustomEvent () <GADBannerViewDelegate>

@property(nonatomic, strong) GADBannerView *adBannerView;

@property(nonatomic) CGSize adSize;

@end

@implementation MPGoogleAdMobBannerCustomEvent
@dynamic delegate;
@dynamic localExtras;

CGFloat adWidth;
CGFloat adHeight;

- (id)init {
self = [super init];
if (self) {
Expand All @@ -45,10 +44,9 @@ - (void)dealloc {
}

- (void)requestAdWithSize:(CGSize)size adapterInfo:(NSDictionary *)info adMarkup:(NSString *)adMarkup {
adWidth = size.width;
adHeight = size.height;
self.adSize = size;

if (adWidth <= 0.0 || adHeight <= 0.0) {
if (self.adSize.width <= 0.0 || self.adSize.height <= 0.0) {
NSString *failureReason = @"Google AdMob banner failed to load due to invalid ad width and/or height.";
NSError *mopubError = [NSError errorWithCode:MOPUBErrorAdapterInvalid localizedDescription:failureReason];

Expand All @@ -58,7 +56,7 @@ - (void)requestAdWithSize:(CGSize)size adapterInfo:(NSDictionary *)info adMarkup
return;
}

self.adBannerView.frame = CGRectMake(0, 0, adWidth, adHeight);
self.adBannerView.frame = (CGRect){CGPointZero, self.adSize};
self.adBannerView.adUnitID = [info objectForKey:@"adUnitID"];
self.adBannerView.rootViewController = [self.delegate inlineAdAdapterViewControllerForPresentingModalView:self];

Expand Down Expand Up @@ -107,8 +105,8 @@ - (void)adViewDidReceiveAd:(GADBannerView *)bannerView {
CGFloat receivedWidth = bannerView.adSize.size.width;
CGFloat receivedHeight = bannerView.adSize.size.height;

if (receivedWidth > adWidth || receivedHeight > adHeight) {
NSString *failureReason = [NSString stringWithFormat:@"Google served an ad but it was invalidated because its size of %.0f x %.0f exceeds the publisher-specified size of %.0f x %.0f", receivedWidth, receivedHeight, adWidth, adHeight];
if (receivedWidth > self.adSize.width || receivedHeight > self.adSize.height) {
NSString *failureReason = [NSString stringWithFormat:@"Google served an ad but it was invalidated because its size of %.0f x %.0f exceeds the publisher-specified size of %.0f x %.0f", receivedWidth, receivedHeight, self.adSize.width, self.adSize.height];
NSError *mopubError = [NSError errorWithCode:MOPUBErrorAdapterInvalid localizedDescription:failureReason];

MPLogAdEvent([MPLogEvent adLoadFailedForAdapter:NSStringFromClass(self.class) error:mopubError], [self getAdNetworkId]);
Expand Down
3 changes: 0 additions & 3 deletions AdMob/MPGoogleAdMobInterstitialCustomEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ - (void)requestAdWithAdapterInfo:(NSDictionary *)info adMarkup:(NSString *)adMar

request.requestAgent = @"MoPub";

// Consent collected from the MoPub’s consent dialogue should not be used to set up Google's
// personalization preference. Publishers should work with Google to be GDPR-compliant.

NSString *npaValue = GoogleAdMobAdapterConfiguration.npaString;

if (npaValue.length > 0) {
Expand Down
3 changes: 0 additions & 3 deletions AdMob/MPGoogleAdMobNativeCustomEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ - (void)requestAdWithCustomEventInfo:(NSDictionary *)info adMarkup:(NSString *)a
options:@[ nativeAdImageLoaderOptions, nativeAdViewAdOptions, nativeAdMediaAdLoaderOptions ]];
self.adLoader.delegate = self;

// Consent collected from the MoPub’s consent dialogue should not be used to set up
// Google's personalization preference. Publishers should work with Google to be GDPR-compliant.

NSString *npaValue = GoogleAdMobAdapterConfiguration.npaString;

if (npaValue.length > 0) {
Expand Down
5 changes: 1 addition & 4 deletions AdMob/MPGoogleAdMobRewardedVideoCustomEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ - (void)requestAdWithAdapterInfo:(NSDictionary *)info adMarkup:(NSString *)adMar
request.contentURL = contentUrl;
}
}

// Consent collected from the MoPub’s consent dialogue should not be used to set up Google's
// personalization preference. Publishers should work with Google to be GDPR-compliant.


NSString *npaValue = GoogleAdMobAdapterConfiguration.npaString;

if (npaValue.length > 0) {
Expand Down
4 changes: 3 additions & 1 deletion AppLovin/AppLovinAdapterConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ @implementation AppLovinAdapterConfiguration

static NSString *const kAppLovinSDKInfoPlistKey = @"AppLovinSdkKey";
static NSString *const kAdapterErrorDomain = @"com.mopub.mopub-ios-sdk.mopub-applovin-adapters";
static NSString *const kAdapterVersion = @"6.15.2.1";
static NSString *const kAdapterVersion = @"10.0.1.0";

static NSString *gSdkKey = nil;

Expand Down Expand Up @@ -60,6 +60,8 @@ - (void)initializeNetworkWithConfiguration:(NSDictionary<NSString *, id> *)confi
if ( sdk )
{
AppLovinAdapterConfigurationSDK = sdk;
sdk.mediationProvider = ALMediationProviderMoPub;
[sdk setPluginVersion: AppLovinAdapterConfiguration.pluginVersion];
}
// If SDK could not be retrieved, it means SDK key was missing from `configuration` (cached or not) AND the Info.plist
else
Expand Down
4 changes: 4 additions & 0 deletions AppLovin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## Changelog
* 10.0.1.0
* Pass `mediationProvider` data for AppLovin SDK to collect ad source information.
* This version of the adapters has been certified with AppLovin SDK 10.0.1 and MoPub SDK 5.16.1.

* 6.15.2.1
* Add support for `fullscreenAdAdapterAdWillDismiss` when a fullscreen creative is about to close. Publishers must use v5.16.1 of the MoPub SDK at the minimum.

Expand Down
3 changes: 3 additions & 0 deletions Chartboost/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## Changelog
* 8.4.1.0
* This version of the adapters has been certified with Chartboost 8.4.1 and MoPub SDK 5.16.1.

* 8.4.0.1
* Add support for `fullscreenAdAdapterAdWillDismiss` when a fullscreen creative is about to close. Publishers must use v5.16.1 of the MoPub SDK at the minimum.

Expand Down
2 changes: 1 addition & 1 deletion Chartboost/ChartboostAdapterConfiguration.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import "ChartboostAdapterConfiguration.h"
#import "ChartboostRouter.h"

#define CHARTBOOST_ADAPTER_VERSION @"8.4.0.1"
#define CHARTBOOST_ADAPTER_VERSION @"8.4.1.0"
#define MOPUB_NETWORK_NAME @"chartboost"

// Constants
Expand Down
3 changes: 3 additions & 0 deletions FacebookAudienceNetwork/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## Changelog
* 6.3.1.0
* This version of the adapters has been certified with Facebook Audience Network 6.3.1 and MoPub 5.16.2.

* 6.3.0.0
* This version of the adapters has been certified with Facebook Audience Network 6.3.0 and MoPub 5.16.1.

Expand Down
2 changes: 1 addition & 1 deletion FacebookAudienceNetwork/FacebookAdapterConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#import "MPConstants.h"
#endif

#define FACEBOOK_ADAPTER_VERSION @"6.3.0.0"
#define FACEBOOK_ADAPTER_VERSION @"6.3.1.0"
#define MOPUB_NETWORK_NAME @"facebook"

static NSString * const kFacebookPlacementIDs = @"placement_ids";
Expand Down
5 changes: 5 additions & 0 deletions Fyber/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Changelog
* 7.8.5.0
* Initial Commit
* Add support for banner, interstitial and rewarded video.
* This version of the adapters has been certified with Fyber Marketplace 7.8.5 and MoPub SDK 5.17.0.
34 changes: 34 additions & 0 deletions Fyber/FyberAdapterConfiguration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#import <Foundation/Foundation.h>
#if __has_include(<MoPub/MoPub.h>)
#import <MoPub/MoPub.h>
#elif __has_include(<MoPubSDK/MoPub.h>)
#import <MoPubSDK/MoPub.h>
#else
#import <MoPub.h>
#import "MPBaseAdapterConfiguration.h"
#import "MPLogging.h"
#endif

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger, IASDKMopubAdapterError) {
IASDKMopubAdapterErrorUnknown = 1,
IASDKMopubAdapterErrorMissingAppID,
IASDKMopubAdapterErrorSDKInit,
IASDKMopubAdapterErrorInternal,
};

extern NSString * const kIASDKMopubAdapterAppIDKey;
extern NSString * const kIASDKMoPubAdapterErrorDomain;

extern NSNotificationName _Nonnull kIASDKInitCompleteNotification;

@interface FyberAdapterConfiguration : MPBaseAdapterConfiguration

+ (void)configureIASDKWithInfo:(NSDictionary *)info;

+ (void)collectConsentStatusFromMoPub;

@end

NS_ASSUME_NONNULL_END
117 changes: 117 additions & 0 deletions Fyber/FyberAdapterConfiguration.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#import "FyberAdapterConfiguration.h"

#import <IASDKCore/IASDKCore.h>
#import "MPLogging.h"

@implementation FyberAdapterConfiguration

#pragma mark - Consts

NSString * const kIASDKMopubAdapterAppIDKey = @"appID";
NSString * const kIASDKMoPubAdapterErrorDomain = @"com.mopub.IASDKAdapter";
NSNotificationName _Nonnull kIASDKInitCompleteNotification = @"kIASDKInitCompleteNotification";

#pragma mark - Static members

static dispatch_queue_t sIASDKInitSyncQueue = nil;

+ (void)initialize {
static BOOL initialised = NO;

if ((self == FyberAdapterConfiguration.self) && !initialised) { // invoke only once per application runtime (and not in subclasses);
initialised = YES;

sIASDKInitSyncQueue = dispatch_queue_create("com.Fyber.SDK.Marketplace.mediation.mopub.init", DISPATCH_QUEUE_SERIAL);
}
}

#pragma mark - MPAdapterConfiguration

- (NSString *)adapterVersion {
return @"7.8.5.0";
}

- (NSString *)biddingToken {
return nil;
}

- (NSString *)moPubNetworkName {
return @"fyber";
}

- (NSString *)networkSdkVersion {
return IASDKCore.sharedInstance.version;
}

#pragma mark - Overrides

- (void)initializeNetworkWithConfiguration:(NSDictionary<NSString *, id> *)configuration complete:(void(^)(NSError *))complete {
NSString *appID = configuration[kIASDKMopubAdapterAppIDKey];

if ([appID isEqualToString:IASDKCore.sharedInstance.appID]) {
if (complete) {
complete(nil);
}
} else {
dispatch_async(sIASDKInitSyncQueue, ^{
[IASDKCore.sharedInstance initWithAppID:appID completionBlock:^(BOOL success, NSError * _Nullable error) {
if (success || (error.code == IASDKCoreInitErrorTypeFailedToDownloadMandatoryData)) {
error = nil;
[NSNotificationCenter.defaultCenter postNotificationName:kIASDKInitCompleteNotification object:self];
}

if (complete) {
complete(error);
}

if (error) {
NSInteger errorCode = IASDKMopubAdapterErrorSDKInit;

if (!appID.length) {
errorCode = IASDKMopubAdapterErrorMissingAppID;
}

error = [NSError errorWithDomain:kIASDKMoPubAdapterErrorDomain code:errorCode userInfo:error.userInfo];
MPLogEvent([MPLogEvent error:error message:nil]);
} else {
[self.class setCachedInitializationParameters:configuration];
}
} completionQueue:nil];
});
}
}

#pragma mark - static API

+ (void)configureIASDKWithInfo:(NSDictionary *)info {
NSString *receivedAppID = info[kIASDKMopubAdapterAppIDKey];

dispatch_async(sIASDKInitSyncQueue, ^{
if (receivedAppID && [receivedAppID isKindOfClass:NSString.class] && receivedAppID.length && ![receivedAppID isEqualToString:IASDKCore.sharedInstance.appID]) {
[IASDKCore.sharedInstance initWithAppID:receivedAppID completionBlock:^(BOOL success, NSError * _Nullable error) {
[NSNotificationCenter.defaultCenter postNotificationName:kIASDKInitCompleteNotification object:self];
} completionQueue:nil];
}
});
}

+ (void)collectConsentStatusFromMoPub {

if (MoPub.sharedInstance.isGDPRApplicable == MPBoolYes) {
if (MoPub.sharedInstance.allowLegitimateInterest) {
if ((MoPub.sharedInstance.currentConsentStatus == MPConsentStatusDenied) ||
(MoPub.sharedInstance.currentConsentStatus == MPConsentStatusDoNotTrack) ||
(MoPub.sharedInstance.currentConsentStatus == MPConsentStatusPotentialWhitelist)) {
IASDKCore.sharedInstance.GDPRConsent = IAGDPRConsentTypeDenied;
} else {
IASDKCore.sharedInstance.GDPRConsent = IAGDPRConsentTypeGiven;
}
} else {
const BOOL canCollectPersonalInfo = MoPub.sharedInstance.canCollectPersonalInfo;

IASDKCore.sharedInstance.GDPRConsent = (canCollectPersonalInfo) ? IAGDPRConsentTypeGiven : IAGDPRConsentTypeDenied;
}
}
}

@end
16 changes: 16 additions & 0 deletions Fyber/FyberBannerCustomEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#if __has_include(<MoPub/MoPub.h>)
#import <MoPub/MoPub.h>
#elif __has_include(<MoPubSDK/MoPub.h>)
#import <MoPubSDK/MoPub.h>
#else
#import <MoPub.h>
#endif

/**
* @brief Banner Custom Event Class for MoPub SDK.
*
* @discussion Use in order to implement mediation with Inneractive Banner Ads.
*/
@interface FyberBannerCustomEvent : MPInlineAdAdapter <MPThirdPartyInlineAdAdapter>

@end
Loading