Skip to content

Commit

Permalink
[mopub] [ios] Added Mopub framework.
Browse files Browse the repository at this point in the history
  • Loading branch information
igrechuhin committed Apr 13, 2017
1 parent d5ea81c commit 5733437
Show file tree
Hide file tree
Showing 405 changed files with 37,363 additions and 118 deletions.
3 changes: 0 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,3 @@
*.ttf binary
*.slf binary
*.borders binary

# Files for git lfs
FBAudienceNetwork filter=lfs diff=lfs merge=lfs -text
Binary file modified iphone/Maps/3party/Bolts.framework/Bolts
Binary file not shown.
Binary file modified iphone/Maps/3party/Bolts.framework/Info.plist
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file modified iphone/Maps/3party/FBSDKCoreKit.framework/FBSDKCoreKit
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,11 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
*/

/**
Sets a device token to register the current application installation for push notifications.
Sets and sends device token to register the current application for push notifications.
Sets a device token from `NSData` representation that you get from `UIApplicationDelegate.-application:didRegisterForRemoteNotificationsWithDeviceToken:`.
Sets and sends a device token from `NSData` representation that you get from `UIApplicationDelegate.-application:didRegisterForRemoteNotificationsWithDeviceToken:`.
- Parameter deviceToken: Device token data.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@
#import <FBSDKCoreKit/FBSDKDeviceViewControllerBase.h>
#endif

#define FBSDK_VERSION_STRING @"4.19.0"
#define FBSDK_VERSION_STRING @"4.21.0"
#define FBSDK_TARGET_PLATFORM_VERSION @"v2.8"
Binary file modified iphone/Maps/3party/FBSDKCoreKit.framework/Info.plist
Binary file not shown.
Binary file modified iphone/Maps/3party/FBSDKLoginKit.framework/FBSDKLoginKit
Binary file not shown.
Binary file modified iphone/Maps/3party/FBSDKLoginKit.framework/Info.plist
Binary file not shown.
Binary file modified iphone/Maps/3party/FBSDKShareKit.framework/FBSDKShareKit
Binary file not shown.
Binary file modified iphone/Maps/3party/FBSDKShareKit.framework/Info.plist
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// FacebookBannerCustomEvent.h
// MoPub
//
// Copyright (c) 2014 MoPub. All rights reserved.
//

#if __has_include(<MoPub/MoPub.h>)
#import <MoPub/MoPub.h>
#else
#import "MPBannerCustomEvent.h"
#endif

/*
* Please reference the Supported Mediation Partner page at http://bit.ly/2mqsuFH for the
* latest version and ad format certifications.
*/
@interface FacebookBannerCustomEvent : MPBannerCustomEvent

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
//
// FacebookBannerCustomEvent.m
// MoPub
//
// Copyright (c) 2014 MoPub. All rights reserved.
//

#import <FBAudienceNetwork/FBAudienceNetwork.h>
#import "FacebookBannerCustomEvent.h"

#import "MPInstanceProvider.h"
#import "MPLogging.h"

@interface MPInstanceProvider (FacebookBanners)

- (FBAdView *)buildFBAdViewWithPlacementID:(NSString *)placementID
size:(FBAdSize)size
rootViewController:(UIViewController *)controller
delegate:(id<FBAdViewDelegate>)delegate;
@end

@implementation MPInstanceProvider (FacebookBanners)

- (FBAdView *)buildFBAdViewWithPlacementID:(NSString *)placementID
size:(FBAdSize)size
rootViewController:(UIViewController *)controller
delegate:(id<FBAdViewDelegate>)delegate
{
FBAdView *adView = [[FBAdView alloc] initWithPlacementID:placementID
adSize:size
rootViewController:controller];
adView.delegate = delegate;
[adView disableAutoRefresh];
return adView;
}

@end

@interface FacebookBannerCustomEvent () <FBAdViewDelegate>

@property (nonatomic, strong) FBAdView *fbAdView;

@end

