Ad Manager Configuration
Prerequisites
GFPAdManager
GFPAdManager is the central entry point class of the NAMSDK.
It cannot be instantiated directly — all functionality is provided via class methods.
| Method / Property | Description |
|---|---|
setup(withPublisherCd:target:completionHandler:) | SDK initialization (called once at app launch) |
isSdkInitialized() | Check whether initialization has completed |
adConfiguration() | Access global ad settings (GFPAdConfiguration) |
registerWebView(_:) | Register a WKWebView |
sdkVersion() | Current SDK version string |
Ad Provider Initialization
SDK initialization (once per app lifecycle) must be performed before requesting ads.
If CocoaPods dependencies are added, ads for each ad provider and ad type are automatically initialized.
However, ads from any provider not initialized at this point will not be processed, regardless of the server response.
When calling SDK initialization, you must pass the Publisher Code issued through the Naver Ad Manager platform or your account manager to the setup() call.
The Publisher Code is a required field — omitting it will cause an initialization error. You must always include this value.
Whether initialization succeeded can be checked via the isSdkInitialized value.
Passing a GFPAdConfiguration along with the setup() call lets you specify SDK-wide options all at once.
Key configurable items:
- Request timeout per ad type
- SDK log level
- Ad UI language and dark/light style
- IDFA and location information collection control
- Test mode per ad provider
→ For the full list of options, see GFPAdConfiguration Settings.
Pass an object implementing GFPAdManagerDelegate to the target parameter of the initialization API.
SDK Initialization Examples
- Swift
- Objective-C
import GFPSDK
// PublisherCd 이용, GFPAdConfiguration(광고 설정) 없이 초기화 하는 경우.
GFPAdManager.setup(withPublisherCd: "publisherCd", target:self) { (error : GFPError?) in
print("Setup Error: \(String(describing: error?.description))")
}
// 광고 초기화 성공 여부
GFPAdManager.isSdkInitialized()
// GFPAdConfiguration 설정 포함 초기화 하는 경우.
let configuration = GFPAdConfiguration()
GFPAdManager.setup(withPublisherCd: "publisherCd", target:self, configuration: configuration) { (error : GFPError?) in
print("Setup Error: \(String(describing: error?.description))")
}
@import GFPSDK;
// PublisherCd 이용, GFPAdConfiguration(광고 설정) 없이 초기화 하는 경우.
[GFPAdManager setupWithPublisherCd:@"publisherCd" target:self completionHandler:^(GFPError * _Nullable error) {
NSLog(@"Setup ERROR: %@", error);
}];
// 광고 초기화 성공 여부
[GFPAdManager isSdkInitialized];
// GFPAdConfiguration 설정 포함 초기화 하는 경우.
GFPAdConfiguration *configuration = [[GFPAdConfiguration alloc] init];
[GFPAdManager setupWithPublisherCd:@"publisherCd" target:self configuration:configuration completionHandler:^(GFPError * _Nullable error) {
NSLog(@"Setup ERROR: %@", error);
}];
GFPAdManagerDelegate Configuration
GFPAdManagerDelegate is a required delegate for passing the ad tracking authorization (ATT) status to the SDK.
In accordance with the ATT (App Tracking Transparency) framework introduced in iOS 14, an app must ask the user for tracking permission before accessing the IDFA (advertising identifier) and then notify the SDK of the result. The SDK uses this status to determine whether to apply ad targeting.
GFPAdManagerDelegate implementation is mandatory since NAMSDK version 4.3.0.
If attStatus() is not implemented, initialization will not work correctly.
@protocol GFPAdManagerDelegate <NSObject>
- (GFPATTAuthorizationStatus)attStatus;
@end
typedef NS_ENUM(NSInteger, GFPATTAuthorizationStatus) {
GFPATTAuthorizationStatusNotDetermined = 0, // 사용자의 승인 미요청 상태
GFPATTAuthorizationStatusRestricted = 1, // 사용자의 기기가 제한된 상태.
GFPATTAuthorizationStatusDenied = 2, // 사용자의 IDFA 요청 거절 상태.
GFPATTAuthorizationStatusAuthorized = 3, // 사용자의 IDFA 요청 승인 상태.
};
- Swift
- Objective-C
func attStatus() -> GFPATTAuthorizationStatus {
if #available(iOS 14.5, *) {
return ATTrackingManager.trackingAuthorizationStatus
} else {
if ASIdentifierManager.shared().isAdvertisingTrackingEnabled {
return .authorized
}
return .notDetermined
}
- (GFPATTAuthorizationStatus)attStatus {
if (@available(iOS 14.5, *)) {
return ATTrackingManager.trackingAuthorizationStatus;
} else {
if ([[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]) {
return GFPATTAuthorizationStatusAuthorized;
}
return GFPATTAuthorizationStatusNotDetermined;
}
}
WebView Registration
Starting from SDK 8.2.0, the WKWebView used by your app must be registered with GFPAdManager.
Ads may not function correctly if it is not registered.
Register your WebView by following the WebView Registration Guide.
Default Value Configuration
GFPAdConfiguration allows you to configure default values and other settings used throughout the app.
For all available options, refer to the GFPAdConfiguration Settings page.
Ad Language Setting
Sets the language for ad UI components (default: none). This applies only to ads served via S2S.
When set to none, rendering is based on the device language; if the language is not supported, English is used.
This must be set before loading an ad. If changed after loading, the language of already-loaded ads will not change. When the language setting is changed, you must reload the ad.
- Swift
- Objective-C
GFPAdManager.adConfiguration().preferredLanguage = .ko
[GFPAdManager adConfiguration].preferredLanguage = GFPLanguageType_ko;
Style Settings
Specifies the style (system, light, or dark) for the Admute icon to match your service's UI.
- Swift
- Objective-C
GFPAdManager.adConfiguration().adInterfaceStyle = .light
GFPAdManager.adConfiguration().adInterfaceStyle = .dark
GFPAdManager.adConfiguration().adInterfaceStyle = .system // 아이폰 설정의 style을 따라갑니다.
[GFPAdManager adConfiguration].adInterfaceStyle = GFPAdInterfaceStyleLight;
[GFPAdManager adConfiguration].adInterfaceStyle = GFPAdInterfaceStyleDark;
[GFPAdManager adConfiguration].adInterfaceStyle = GFPAdInterfaceStyleSystem; // 아이폰 설정의 style을 따라갑니다.
Global CustomParam Settings
Custom parameters can be set for all ad placements. All keys and values in the parameter dictionary must be of string type. (since 6.0.0)
If a key conflicts with adParam's customUserParam, the priority is as follows:
- GFPAdParam.customUserParam > GFPAdConfiguration.customParam
- Swift
- Objective-C
GFPAdManager.adConfiguration().customParam = ["key1": "value1", "key2": "value2"] //custom key:value
[GFPAdManager adConfiguration].customParam = @{@"key1": @"value1", @"key2": @"value2"}; //custom key:value