From 541df5cacc669aba5985f56874074bf5af9a0645 Mon Sep 17 00:00:00 2001 From: maninomula Date: Mon, 7 May 2018 19:08:25 -0700 Subject: [PATCH] Updating exapmle iOS SDK and Adapter to show the use of native video. --- example/Adapter/SampleAdapter.m | 2 +- .../Adapter/SampleAdapterMediatedNativeAd.m | 14 +++- example/CustomEvent/SampleMediatedNativeAd.m | 13 +++- .../SampleCustomEventNativeAdSwift.swift | 71 +++++++++---------- .../SampleMediatedNativeAdSwift.swift | 39 ++++++---- .../Base.lproj/ExampleUnifiedNativeAdView.xib | 15 +++- example/MediationExample/ViewController.m | 17 ++++- example/SDK/SampleMediaView.h | 33 +++++++++ example/SDK/SampleMediaView.m | 69 ++++++++++++++++++ example/SDK/SampleNativeAd.h | 8 +++ example/SDK/SampleNativeAd.m | 4 ++ example/SDK/SampleNativeAdLoader.m | 8 ++- example/SDK/SampleNativeAdLoaderDelegate.h | 2 +- example/SampleAdSDK/SampleAdSDK.h | 1 + .../SampleAdSDK.xcodeproj/project.pbxproj | 8 +++ 15 files changed, 242 insertions(+), 62 deletions(-) create mode 100644 example/SDK/SampleMediaView.h create mode 100644 example/SDK/SampleMediaView.m diff --git a/example/Adapter/SampleAdapter.m b/example/Adapter/SampleAdapter.m index 8aae35d50..626f99595 100644 --- a/example/Adapter/SampleAdapter.m +++ b/example/Adapter/SampleAdapter.m @@ -216,7 +216,7 @@ - (GADNativeAdViewAdOptions *)nativeAdViewAdOptions { /// Initializes and returns a sample adapter with a reward based video ad connector. - (instancetype)initWithRewardBasedVideoAdNetworkConnector: - (id)connector { + (id)connector { if (!connector) { return nil; } diff --git a/example/Adapter/SampleAdapterMediatedNativeAd.m b/example/Adapter/SampleAdapterMediatedNativeAd.m index 78cbfb0cc..ca0bfd6cf 100644 --- a/example/Adapter/SampleAdapterMediatedNativeAd.m +++ b/example/Adapter/SampleAdapterMediatedNativeAd.m @@ -47,6 +47,7 @@ @interface SampleAdapterMediatedNativeAd () @property(nonatomic, copy) NSDictionary *extras; @property(nonatomic, strong) GADNativeAdViewAdOptions *nativeAdViewAdOptions; @property(nonatomic, strong) SampleAdInfoView *adInfoView; +@property(nonatomic, strong) SampleMediaView *mediaView; @end @@ -77,7 +78,7 @@ - (instancetype)initWithSampleNativeAd:(SampleNativeAd *)sampleNativeAd NSURL *iconURL = [[NSURL alloc] initFileURLWithPath:_sampleAd.iconURL]; _mappedIcon = [[GADNativeAdImage alloc] initWithURL:iconURL scale:_sampleAd.iconScale]; } - + _mediaView = _sampleAd.mediaView; _nativeAdViewAdOptions = nativeAdViewAdOptions; // The sample SDK provides an AdChoices view (SampleAdInfoView). If your SDK provides image @@ -88,6 +89,14 @@ - (instancetype)initWithSampleNativeAd:(SampleNativeAd *)sampleNativeAd return self; } +- (BOOL)hasVideoContent { + return self.sampleAd.mediaView != nil; +} + +- (UIView *)mediaView { + return _mediaView; +} + - (NSString *)advertiser { return self.sampleAd.advertiser; } @@ -180,6 +189,9 @@ - (void)didRenderInView:(UIView *)view viewController:(UIViewController *)viewController { // This method is called when the native ad view is rendered. Here you would pass the UIView back // to the mediated network's SDK. + + // Playing video using SampleMediaView's playVideo method + [_sampleAd playVideo]; } - (void)didUntrackView:(UIView *)view { diff --git a/example/CustomEvent/SampleMediatedNativeAd.m b/example/CustomEvent/SampleMediatedNativeAd.m index 696b9e11f..44dd9c531 100644 --- a/example/CustomEvent/SampleMediatedNativeAd.m +++ b/example/CustomEvent/SampleMediatedNativeAd.m @@ -45,6 +45,7 @@ @interface SampleMediatedNativeAd () @property(nonatomic, copy) NSDictionary *extras; @property(nonatomic, strong) GADNativeAdViewAdOptions *nativeAdViewAdOptions; @property(nonatomic, strong) SampleAdInfoView *adInfoView; +@property(nonatomic, strong) SampleMediaView *mediaView; @end @@ -75,7 +76,7 @@ - (instancetype)initWithSampleNativeAd:(SampleNativeAd *)sampleNativeAd NSURL *iconURL = [[NSURL alloc] initFileURLWithPath:_sampleAd.iconURL]; _mappedIcon = [[GADNativeAdImage alloc] initWithURL:iconURL scale:_sampleAd.iconScale]; } - + _mediaView = _sampleAd.mediaView; _nativeAdViewAdOptions = nativeAdViewAdOptions; // The sample SDK provides an AdChoices view (SampleAdInfoView). If your SDK provides image @@ -86,6 +87,14 @@ - (instancetype)initWithSampleNativeAd:(SampleNativeAd *)sampleNativeAd return self; } +- (BOOL)hasVideoContent { + return self.sampleAd.mediaView != nil; +} + +- (UIView *)mediaView { + return _mediaView; +} + - (NSString *)advertiser { return self.sampleAd.advertiser; } @@ -146,6 +155,8 @@ - (void)didRenderInView:(UIView *)view viewController:(UIViewController *)viewController { // This method is called when the native ad view is rendered. Here you would pass the UIView back // to the mediated network's SDK. + // Playing video using SampleNativeAd's playVideo method + [_sampleAd playVideo]; } - (void)didUntrackView:(UIView *)view { diff --git a/example/CustomEventSwift/SampleCustomEventNativeAdSwift.swift b/example/CustomEventSwift/SampleCustomEventNativeAdSwift.swift index e0684169c..c959a68c7 100644 --- a/example/CustomEventSwift/SampleCustomEventNativeAdSwift.swift +++ b/example/CustomEventSwift/SampleCustomEventNativeAdSwift.swift @@ -21,19 +21,19 @@ import GoogleMobileAds import SampleAdSDK /// Constant for Sample Ad Network custom event error domain. -private let customEventErrorDomain: String = "com.google.CustomEvent" +private let customEventErrorDomain : String = "com.google.CustomEvent" -class SampleCustomEventNativeAdSwift: NSObject, GADCustomEventNativeAd { +class SampleCustomEventNativeAdSwift : NSObject, GADCustomEventNativeAd { /// Native ad view options. - fileprivate var nativeAdViewAdOptions: GADNativeAdViewAdOptions? - - var delegate: GADCustomEventNativeAdDelegate? - - func request(withParameter serverParameter: String, request: GADCustomEventRequest, - adTypes: [Any], options: [Any], rootViewController: UIViewController) { - + fileprivate var nativeAdViewAdOptions : GADNativeAdViewAdOptions? + var delegate : GADCustomEventNativeAdDelegate? + func request(withParameter serverParameter : String, + request : GADCustomEventRequest, + adTypes : [Any], + options : [Any], + rootViewController : UIViewController) { let requestedUnified: Bool = - adTypes.contains(where: { $0 as? GADAdLoaderAdType == .unifiedNative}) + adTypes.contains(where: { $0 as? GADAdLoaderAdType == .unifiedNative}) // This custom event assumes you have implemented unified native advanced in your app as is done // in this sample. If you have implemented app install and content ad formats in your app, @@ -50,7 +50,6 @@ class SampleCustomEventNativeAdSwift: NSObject, GADCustomEventNativeAd { delegate?.customEventNativeAd(self, didFailToLoadWithError: error) return } - let adLoader = SampleNativeAdLoader() let sampleRequest = SampleNativeAdRequest() @@ -65,56 +64,52 @@ class SampleCustomEventNativeAdSwift: NSObject, GADCustomEventNativeAd { sampleRequest.preferredImageOrientation = NativeAdImageOrientation.any sampleRequest.shouldRequestMultipleImages = false if let options = options as? [GADAdLoaderOptions] { - for loaderOptions: GADAdLoaderOptions in options { + for loaderOptions:GADAdLoaderOptions in options { if let imageOptions = loaderOptions as? GADNativeAdImageAdLoaderOptions { - switch imageOptions.preferredImageOrientation { - case GADNativeAdImageAdLoaderOptionsOrientation.landscape: - sampleRequest.preferredImageOrientation = NativeAdImageOrientation.landscape - case GADNativeAdImageAdLoaderOptionsOrientation.portrait: - sampleRequest.preferredImageOrientation = NativeAdImageOrientation.portrait - default: - sampleRequest.preferredImageOrientation = NativeAdImageOrientation.any + switch imageOptions.preferredImageOrientation{ + case GADNativeAdImageAdLoaderOptionsOrientation.landscape: + sampleRequest.preferredImageOrientation = NativeAdImageOrientation.landscape + case GADNativeAdImageAdLoaderOptionsOrientation.portrait : + sampleRequest.preferredImageOrientation = NativeAdImageOrientation.portrait + default: + sampleRequest.preferredImageOrientation = NativeAdImageOrientation.any } sampleRequest.shouldRequestMultipleImages = imageOptions.shouldRequestMultipleImages - // If the GADNativeAdImageAdLoaderOptions' disableImageLoading property is YES, the - // adapter should send just the URLs for the images. + // If the GADNativeAdImageAdLoaderOptions' disableImageLoading property is + // YES, the adapter should send just the URLs for the images. sampleRequest.shouldDownloadImages = !imageOptions.disableImageLoading } else if let options = loaderOptions as? GADNativeAdViewAdOptions { nativeAdViewAdOptions = options } - } } - - // This custom event uses the server parameter to carry an ad unit ID, which is the most common - // use case. - adLoader.adUnitID = serverParameter - adLoader.delegate = self - adLoader.fetchAd(sampleRequest) + } + // This custom event uses the server parameter to carry an ad unit ID, which is the most common + // use case. + adLoader.adUnitID = serverParameter + adLoader.delegate = self + adLoader.fetchAd(sampleRequest) } // Indicates if the custom event handles user clicks. Return YES if the custom event should handle // user clicks. - func handlesUserClicks() -> Bool { + func handlesUserClicks() -> Bool{ return true } - func handlesUserImpressions() -> Bool { return false } } -extension SampleCustomEventNativeAdSwift: SampleNativeAdLoaderDelegate { - - func adLoader(_ adLoader: SampleNativeAdLoader, didReceive nativeAd: SampleNativeAd) { +extension SampleCustomEventNativeAdSwift : SampleNativeAdLoaderDelegate { + func adLoader(_ adLoader : SampleNativeAdLoader, didReceive nativeAd : SampleNativeAd){ let mediatedAd = SampleMediatedUnifiedNativeAdSwift( - sampleNativeAd:nativeAd,nativeAdViewAdOptions: nativeAdViewAdOptions) - delegate?.customEventNativeAd(self, didReceive: mediatedAd) + sampleNativeAd : nativeAd, nativeAdViewAdOptions : nativeAdViewAdOptions) + delegate?.customEventNativeAd(self, didReceive : mediatedAd) } - func adLoader(_ adLoader: SampleNativeAdLoader, didFailToLoadAdWith errorCode: SampleErrorCode) { - let error = NSError(domain: customEventErrorDomain, code: errorCode.rawValue, userInfo: nil) + func adLoader(_ adLoader : SampleNativeAdLoader, didFailToLoadAdWith errorCode : SampleErrorCode) { + let error = NSError(domain : customEventErrorDomain, code : errorCode.rawValue, userInfo : nil) delegate?.customEventNativeAd(self, didFailToLoadWithError: error) } - } diff --git a/example/CustomEventSwift/SampleMediatedNativeAdSwift.swift b/example/CustomEventSwift/SampleMediatedNativeAdSwift.swift index 4a08e096a..06eaff17f 100644 --- a/example/CustomEventSwift/SampleMediatedNativeAdSwift.swift +++ b/example/CustomEventSwift/SampleMediatedNativeAdSwift.swift @@ -25,7 +25,7 @@ import SampleAdSDK /// by a mediated network don't always line up with the ones expected by the Google /// Mobile Ads SDK (one might have "title" while the other expects "headline," for /// example). It's the job of this "mapper" class to smooth out those wrinkles. -class SampleMediatedUnifiedNativeAdSwift: NSObject { +class SampleMediatedUnifiedNativeAdSwift : NSObject { // You may notice that this class and the Mediation Adapter's // SampleAdapterMediatedNativeAd class look an awful lot alike. That's not // by accident. They're the same class, with the same methods and properties, @@ -43,41 +43,39 @@ class SampleMediatedUnifiedNativeAdSwift: NSObject { // share code between them), they each get their own copies of this class, // with slightly different names. - var sampleAd: SampleNativeAd + var sampleAd : SampleNativeAd var mappedImages = [GADNativeAdImage]() var mappedIcon: GADNativeAdImage? - var extras = [String: Any]() + var extras = [String:Any]() var nativeAdViewAdOptions: GADNativeAdViewAdOptions? let adInfoView = SampleAdInfoView() - - init(sampleNativeAd: SampleNativeAd, nativeAdViewAdOptions: GADNativeAdViewAdOptions?) { - + var sampleMediaView : SampleMediaView? + init(sampleNativeAd : SampleNativeAd, nativeAdViewAdOptions : GADNativeAdViewAdOptions?) { sampleAd = sampleNativeAd super.init() - extras = [SampleCustomEventConstantsSwift.awesomenessKey: sampleAd.degreeOfAwesomeness ?? ""] if let image = sampleAd.image { - mappedImages = [GADNativeAdImage(image: image)] + mappedImages = [GADNativeAdImage(image : image)] } else { - let imageUrl = URL(fileURLWithPath: sampleAd.imageURL) - mappedImages = [GADNativeAdImage(url: imageUrl, scale: sampleAd.imageScale)] + let imageUrl = URL(fileURLWithPath : sampleAd.imageURL) + mappedImages = [GADNativeAdImage(url : imageUrl, scale : sampleAd.imageScale)] } if let icon = sampleAd.icon { - mappedIcon = GADNativeAdImage(image: icon) + mappedIcon = GADNativeAdImage(image : icon) } else { - let iconURL = URL(fileURLWithPath: sampleNativeAd.iconURL) - mappedIcon = GADNativeAdImage(url: iconURL, scale: sampleAd.iconScale) + let iconURL = URL(fileURLWithPath : sampleNativeAd.iconURL) + mappedIcon = GADNativeAdImage(url : iconURL, scale : sampleAd.iconScale) } self.nativeAdViewAdOptions = nativeAdViewAdOptions + self.sampleMediaView = self.sampleAd.mediaView } } /// This is a concrete implementation for the GADMediatedUnifiedNativeAd protocol. extension SampleMediatedUnifiedNativeAdSwift : GADMediatedUnifiedNativeAd { - var advertiser : String? { return sampleAd.advertiser } @@ -122,6 +120,14 @@ extension SampleMediatedUnifiedNativeAdSwift : GADMediatedUnifiedNativeAd { return extras } + var mediaView : UIView?{ + return self.sampleMediaView! + } + + var hasVideoContent : Bool { + return self.sampleAd.mediaView != nil + } + func didRecordImpression() { sampleAd.recordImpression() } @@ -134,9 +140,12 @@ extension SampleMediatedUnifiedNativeAdSwift : GADMediatedUnifiedNativeAd { // one. // You can also access the clickable and non-clickable views by asset key if the mediation network // needs this information. - func didRender(in view: UIView, clickableAssetViews: [GADUnifiedNativeAssetIdentifier : UIView], nonclickableAssetViews: [GADUnifiedNativeAssetIdentifier : UIView], viewController: UIViewController) { + func didRender(in view: UIView, clickableAssetViews: [GADUnifiedNativeAssetIdentifier : UIView], + nonclickableAssetViews: [GADUnifiedNativeAssetIdentifier : UIView], + viewController: UIViewController) { // This method is called when the native ad view is rendered. Here you would pass the UIView // back to the mediated network's SDK. + self.sampleAd.mediaView.playMedia() } func didRecordClickOnAsset(withName assetName: GADUnifiedNativeAssetIdentifier, view: UIView, viewController: UIViewController) { diff --git a/example/MediationExample/Base.lproj/ExampleUnifiedNativeAdView.xib b/example/MediationExample/Base.lproj/ExampleUnifiedNativeAdView.xib index 02346c148..f55bf297e 100644 --- a/example/MediationExample/Base.lproj/ExampleUnifiedNativeAdView.xib +++ b/example/MediationExample/Base.lproj/ExampleUnifiedNativeAdView.xib @@ -1,11 +1,11 @@ - + - + @@ -36,6 +36,13 @@ + + + + + + + @@ -82,15 +89,18 @@ + + + @@ -116,6 +126,7 @@ + diff --git a/example/MediationExample/ViewController.m b/example/MediationExample/ViewController.m index 64f474959..618988943 100644 --- a/example/MediationExample/ViewController.m +++ b/example/MediationExample/ViewController.m @@ -171,12 +171,25 @@ - (void)adLoader:(GADAdLoader *)adLoader didReceiveUnifiedNativeAd:(GADUnifiedNa [self replaceNativeAdView:nativeAdView inPlaceholder:placeholder]; + if (nativeAd.videoController.hasVideoContent) { + nativeAdView.imageView.hidden = YES; + nativeAdView.mediaView.contentMode = UIViewContentModeScaleAspectFit; + nativeAdView.mediaView.hidden = NO; + } else { + nativeAdView.imageView.hidden = NO; + nativeAdView.mediaView.hidden = YES; + GADNativeAdImage *image = nativeAd.images.firstObject; + if (image != nil) { + ((UIImageView *)nativeAdView.imageView).image = image.image; + } + } + // Populate the native ad view with the native ad assets. // Some assets are guaranteed to be present in every native ad. ((UILabel *)nativeAdView.headlineView).text = nativeAd.headline; ((UILabel *)nativeAdView.bodyView).text = nativeAd.body; - [((UIButton *)nativeAdView.callToActionView)setTitle:nativeAd.callToAction - forState:UIControlStateNormal]; + [((UIButton *)nativeAdView.callToActionView) setTitle:nativeAd.callToAction + forState:UIControlStateNormal]; GADNativeAdImage *image = nativeAd.images.firstObject; if (image != nil) { diff --git a/example/SDK/SampleMediaView.h b/example/SDK/SampleMediaView.h new file mode 100644 index 000000000..e5d6fc6b9 --- /dev/null +++ b/example/SDK/SampleMediaView.h @@ -0,0 +1,33 @@ +// +// Copyright (C) 2015 Google, Inc. +// +// SampleMediaView.h +// Sample Ad Network SDK +// +// Licenced 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 + +@import UIKit; + +@interface SampleMediaView : UIView + +- (instancetype)initWithFrame:(CGRect)frame; + +- (void)createMediaContent; + +- (void)playMedia; + +@end + diff --git a/example/SDK/SampleMediaView.m b/example/SDK/SampleMediaView.m new file mode 100644 index 000000000..9dd7a9122 --- /dev/null +++ b/example/SDK/SampleMediaView.m @@ -0,0 +1,69 @@ +// +// Copyright (C) 2015 Google, Inc. +// +// SampleMediaView.m +// Sample Ad Network SDK +// +// 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 "SampleMediaView.h" +#import "SampleNativeAd.h" +@import UIKit; + +@interface SampleMediaView () +@property(nonatomic, strong) UILabel* label; +@end +@implementation SampleMediaView + +- (instancetype)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + self.frame = frame; + } + return self; +} + +- (void)createMediaContent { + _label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]; + _label.backgroundColor = [UIColor colorWithRed:0 green:0.8 blue:0 alpha:1]; + _label.text = @"Sample video"; + _label.textAlignment = NSTextAlignmentCenter; + _label.autoresizingMask = + UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewContentModeCenter; + [self addSubview:_label]; + self.clipsToBounds = YES; +} + +- (void)playMedia { + int timer = 10; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(timer / 6 * NSEC_PER_SEC)), + dispatch_get_main_queue(), ^{ + _label.text = @"20% loaded"; + }); + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(timer / 4 * NSEC_PER_SEC)), + dispatch_get_main_queue(), ^{ + _label.text = @"40% loaded"; + }); + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(timer / 3 * NSEC_PER_SEC)), + dispatch_get_main_queue(), ^{ + _label.text = @"60% loaded"; + }); + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(timer / 2 * NSEC_PER_SEC)), + dispatch_get_main_queue(), ^{ + _label.text = @"100% loaded"; + }); +} + +@end diff --git a/example/SDK/SampleNativeAd.h b/example/SDK/SampleNativeAd.h index 5a2235956..618756169 100644 --- a/example/SDK/SampleNativeAd.h +++ b/example/SDK/SampleNativeAd.h @@ -20,6 +20,8 @@ @import Foundation; @import UIKit; +#import "SampleMediaView.h" + @interface SampleNativeAd : NSObject /// The name of an advertiser. @@ -52,6 +54,9 @@ /// The scale of the image file (pixels/pts) that can be downloaded from imageURL. @property(nonatomic, assign) CGFloat imageScale; +/// The main video associated with the ad. +@property(nonatomic, strong) SampleMediaView *mediaView; + /// The price of the app being advertised. @property(nonatomic, copy) NSString *price; @@ -71,4 +76,7 @@ /// Records impressions for the native ad (it just NSLogs them). - (void)recordImpression; +/// Starts playing the video after the view is rendered +- (void)playVideo; + @end diff --git a/example/SDK/SampleNativeAd.m b/example/SDK/SampleNativeAd.m index 54cfd613b..c81443555 100644 --- a/example/SDK/SampleNativeAd.m +++ b/example/SDK/SampleNativeAd.m @@ -32,4 +32,8 @@ - (void)recordImpression { // In a real SDK, some work would be done here to record the impression. } +- (void)playVideo { + [_mediaView playMedia]; +} + @end diff --git a/example/SDK/SampleNativeAdLoader.m b/example/SDK/SampleNativeAdLoader.m index 1c91ab98f..f2d4e770e 100644 --- a/example/SDK/SampleNativeAdLoader.m +++ b/example/SDK/SampleNativeAdLoader.m @@ -19,6 +19,7 @@ #import "SampleNativeAdLoader.h" +#import "SampleMediaView.h" #import "SampleNativeAd.h" @interface SampleNativeAdLoader () @@ -76,12 +77,15 @@ - (SampleNativeAd *)createFakeNativeAdForRequest:(SampleNativeAdRequest *)reques if (randomValue > 50) { // Create a fake ad by an advertiser with generic content. - newAd.body = @"This is a sample ad, so there's no real content. In the event of a real " + newAd.body = + @"This is a sample ad, so there's no real content. In the event of a real " @"ad, though, some persuasive text would appear here."; newAd.callToAction = @"Take Action"; newAd.headline = @"Sample Content!"; newAd.advertiser = @"An advertiser"; newAd.degreeOfAwesomeness = @"Fairly Awesome!"; + newAd.mediaView = [[SampleMediaView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]; + [newAd.mediaView createMediaContent]; } else { // Create a fake ad for an App. newAd.body = @"This app doesn't actually exist."; @@ -91,6 +95,8 @@ - (SampleNativeAd *)createFakeNativeAdForRequest:(SampleNativeAdRequest *)reques newAd.starRating = [[NSDecimalNumber alloc] initWithDouble:4.5]; newAd.store = @"Sample Store"; newAd.degreeOfAwesomeness = @"Quite Awesome!"; + newAd.mediaView = [[SampleMediaView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]; + [newAd.mediaView createMediaContent]; } // If this were a real SDK, it would check some of the other image options in the request. To keep diff --git a/example/SDK/SampleNativeAdLoaderDelegate.h b/example/SDK/SampleNativeAdLoaderDelegate.h index 6600ee4f6..1ddf33166 100644 --- a/example/SDK/SampleNativeAdLoaderDelegate.h +++ b/example/SDK/SampleNativeAdLoaderDelegate.h @@ -24,7 +24,7 @@ @class SampleNativeAdLoader; @class SampleNativeAd; -@protocol SampleNativeAdLoaderDelegate +@protocol SampleNativeAdLoaderDelegate /// Sent when the SampleNativeAdLoader has received a native ad. - (void)adLoader:(SampleNativeAdLoader *)adLoader didReceiveNativeAd:(SampleNativeAd *)nativeAd; diff --git a/example/SampleAdSDK/SampleAdSDK.h b/example/SampleAdSDK/SampleAdSDK.h index ce1b200e4..38cf4c3cf 100644 --- a/example/SampleAdSDK/SampleAdSDK.h +++ b/example/SampleAdSDK/SampleAdSDK.h @@ -39,3 +39,4 @@ FOUNDATION_EXPORT const unsigned char SampleAdSDKVersionString[]; #import #import #import +#import diff --git a/example/SampleAdSDK/SampleAdSDK.xcodeproj/project.pbxproj b/example/SampleAdSDK/SampleAdSDK.xcodeproj/project.pbxproj index b98aa670b..f7db5f8ff 100644 --- a/example/SampleAdSDK/SampleAdSDK.xcodeproj/project.pbxproj +++ b/example/SampleAdSDK/SampleAdSDK.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 4569383F208EBC1C0030CCD1 /* SampleMediaView.h in Headers */ = {isa = PBXBuildFile; fileRef = 4569383D208EBC1C0030CCD1 /* SampleMediaView.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 45693840208EBC1C0030CCD1 /* SampleMediaView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4569383E208EBC1C0030CCD1 /* SampleMediaView.m */; }; AE50D67D1F3BC49C0007AF85 /* SampleAdRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = AE50D64F1F3BC3D20007AF85 /* SampleAdRequest.m */; }; AE50D67E1F3BC49C0007AF85 /* SampleBanner.m in Sources */ = {isa = PBXBuildFile; fileRef = AE50D6511F3BC3D20007AF85 /* SampleBanner.m */; }; AE50D67F1F3BC49C0007AF85 /* SampleInterstitial.m in Sources */ = {isa = PBXBuildFile; fileRef = AE50D6541F3BC3D20007AF85 /* SampleInterstitial.m */; }; @@ -58,6 +60,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 4569383D208EBC1C0030CCD1 /* SampleMediaView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SampleMediaView.h; sourceTree = ""; }; + 4569383E208EBC1C0030CCD1 /* SampleMediaView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SampleMediaView.m; sourceTree = ""; }; AE50D64E1F3BC3D20007AF85 /* SampleAdRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SampleAdRequest.h; sourceTree = ""; }; AE50D64F1F3BC3D20007AF85 /* SampleAdRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SampleAdRequest.m; sourceTree = ""; }; AE50D6501F3BC3D20007AF85 /* SampleBanner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SampleBanner.h; sourceTree = ""; }; @@ -143,6 +147,8 @@ AE50D6681F3BC3D20007AF85 /* SDK */ = { isa = PBXGroup; children = ( + 4569383D208EBC1C0030CCD1 /* SampleMediaView.h */, + 4569383E208EBC1C0030CCD1 /* SampleMediaView.m */, AE50D64E1F3BC3D20007AF85 /* SampleAdRequest.h */, AE50D64F1F3BC3D20007AF85 /* SampleAdRequest.m */, AE50D6501F3BC3D20007AF85 /* SampleBanner.h */, @@ -231,6 +237,7 @@ AE50D68E1F3BC4B30007AF85 /* SampleAdRequest.h in Headers */, AE50D68F1F3BC4B30007AF85 /* SampleBanner.h in Headers */, AE50D6901F3BC4B30007AF85 /* SampleBannerAdDelegate.h in Headers */, + 4569383F208EBC1C0030CCD1 /* SampleMediaView.h in Headers */, AE50D6911F3BC4B30007AF85 /* SampleInterstitial.h in Headers */, AE50D6921F3BC4B30007AF85 /* SampleInterstitialAdDelegate.h in Headers */, AE50D6931F3BC4B30007AF85 /* SampleRewardBasedVideo.h in Headers */, @@ -369,6 +376,7 @@ AE50D6821F3BC49C0007AF85 /* SampleRewardBasedVideoAd.m in Sources */, AE50D6831F3BC49C0007AF85 /* SampleNativeAdLoader.m in Sources */, AE50D6871F3BC49C0007AF85 /* SampleAdInfoView.m in Sources */, + 45693840208EBC1C0030CCD1 /* SampleMediaView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };