Skip to content

Commit

Permalink
update samples.
Browse files Browse the repository at this point in the history
  • Loading branch information
AdGeneration committed Jan 29, 2019
1 parent 669235e commit 2e1bad9
Show file tree
Hide file tree
Showing 18 changed files with 392 additions and 144 deletions.
34 changes: 34 additions & 0 deletions Samples/ADGSample/ADGSample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
B0EE73751F74F87B00D9A52E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B0EE73731F74F87B00D9A52E /* Main.storyboard */; };
B0EE73771F74F87B00D9A52E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B0EE73761F74F87B00D9A52E /* Assets.xcassets */; };
B0EE737A1F74F87B00D9A52E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B0EE73781F74F87B00D9A52E /* LaunchScreen.storyboard */; };
C57EDB7121142133003B9B90 /* FBNativeBannerAdCustomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C57EDB7021142133003B9B90 /* FBNativeBannerAdCustomView.swift */; };
C57EDB7321142157003B9B90 /* FBNativeBannerAdCustomView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C57EDB7221142157003B9B90 /* FBNativeBannerAdCustomView.xib */; };
C57EDB772114433B003B9B90 /* FBNativeBannerAdCustomView.m in Sources */ = {isa = PBXBuildFile; fileRef = C57EDB762114433B003B9B90 /* FBNativeBannerAdCustomView.m */; };
C57EDB7B211444B2003B9B90 /* FBNativeBannerAdCustomView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C57EDB7A211444B2003B9B90 /* FBNativeBannerAdCustomView.xib */; };
DC6D580A034949ADA8A484EB /* Pods_BannerAdsSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F9329FD9372BA0F16C1A285 /* Pods_BannerAdsSwift.framework */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -132,6 +136,11 @@
B0EE73761F74F87B00D9A52E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
B0EE73791F74F87B00D9A52E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
B0EE737B1F74F87B00D9A52E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
C57EDB7021142133003B9B90 /* FBNativeBannerAdCustomView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FBNativeBannerAdCustomView.swift; sourceTree = "<group>"; };
C57EDB7221142157003B9B90 /* FBNativeBannerAdCustomView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FBNativeBannerAdCustomView.xib; sourceTree = "<group>"; };
C57EDB752114433B003B9B90 /* FBNativeBannerAdCustomView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBNativeBannerAdCustomView.h; sourceTree = "<group>"; };
C57EDB762114433B003B9B90 /* FBNativeBannerAdCustomView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBNativeBannerAdCustomView.m; sourceTree = "<group>"; };
C57EDB7A211444B2003B9B90 /* FBNativeBannerAdCustomView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FBNativeBannerAdCustomView.xib; sourceTree = "<group>"; };
CA10F631DC7C183F86700222 /* Pods-NativeAdsSwift.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NativeAdsSwift.debug.xcconfig"; path = "Pods/Target Support Files/Pods-NativeAdsSwift/Pods-NativeAdsSwift.debug.xcconfig"; sourceTree = "<group>"; };
D2520EFDD352131682380FD2 /* Pods-InterstitialAdsObjC.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InterstitialAdsObjC.release.xcconfig"; path = "Pods/Target Support Files/Pods-InterstitialAdsObjC/Pods-InterstitialAdsObjC.release.xcconfig"; sourceTree = "<group>"; };
D673650960CBE6AF4109A2D5 /* Pods_ADGSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ADGSample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -301,6 +310,7 @@
children = (
B01556C61F752D970078E406 /* ADGNativeAdView */,
B03C6DC81F78A32400F8F307 /* FBNativeAdCustomView */,
C57EDB7421144310003B9B90 /* FBNativeBannerAdCustomView */,
B02FCCCB1F73CBF200D7C310 /* AppDelegate.h */,
B02FCCCC1F73CBF200D7C310 /* AppDelegate.m */,
B02FCCCE1F73CBF200D7C310 /* NativeAdsObjCViewController.h */,
Expand All @@ -319,6 +329,7 @@
children = (
B01556D61F757AEC0078E406 /* ADGNativeAdView */,
B03C6DCE1F78CBC300F8F307 /* FBNativeAdCustomView */,
C57EDB6F211420AC003B9B90 /* FBNativeBannerAdCustomView */,
B02FCCE51F73CC0600D7C310 /* AppDelegate.swift */,
B02FCCE71F73CC0600D7C310 /* NativeAdsSwiftViewController.swift */,
B02FCCE91F73CC0600D7C310 /* Main.storyboard */,
Expand Down Expand Up @@ -372,6 +383,25 @@
name = "Supporting Files";
sourceTree = "<group>";
};
C57EDB6F211420AC003B9B90 /* FBNativeBannerAdCustomView */ = {
isa = PBXGroup;
children = (
C57EDB7221142157003B9B90 /* FBNativeBannerAdCustomView.xib */,
C57EDB7021142133003B9B90 /* FBNativeBannerAdCustomView.swift */,
);
path = FBNativeBannerAdCustomView;
sourceTree = "<group>";
};
C57EDB7421144310003B9B90 /* FBNativeBannerAdCustomView */ = {
isa = PBXGroup;
children = (
C57EDB7A211444B2003B9B90 /* FBNativeBannerAdCustomView.xib */,
C57EDB752114433B003B9B90 /* FBNativeBannerAdCustomView.h */,
C57EDB762114433B003B9B90 /* FBNativeBannerAdCustomView.m */,
);
path = FBNativeBannerAdCustomView;
sourceTree = "<group>";
};
D4F3057F70A2B8F55D3DC898 /* Pods */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -613,6 +643,7 @@
B02FCCD81F73CBF200D7C310 /* LaunchScreen.storyboard in Resources */,
B02FCCD51F73CBF200D7C310 /* Assets.xcassets in Resources */,
B03C6DCD1F78A35100F8F307 /* FBNativeAdCustomView.xib in Resources */,
C57EDB7B211444B2003B9B90 /* FBNativeBannerAdCustomView.xib in Resources */,
B02FCCD31F73CBF200D7C310 /* Main.storyboard in Resources */,
B01556D11F752ECF0078E406 /* ADGNativeAdView.xib in Resources */,
);
Expand All @@ -625,6 +656,7 @@
B02FCCF01F73CC0600D7C310 /* LaunchScreen.storyboard in Resources */,
B02FCCED1F73CC0600D7C310 /* Assets.xcassets in Resources */,
B02FCCEB1F73CC0600D7C310 /* Main.storyboard in Resources */,
C57EDB7321142157003B9B90 /* FBNativeBannerAdCustomView.xib in Resources */,
B01556DA1F757B380078E406 /* ADGNativeAdView.xib in Resources */,
B03C6DD21F78CBFD00F8F307 /* FBNativeAdCustomView.xib in Resources */,
);
Expand Down Expand Up @@ -953,6 +985,7 @@
B02FCCCD1F73CBF200D7C310 /* AppDelegate.m in Sources */,
B03C6DCB1F78A34600F8F307 /* FBNativeAdCustomView.m in Sources */,
B01556CF1F752EC20078E406 /* ADGNativeAdView.m in Sources */,
C57EDB772114433B003B9B90 /* FBNativeBannerAdCustomView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -962,6 +995,7 @@
files = (
B01556D81F757B0D0078E406 /* ADGNativeAdView.swift in Sources */,
B02FCCE81F73CC0600D7C310 /* NativeAdsSwiftViewController.swift in Sources */,
C57EDB7121142133003B9B90 /* FBNativeBannerAdCustomView.swift in Sources */,
B02FCCE61F73CC0600D7C310 /* AppDelegate.swift in Sources */,
B03C6DD01F78CBDF00F8F307 /* FBNativeAdCustomView.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
23 changes: 7 additions & 16 deletions Samples/ADGSample/BannerAdsObjC/BannerAdsObjCViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,17 @@ - (void)viewDidLoad {
[super viewDidLoad];

/*
locationid: 管理画面から払い出された広告枠ID
adtype: 枠サイズ
locationID: 管理画面から払い出された広告枠ID
adType: 枠サイズ
kADG_AdType_Sp:320x50, kADG_AdType_Large:320x100,
kADG_AdType_Rect:300x250, kADG_AdType_Tablet:728x90,
kADG_AdType_Free:自由設定
originx: 広告枠設置起点のx座標(optional)
originy: 広告枠設置起点のy座標(optional)
w: 広告枠横幅(kADG_AdType_Freeのとき有効 optional)
h: 広告枠高さ(kADG_AdType_Freeのとき有効 optional)
rootViewController: 広告を配置するViewController
*/
NSDictionary *adgparam = @{
@"locationid" : @"48547",
@"adtype" : @(kADG_AdType_Sp),
// @"originx" : @0,
// @"originy" : @0,
// @"w" : @0,
// @"h" : @0
};
self.adg = [[ADGManagerViewController alloc] initWithAdParams:adgparam
adView:self.adView];
self.adg = [[ADGManagerViewController alloc] initWithLocationID:@"48547"
adType:kADG_AdType_Sp
rootViewController:self];
[self.adg addAdContainerView:self.adView]; // 広告Viewを配置するViewを指定
self.adg.delegate = self;
[self.adg loadRequest]; // 広告リクエスト
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,15 @@ class BannerAdsSwiftViewController: UIViewController {
super.viewDidLoad()

/*
locationid: 管理画面から払い出された広告枠ID
adtype: 枠サイズ
locationID: 管理画面から払い出された広告枠ID
adType: 枠サイズ
adType_Sp:320x50, adType_Large:320x100,
adType_Rect:300x250, adType_Tablet:728x90,
adType_Free:自由設定
originx: 広告枠設置起点のx座標(optional)
originy: 広告枠設置起点のy座標(optional)
w: 広告枠横幅(kADG_AdType_Freeのとき有効 optional)
h: 広告枠高さ(kADG_AdType_Freeのとき有効 optional)
rootViewController: 広告を配置するViewController
*/
let params: [String: Any] = [
"locationid": "48547",
"adtype": ADGAdType.adType_Sp.rawValue,
// "originx": 0,
// "originy": 0,
// "w": 0,
// "h": 0,
]
adg = ADGManagerViewController(adParams: params, adView: self.adView)
adg = ADGManagerViewController(locationID: "48547", adType: .adType_Sp, rootViewController: self)
adg?.addAdContainerView(self.adView) // 広告Viewを配置するViewを指定
adg?.delegate = self
adg?.loadRequest() // 広告リクエスト
}
Expand All @@ -59,11 +49,11 @@ class BannerAdsSwiftViewController: UIViewController {

extension BannerAdsSwiftViewController: ADGManagerViewControllerDelegate {

func adgManagerViewControllerReceiveAd(_ adgManagerViewController: ADGManagerViewController!) {
func adgManagerViewControllerReceiveAd(_ adgManagerViewController: ADGManagerViewController) {
print("Received an ad.")
}

func adgManagerViewControllerFailed(toReceiveAd adgManagerViewController: ADGManagerViewController!, code: kADGErrorCode) {
func adgManagerViewControllerFailed(toReceiveAd adgManagerViewController: ADGManagerViewController, code: kADGErrorCode) {
print("Failed to receive an ad.")
// エラー時のリトライは特段の理由がない限り必ず記述するようにしてください。
switch code {
Expand All @@ -76,7 +66,7 @@ extension BannerAdsSwiftViewController: ADGManagerViewControllerDelegate {
}
}

func adgManagerViewControllerDidTapAd(_ adgManagerViewController: ADGManagerViewController!) {
func adgManagerViewControllerDidTapAd(_ adgManagerViewController: ADGManagerViewController) {
print("Did tap an ad.")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ class InterstitialAdsSwiftViewController: UIViewController {

extension InterstitialAdsSwiftViewController: ADGInterstitialDelegate {

func adgManagerViewControllerReceiveAd(_ adgManagerViewController: ADGManagerViewController!) {
func adgManagerViewControllerReceiveAd(_ adgManagerViewController: ADGManagerViewController) {
print("Received an ad.")
}

func adgManagerViewControllerFailed(toReceiveAd adgManagerViewController: ADGManagerViewController!, code: kADGErrorCode) {
func adgManagerViewControllerFailed(toReceiveAd adgManagerViewController: ADGManagerViewController, code: kADGErrorCode) {
print("Failed to receive an ad.")
// エラー時のリトライは特段の理由がない限り必ず記述するようにしてください。
switch code {
Expand All @@ -62,7 +62,7 @@ extension InterstitialAdsSwiftViewController: ADGInterstitialDelegate {
}
}

func adgManagerViewControllerDidTapAd(_ adgManagerViewController: ADGManagerViewController!) {
func adgManagerViewControllerDidTapAd(_ adgManagerViewController: ADGManagerViewController) {
print("Did tap an ad.")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@interface FBNativeAdCustomView()

@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet FBAdIconView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UIView *mediaViewContainer;
@property (weak, nonatomic) IBOutlet UILabel *bodyLabel;
Expand Down Expand Up @@ -47,48 +47,37 @@ - (void)apply:(FBNativeAd *)nativeAd viewController:(UIViewController *)viewCont
return;
}

// アイコン
if (nativeAd.icon) {
NSData *data = [NSData dataWithContentsOfURL:nativeAd.icon.url];
self.iconImageView.image = [UIImage imageWithData:data];
}

// タイトル
self.titleLabel.text = nativeAd.title;
self.titleLabel.text = nativeAd.headline;

// FBMediaView
FBMediaView *mediaView = [[FBMediaView alloc] initWithFrame:CGRectMake(0, 0, self.mediaViewContainer.frame.size.width, self.mediaViewContainer.frame.size.height)];
mediaView.nativeAd = nativeAd;
[self.mediaViewContainer addSubview:mediaView];

// FBMediaViewを使用せず静止画のみ使用する場合
// UIImageView *coverImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.mediaViewContainer.frame.size.width, self.mediaViewContainer.frame.size.height)];
// coverImageView.clipsToBounds = YES;
// NSData *coverImageData = [NSData dataWithContentsOfURL:nativeAd.coverImage.url];
// UIImage *coverImage = [UIImage imageWithData:coverImageData];
// coverImageView.image = coverImage;
// [self.mediaViewContainer addSubview:coverImageView];


// AdChoices(AudienceNetworkの広告オプトアウトへの導線です)
FBAdChoicesView *adChoices = [[FBAdChoicesView alloc] initWithNativeAd:nativeAd expandable:YES];
adChoices.backgroundShown = NO;
[self.mediaViewContainer addSubview:adChoices];
[adChoices updateFrameFromSuperview:UIRectCornerTopRight];

// 本文
self.bodyLabel.text = nativeAd.body;
self.bodyLabel.text = nativeAd.bodyText;

// socialContext
self.socialLabel.text = nativeAd.socialContext;

// CTA
self.ctaLabel.text = nativeAd.callToAction;



// クリック領域
NSArray *clickableViews = @[self.titleLabel, self.mediaViewContainer, self.socialLabel, self.ctaLabel];
[nativeAd registerViewForInteraction:self
withViewController:viewController
withClickableViews:clickableViews];
mediaView:mediaView
iconView:self.iconImageView
viewController:viewController
clickableViews:clickableViews];
}

@end
Loading

0 comments on commit 2e1bad9

Please sign in to comment.