Skip to content

Commit

Permalink
Updated sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
AdGeneration committed Apr 2, 2024
1 parent 852734f commit 3434cdc
Show file tree
Hide file tree
Showing 24 changed files with 4,813 additions and 991 deletions.
252 changes: 62 additions & 190 deletions Samples/ADGSample/ADGSample.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

129 changes: 125 additions & 4 deletions Samples/ADGSample/BannerAdsObjC/BannerAdsObjCViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,27 @@

#import "BannerAdsObjCViewController.h"
#import <ADG/ADGManagerViewController.h>
#import <ADG/ADGSettings.h>
#import <CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <AdSupport/AdSupport.h>
#import <AppTrackingTransparency/ATTrackingManager.h>

@interface BannerAdsObjCViewController () <ADGManagerViewControllerDelegate>

#define LOCATION_ID @"48547"

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UIButton *attButon;
@property (weak, nonatomic) IBOutlet UILabel *attStatusLabel;
@property (weak, nonatomic) IBOutlet UIView *adView;
@property (nonatomic) ADGManagerViewController *adg;

@end

@implementation BannerAdsObjCViewController

- (void)viewDidLoad {
[super viewDidLoad];

- (void)loadAd {
/*
locationID: 管理画面から払い出された広告枠ID
adType: 枠サイズ
Expand All @@ -28,25 +36,138 @@ - (void)viewDidLoad {
kADG_AdType_Free:自由設定
rootViewController: 広告を配置するViewController
*/
self.adg = [[ADGManagerViewController alloc] initWithLocationID:@"48547"
self.adg = [[ADGManagerViewController alloc] initWithLocationID:LOCATION_ID
adType:kADG_AdType_Sp
rootViewController:self];
// test mode 設定
//[self.adg setEnableTestMode:YES]
// geolocation 設定
//[ADGSettings setGeolocationEnabled:YES]
// in app browser 設定
//[ADGSettings setEnableInAppBrowser:NO];
// child directed であると指定
//[ADGSettings setChildDirectedEnabled:YES];
// child directed でないと指定
//[ADGSettings setChildDirectedEnabled:NO];
// hyper id 設定
//[ADGSettings setHyperIdEnabled:NO];
[self.adg addAdContainerView:self.adView]; // 広告Viewを配置するViewを指定
self.adg.delegate = self;
[self.adg loadRequest]; // 広告リクエスト
}

- (void)viewDidLoad {
[super viewDidLoad];
[self loadAd];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated {
self.titleLabel.text = @"Objective-C - 広告枠id: " LOCATION_ID;
[self reloadATTViews];
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
// 画面復帰時のローテーション再開
[self.adg resumeRefresh];
}

- (NSString *)getInfoText {
CTTelephonyNetworkInfo *networkInfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *provider = [networkInfo subscriberCellularProvider];
return [NSString stringWithFormat:
@"ADG SDK: v%@\n"
"isHyperIdEnabled: %@\n"
"isGeolocationEnabled: %@\n"
"enableInAppBrowser: %@\n"
"device name: %@\n"
"system name: %@\n"
"system version: %@\n"
"OS model: %@\n"
"carrier name: %@\n"
"ISO Country code: %@\n"
"PreferredLanguage: %@\n"
"code: %@\n"
"BundleID: %@\n"
"ChildDirected: %@\n"
"IDFA: %@\n"
"IDFV: %@"
, ADG_SDK_VERSION
, ADGSettings.isHyperIdEnabled ? @"YES" : @"NO"
, ADGSettings.isGeolocationEnabled ? @"YES" : @"NO"
, ADGSettings.enableInAppBrowser ? @"YES" : @"NO"
, UIDevice.currentDevice.name
, UIDevice.currentDevice.systemName
, UIDevice.currentDevice.systemVersion
, UIDevice.currentDevice.model
, provider.carrierName
, provider.isoCountryCode
, NSLocale.preferredLanguages.firstObject
, NSLocale.currentLocale.localeIdentifier
, NSBundle.mainBundle.bundleIdentifier
, ADGSettings.isChildDirectedEnabled ? @"YES" : @"NO"
, ASIdentifierManager.sharedManager.advertisingIdentifier.UUIDString
, UIDevice.currentDevice.identifierForVendor.UUIDString
];
}

- (void)reloadATTViews {
self.attStatusLabel.text = @"エラー";
if (@available(iOS 14, *)) {
self.attButon.enabled = YES;
switch (ATTrackingManager.trackingAuthorizationStatus) {
case ATTrackingManagerAuthorizationStatusAuthorized:
self.attStatusLabel.text = @"Authorized";
break;
case ATTrackingManagerAuthorizationStatusRestricted:
self.attStatusLabel.text = @"Restricted";
break;
case ATTrackingManagerAuthorizationStatusDenied:
self.attStatusLabel.text = @"Denied";
break;
case ATTrackingManagerAuthorizationStatusNotDetermined:
self.attStatusLabel.text = @"NotDetermined";
break;
}
} else {
self.attButon.enabled = NO;
self.attStatusLabel.text = @"OS非対応";
}
}

- (IBAction)tappedInfo {
UIAlertController *infoDialog = [UIAlertController alertControllerWithTitle:@"Info" message:[self getInfoText] preferredStyle:UIAlertControllerStyleAlert];
[infoDialog addAction:[UIAlertAction actionWithTitle:@"閉じる" style:UIAlertActionStyleCancel handler:nil]];
[self presentViewController:infoDialog animated:YES completion:nil];
}


- (IBAction)tappedATT {
if (@available(iOS 14, *)) {
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
__weak typeof(self) weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf reloadATTViews];
});
}];
}
}


