Skip to content

Commit

Permalink
Merge branch 'master' of ssh://stash.corp.appnexus.com:7999/mobile-sd…
Browse files Browse the repository at this point in the history
…k/app_mobile-sdk-ios
  • Loading branch information
asharmaa committed Apr 21, 2020
2 parents ec9fb7c + e4e3c6e commit f87666e
Show file tree
Hide file tree
Showing 113 changed files with 8,313 additions and 154 deletions.
10 changes: 9 additions & 1 deletion AppNexusSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "AppNexusSDK"
s.version = "7.2"
s.version = "7.3"
s.platform = :ios, "9.0"

s.summary = "AppNexus iOS Mobile Advertising SDK"
Expand Down Expand Up @@ -43,6 +43,14 @@ DESC
subspec.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '${PODS_ROOT}/AmazonAd/**' }
end

s.subspec 'FacebookCSRAdapter' do |subspec|
subspec.dependency 'AppNexusSDK/AppNexusSDK', "#{s.version}"
subspec.dependency 'FBAudienceNetwork', '5.5.1'
subspec.source_files = "csr/Facebook/*.{h,m}"
subspec.public_header_files = "csr/Facebook/ANFBSettings.h"
subspec.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '${PODS_ROOT}/FBAudienceNetwork/**' }
end

s.subspec 'FacebookAdapter' do |subspec|
subspec.dependency 'AppNexusSDK/AppNexusSDK', "#{s.version}"
subspec.dependency 'FBAudienceNetwork', '5.5.1'
Expand Down
8 changes: 8 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 7.3
### New Feature
+ MS-4266 Added API to support Friendly Obstruction for Open Measurement
+ MS-4223 Added Client Side Rendering for FB mediated Ads.

### Improvements/Bug Fixes
+ MS-4275 Fixed BannerAd OMID session tracker firing

## 7.2
### Improvements/Bug Fixes
+ MS-4200 : Support IAB Europe Transparency & Consent Framework v2.0
Expand Down
94 changes: 94 additions & 0 deletions csr/Facebook/ANAdAdapterCSRNativeBannerFacebook.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/* Copyright 2020 APPNEXUS INC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#import <Foundation/Foundation.h>
#if __has_include(<AppNexusNativeSDK/AppNexusNativeSDK.h>)
#import <AppNexusNativeSDK/AppNexusNativeSDK.h>
#elif __has_include(<AppNexusSDK/AppNexusSDK.h>)
#import <AppNexusSDK/AppNexusSDK.h>
#else
#import "ANNativeCustomAdapter.h"
#import "ANLogging.h"
#import "ANCSRNativeAdResponse.h"
#endif
#import <FBAudienceNetwork/FBAudienceNetwork.h>


NS_ASSUME_NONNULL_BEGIN

@interface ANAdAdapterCSRNativeBannerFacebook : NSObject

/*!
* Should be called when the CSRNativeBannerAd view has been populated with the ad elements and will be displayed.
* Clicks will be handled automatically. If the view is already registered with another ANNativeAdResponse,
* it will be automatically detached from that response before being attached to this response.
*
*/

/*
* @param view The view which is populated with the native ad elements. Must not be nil.
* @param controller The root view controller which contains the view. Must not be nil.
* @param iconView The FBMediaView you created to render the icon.
* @param clickableViews Specifies view subviews which should be clickable, instead of the whole view (the default). May be nil.
* @note The response holds a strong reference to the registered view.
*/

- (void)registerViewForTracking:(nonnull UIView *)view
withRootViewController:(nonnull UIViewController *)controller
iconView:(FBMediaView *_Nonnull)iconView
clickableViews:(nullable NSArray *)clickableViews;


/*!
* @param view The view which is populated with the native ad elements. Must not be nil.
* @param controller The root view controller which contains the view. Must not be nil.
* @param iconImageView The UIImageView you created to render the icon.
* @param clickableViews Specifies view subviews which should be clickable, instead of the whole view (the default). May be nil.
* @note The response holds a strong reference to the registered view.
*/

- (void)registerViewForTracking:(nonnull UIView *)view
withRootViewController:(nonnull UIViewController *)controller
iconImageView:(UIImageView *_Nonnull)iconImageView
clickableViews:(nullable NSArray *)clickableViews;