@implementation FacebookBannerCustomEvent

- (BOOL)enableAutomaticImpressionAndClickTracking
{
return NO;
}

- (void)requestAdWithSize:(CGSize)size customEventInfo:(NSDictionary *)info
{
/**
* Facebook Banner ads can accept arbitrary widths for given heights of 50 and 90. We convert these sizes
* to Facebook's constants and set the fbAdView's size to the intended size ("size" passed to this method).
*/
FBAdSize fbAdSize;
if (CGSizeEqualToSize(size, kFBAdSize320x50.size)) {
fbAdSize = kFBAdSize320x50;
} else if (size.height == kFBAdSizeHeight250Rectangle.size.height) {
fbAdSize = kFBAdSizeHeight250Rectangle;
} else if (size.height == kFBAdSizeHeight90Banner.size.height) {
fbAdSize = kFBAdSizeHeight90Banner;
} else if (size.height == kFBAdSizeHeight50Banner.size.height) {
fbAdSize = kFBAdSizeHeight50Banner;
} else {
MPLogError(@"Invalid size for Facebook banner ad");
[self.delegate bannerCustomEvent:self didFailToLoadAdWithError:nil];
return;
}

if (![info objectForKey:@"placement_id"]) {
MPLogError(@"Placement ID is required for Facebook banner ad");
[self.delegate bannerCustomEvent:self didFailToLoadAdWithError:nil];
return;
}

MPLogInfo(@"Requesting Facebook banner ad");
self.fbAdView =
[[MPInstanceProvider sharedProvider] buildFBAdViewWithPlacementID:[info objectForKey:@"placement_id"]
size:fbAdSize
rootViewController:[self.delegate viewControllerForPresentingModalView]
delegate:self];

if (!self.fbAdView) {
[self.delegate bannerCustomEvent:self didFailToLoadAdWithError:nil];
return;
}

/*
* Manually resize the frame of the FBAdView due to a bug in the Facebook SDK that sets the ad's width
* to the width of the device instead of the width of the container it's placed in.
* (Confirmed in email with a FB Solutions Engineer)
*/
CGRect fbAdFrame = self.fbAdView.frame;
fbAdFrame.size = size;
self.fbAdView.frame = fbAdFrame;

[self.fbAdView loadAd];
}

- (void)dealloc
{
_fbAdView.delegate = nil;
}

#pragma mark FBAdViewDelegate methods

- (void)adView:(FBAdView *)adView didFailWithError:(NSError *)error;
{
MPLogInfo(@"Facebook banner failed to load with error: %@", error.description);
[self.delegate bannerCustomEvent:self didFailToLoadAdWithError:error];
}

- (void)adViewDidLoad:(FBAdView *)adView;
{
MPLogInfo(@"Facebook banner ad did load");
[self.delegate trackImpression];
[self.delegate bannerCustomEvent:self didLoadAd:adView];
}

- (void)adViewDidClick:(FBAdView *)adView
{
MPLogInfo(@"Facebook banner ad was clicked");
[self.delegate trackClick];
[self.delegate bannerCustomEventWillBeginAction:self];
}

- (void)adViewDidFinishHandlingClick:(FBAdView *)adView
{
MPLogInfo(@"Facebook banner ad did finish handling click");
[self.delegate bannerCustomEventDidFinishAction:self];
}