- (IBAction)tappedAdReload {
[self reloadATTViews];
__weak typeof(self) weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf loadAd];
});
}


- (void)dealloc {
// インスタンスの破棄
self.adg.delegate = nil;
Expand Down
91 changes: 76 additions & 15 deletions Samples/ADGSample/BannerAdsObjC/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_0" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -15,31 +13,94 @@
<objects>
<viewController id="BYZ-38-t0r" customClass="BannerAdsObjCViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5ce-wB-qen">
<rect key="frame" x="27" y="617" width="320" height="50"/>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="p72-hy-Pce">
<rect key="frame" x="0.0" y="463" width="320" height="50"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="320" id="4CB-nl-8fU"/>
<constraint firstAttribute="height" constant="50" id="mao-Pq-PvZ"/>
<constraint firstAttribute="width" constant="320" id="S8a-h5-AZi"/>
<constraint firstAttribute="height" constant="50" id="eZn-Fy-vRw"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vl8-M6-bfa">
<rect key="frame" x="10" y="79.5" width="88" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="SzS-A8-OA2"/>
<constraint firstAttribute="width" constant="88" id="aUr-Vx-Hmr"/>
</constraints>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="filled" title="ATT"/>
<connections>
<action selector="tappedATT" destination="BYZ-38-t0r" eventType="touchUpInside" id="cF0-2e-SFQ"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="NotDetermined" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ES2-aX-6Eu" userLabel="ATT Status">
<rect key="frame" x="108" y="79.5" width="212" height="44"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="c41-B9-Fw9"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tSh-R4-Zlq">
<rect key="frame" x="96" y="523" width="128" height="35"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="filled" title="広告リロード"/>
<connections>
<action selector="tappedAdReload" destination="BYZ-38-t0r" eventType="touchUpInside" id="oEK-cr-dEg"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Sample" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XMO-tw-RCt" userLabel="Title">
<rect key="frame" x="0.0" y="20" width="320" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="d1O-R7-U68"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="pY0-Qd-h2d">
<rect key="frame" x="251" y="24.5" width="53" height="35"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="filled" title="Info"/>
<connections>
<action selector="tappedInfo" destination="BYZ-38-t0r" eventType="touchUpInside" id="5YD-Sk-Oc5"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="5ce-wB-qen" firstAttribute="bottom" secondItem="6Tk-OE-BBY" secondAttribute="bottom" id="1rB-94-PD6"/>
<constraint firstItem="5ce-wB-qen" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="6Dd-nr-LJv"/>
<constraint firstItem="tSh-R4-Zlq" firstAttribute="top" secondItem="p72-hy-Pce" secondAttribute="bottom" constant="10" id="4BP-Ij-mQM"/>
<constraint firstItem="p72-hy-Pce" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="IbS-ab-rz3"/>
<constraint firstItem="ES2-aX-6Eu" firstAttribute="centerY" secondItem="vl8-M6-bfa" secondAttribute="centerY" id="Lcr-Tb-MGg"/>
<constraint firstItem="XMO-tw-RCt" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" id="QLv-p0-8Pi"/>
<constraint firstItem="vl8-M6-bfa" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="10" id="QQR-gM-Zt3"/>
<constraint firstItem="vl8-M6-bfa" firstAttribute="top" secondItem="pY0-Qd-h2d" secondAttribute="bottom" constant="20" id="Uss-3I-JyK"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="XMO-tw-RCt" secondAttribute="trailing" id="ec4-tH-k1X"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="bottom" secondItem="tSh-R4-Zlq" secondAttribute="bottom" constant="10" id="fF4-zq-ICP"/>
<constraint firstItem="pY0-Qd-h2d" firstAttribute="centerY" secondItem="XMO-tw-RCt" secondAttribute="centerY" id="hgf-m7-Lbh"/>
<constraint firstItem="XMO-tw-RCt" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="lE6-nX-ZNp"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="pY0-Qd-h2d" secondAttribute="trailing" constant="16" id="mb8-xB-ExL"/>
<constraint firstItem="ES2-aX-6Eu" firstAttribute="leading" secondItem="vl8-M6-bfa" secondAttribute="trailing" constant="10" id="n2U-Mk-jKu"/>
<constraint firstItem="tSh-R4-Zlq" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="szN-gG-QYl"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="ES2-aX-6Eu" secondAttribute="trailing" id="xCp-vH-WER"/>
</constraints>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
<connections>
<outlet property="adView" destination="5ce-wB-qen" id="ibf-8b-XK4"/>
<outlet property="adView" destination="p72-hy-Pce" id="DfP-dv-fBK"/>
<outlet property="attButon" destination="vl8-M6-bfa" id="QO1-UL-PCT"/>
<outlet property="attStatusLabel" destination="ES2-aX-6Eu" id="yLS-ea-Z0p"/>
<outlet property="titleLabel" destination="XMO-tw-RCt" id="W2I-6y-b3c"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-26" y="-36"/>
</scene>
</scenes>
</document>
Loading

0 comments on commit 3434cdc

Please sign in to comment.