/*
* @param view The view which is populated with the native ad elements. Must not be nil.
* @param controller The root view controller which contains the view. Must not be nil.
* @param iconView The FBMediaView you created to render the icon.
* @note The response holds a strong reference to the registered view.
*/
- (void)registerViewForTracking:(nonnull UIView *)view
withRootViewController:(nonnull UIViewController *)controller
iconView:(FBMediaView *_Nonnull)iconView;



/*!
* @param view The view which is populated with the native ad elements. Must not be nil.
* @param controller The root view controller which contains the view. Must not be nil.
* @param iconImageView The UIImageView you created to render the icon.
* @note The response holds a strong reference to the registered view.
*/

- (void)registerViewForTracking:(nonnull UIView *)view
withRootViewController:(nonnull UIViewController *)controller
iconImageView:(UIImageView *_Nonnull)iconImageView;


@end

NS_ASSUME_NONNULL_END
192 changes: 192 additions & 0 deletions csr/Facebook/ANAdAdapterCSRNativeBannerFacebook.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
/* Copyright 2020 APPNEXUS INC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#import "ANAdAdapterCSRNativeBannerFacebook.h"
@import FBAudienceNetwork;

@protocol ANCSRNativeAdRequestAdDelegate;



@interface ANAdAdapterCSRNativeBannerFacebook () <FBNativeBannerAdDelegate , ANNativeCustomAdapter>

@property (nonatomic, strong) FBNativeBannerAd *nativeBannerAd;
@property (nonatomic) FBMediaView *fbAdMediaViewIcon;
@property (nonatomic) UIImageView *fbAdImageViewIcon;
@property (nonatomic , weak) ANCSRNativeAdResponse *csrNativeAdResponse;

@end

@implementation ANAdAdapterCSRNativeBannerFacebook

@synthesize requestDelegate;
@synthesize nativeAdDelegate;
@synthesize expired;

- (void) requestAdwithPayload:(nonnull NSString *) payload targetingParameters:(nullable ANTargetingParameters *)targetingParameters{

NSString *placement = [self getPlacementIdFrom:payload];
FBNativeBannerAd *nativeBannerAd = [[FBNativeBannerAd alloc]
initWithPlacementID:placement];

// Set a delegate to get notified when the ad was loaded.
nativeBannerAd.delegate = self;
// Initiate a request to load an ad.
[nativeBannerAd loadAdWithBidPayload:payload];
}

-(NSString *)getPlacementIdFrom:(NSString *)payload{
NSData *data = [payload dataUsingEncoding:NSUTF8StringEncoding];
id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
return json[@"placement_id"];
}

- (void)nativeBannerAdDidLoad:(FBNativeBannerAd *)nativeBannerAd
{
self.nativeBannerAd = nativeBannerAd;
[self showNativeBannerAd];
}

- (void)showNativeBannerAd
{
ANLogDebug(@"Ad did receive FacebookNativeBannerAd.");

ANCSRNativeAdResponse *csrNativeAdResponse = [[ANCSRNativeAdResponse alloc] initWithCustomAdapter:self
networkCode:ANNativeAdNetworkCodeFacebook];
csrNativeAdResponse.title = self.nativeBannerAd.headline;
csrNativeAdResponse.body = self.nativeBannerAd.bodyText;
csrNativeAdResponse.callToAction = self.nativeBannerAd.callToAction;
csrNativeAdResponse.customElements = @{ kANNativeCSRObject : self , kANNativeElementObject : self.nativeBannerAd};
self.csrNativeAdResponse = csrNativeAdResponse;
[self.requestDelegate didLoadNativeAd:self.csrNativeAdResponse];
}

#pragma mark FBNativeBannerAdDelegate

- (void)nativeBannerAdDidDownloadMedia:(FBNativeBannerAd *)nativeBannerAd{
ANLogDebug(@"FacebookNativeBannerAd did download media");
}

- (void)nativeBannerAdWillLogImpression:(FBNativeBannerAd *)nativeBannerAd{
ANLogDebug(@"FacebookNativeBannerAd impression is being captured.");
[self.nativeAdDelegate adDidLogImpression];
}

- (void)nativeBannerAd:(FBNativeBannerAd *)nativeBannerAd didFailWithError:(NSError *)error{
ANLogError(@"Error loading Facebook banner native ad: %@", error);
ANAdResponseCode code = ANAdResponseInternalError;
if (error.code == 1001) {
code = ANAdResponseUnableToFill;
}
[self.requestDelegate didFailToLoadNativeAd:code];
}

- (void)nativeBannerAdDidFinishHandlingClick:(FBNativeBannerAd *)nativeBannerAd{
ANLogDebug(@"FacebookNativeBannerAd did finish handling click");
}

- (void)nativeBannerAdDidClick:(FBNativeBannerAd *)nativeBannerAd
{
ANLogDebug(@"FacebookNativeBannerAd ad was clicked.");
[self.nativeAdDelegate adWasClicked];
}



- (void)registerViewForTracking:(nonnull UIView *)view
withRootViewController:(nonnull UIViewController *)controller
iconView:(FBMediaView *_Nonnull)iconView
clickableViews:(nullable NSArray *)clickableViews{

if(![self hasExpired]){
[self registerNativeAdDelegate];
[self.nativeBannerAd registerViewForInteraction:view
iconView:iconView
viewController:controller
clickableViews:clickableViews];
}
else{
ANLogDebug(@"FacebookNativeBannerAd is expired.");
}
}

- (void)registerViewForTracking:(nonnull UIView *)view
withRootViewController:(nonnull UIViewController *)controller
iconImageView:(UIImageView *_Nonnull)iconImageView
clickableViews:(nullable NSArray *)clickableViews{

if(![self hasExpired] ){
[self registerNativeAdDelegate];
[self.nativeBannerAd registerViewForInteraction:view
iconImageView:iconImageView
viewController:controller
clickableViews:clickableViews];
}
else{
ANLogDebug(@"FacebookNativeBannerAd is expired.");
}
}


- (void)registerViewForTracking:(nonnull UIView *)view
withRootViewController:(nonnull UIViewController *)controller
iconView:(FBMediaView *_Nonnull)iconView{
if(![self hasExpired]){
[self registerNativeAdDelegate];
[self.nativeBannerAd registerViewForInteraction:view
iconView:iconView
viewController:controller];
}
else{
ANLogDebug(@"FacebookNativeBannerAd is expired.");
}
}

- (void)registerViewForTracking:(nonnull UIView *)view
withRootViewController:(nonnull UIViewController *)controller
iconImageView:(UIImageView *_Nonnull)iconImageView{

if(![self hasExpired]){
[self registerNativeAdDelegate];
[self.nativeBannerAd registerViewForInteraction:view
iconImageView:iconImageView
viewController:controller];
}
else{
ANLogDebug(@"FacebookNativeBannerAd is expired.");
}
}

- (void)dealloc {
[self unregisterViewFromTracking];
}

- (BOOL)hasExpired {
return ![self.nativeBannerAd isAdValid];
}

- (void)unregisterViewFromTracking {
[self.nativeBannerAd unregisterView];
self.nativeBannerAd = nil;
self.csrNativeAdResponse = nil;
}

- (void)registerNativeAdDelegate {
if(self.csrNativeAdResponse != nil && self.csrNativeAdResponse.adapter!= nil){
self.csrNativeAdResponse.adapter.nativeAdDelegate = self.csrNativeAdResponse;
[self.csrNativeAdResponse registerOMID];
}
}
@end
27 changes: 27 additions & 0 deletions csr/Facebook/ANFBSettings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* Copyright 2020 APPNEXUS INC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/


#import <Foundation/Foundation.h>
#import <FBAudienceNetwork/FBAudienceNetwork.h>

NS_ASSUME_NONNULL_BEGIN

@interface ANFBSettings : NSObject
+ (NSString *)getBidderToken;
@end


NS_ASSUME_NONNULL_END
24 changes: 24 additions & 0 deletions csr/Facebook/ANFBSettings.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* Copyright 2020 APPNEXUS INC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

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

@implementation ANFBSettings

+ (NSString *)getBidderToken{
return [FBAdSettings bidderToken];
}
@end
1 change: 1 addition & 0 deletions sdk/AppNexusNativeSDK/AppNexusNativeSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ FOUNDATION_EXPORT const unsigned char AppNexusNativeSDKVersionString[];
#import <AppNexusNativeSDK/ANMultiAdRequest.h>


#import <AppNexusNativeSDK/ANCSRNativeAdResponse.h>
Loading

0 comments on commit f87666e

Please sign in to comment.