- (UIViewController *)viewControllerForPresentingModalView
{
return [self.delegate viewControllerForPresentingModalView];
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// FacebookInterstitialCustomEvent.h
// MoPub
//
// Copyright (c) 2014 MoPub. All rights reserved.
//

#if __has_include(<MoPub/MoPub.h>)
#import <MoPub/MoPub.h>
#else
#import "MPInterstitialCustomEvent.h"
#endif

/*
* Please reference the Supported Mediation Partner page at http://bit.ly/2mqsuFH for the
* latest version and ad format certifications.
*/
@interface FacebookInterstitialCustomEvent : MPInterstitialCustomEvent

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
//
// FacebookInterstitialCustomEvent.m
// MoPub
//
// Copyright (c) 2014 MoPub. All rights reserved.
//

#import <FBAudienceNetwork/FBAudienceNetwork.h>
#import "FacebookInterstitialCustomEvent.h"

#import "MPInstanceProvider.h"
#import "MPLogging.h"

@interface MPInstanceProvider (FacebookInterstitials)

- (FBInterstitialAd *)buildFBInterstitialAdWithPlacementID:(NSString *)placementID
delegate:(id<FBInterstitialAdDelegate>)delegate;

@end

@implementation MPInstanceProvider (FacebookInterstitials)

- (FBInterstitialAd *)buildFBInterstitialAdWithPlacementID:(NSString *)placementID
delegate:(id<FBInterstitialAdDelegate>)delegate
{
FBInterstitialAd *interstitialAd = [[FBInterstitialAd alloc] initWithPlacementID:placementID];
interstitialAd.delegate = delegate;
return interstitialAd;
}

@end

@interface FacebookInterstitialCustomEvent () <FBInterstitialAdDelegate>

@property (nonatomic, strong) FBInterstitialAd *fbInterstitialAd;

@end

@implementation FacebookInterstitialCustomEvent

- (void)requestInterstitialWithCustomEventInfo:(NSDictionary *)info
{
if (![info objectForKey:@"placement_id"]) {
MPLogError(@"Placement ID is required for Facebook interstitial ad");
[self.delegate interstitialCustomEvent:self didFailToLoadAdWithError:nil];
return;
}

MPLogInfo(@"Requesting Facebook interstitial ad");

self.fbInterstitialAd =
[[MPInstanceProvider sharedProvider] buildFBInterstitialAdWithPlacementID:[info objectForKey:@"placement_id"]
delegate:self];

[self.fbInterstitialAd loadAd];
}

- (void)showInterstitialFromRootViewController:(UIViewController *)controller {
if (!self.fbInterstitialAd || !self.fbInterstitialAd.isAdValid) {
MPLogError(@"Facebook interstitial ad was not loaded");
[self.delegate interstitialCustomEventDidExpire:self];
} else {
MPLogInfo(@"Facebook interstitial ad will be presented");
[self.delegate interstitialCustomEventWillAppear:self];
[self.fbInterstitialAd showAdFromRootViewController:controller];
MPLogInfo(@"Facebook interstitial ad was presented");
[self.delegate interstitialCustomEventDidAppear:self];
}
}

- (void)dealloc
{
_fbInterstitialAd.delegate = nil;
}

#pragma mark FBInterstitialAdDelegate methods

- (void)interstitialAdDidLoad:(FBInterstitialAd *)interstitialAd
{
MPLogInfo(@"Facebook intersitital ad was loaded. Can present now");
[self.delegate interstitialCustomEvent:self didLoadAd:interstitialAd];
}

- (void)interstitialAd:(FBInterstitialAd *)interstitialAd didFailWithError:(NSError *)error
{
MPLogInfo(@"Facebook intersitital ad failed to load with error: %@", error.description);
[self.delegate interstitialCustomEvent:self didFailToLoadAdWithError:nil];
}

- (void)interstitialAdDidClick:(FBInterstitialAd *)interstitialAd
{
MPLogInfo(@"Facebook interstitial ad was clicked");
[self.delegate interstitialCustomEventDidReceiveTapEvent:self];
}

- (void)interstitialAdDidClose:(FBInterstitialAd *)interstitialAd
{
MPLogInfo(@"Facebook interstitial ad was closed");
[self.delegate interstitialCustomEventDidDisappear:self];
}

- (void)interstitialAdWillClose:(FBInterstitialAd *)interstitialAd
{
MPLogInfo(@"Facebook interstitial ad will close");
[self.delegate interstitialCustomEventWillDisappear:self];
}

@end
Loading

0 comments on commit 5733437

Please sign in to comment.