Getting Started
Supported Versions
- iOS 13.0 or higher
- Xcode 12.0 or higher
- 14.1 or higher when using DFP
- 15 or higher when using Unity or IronSource
- 15.2 or higher when using FAN
Starting from NAMSDK 2.2.4, Xcode 12.0 or higher is required. (only compatible with iOS 14 or higher)
Starting from NAMSDK 6.0.0, Xcode 14.1 or higher is required when using Google DFP.
Starting from NAMSDK 7.0.0, Xcode 15 or higher is required when using Unity or IronSource.
Adding Cocoapods Dependencies
Add 'NAMSDK' to your Podfile.
Add Mediation Pods of the ad mediation networks on your demand.
source 'https://github.com/CocoaPods/Specs.git'
target 'MyApplication' do
pod 'NAMSDK' #
pod 'NAMSDK/MediationNDA' # Naver Banner & Native ads
pod 'NAMSDK/MediationNDAVideo' # Naver Video ads (requires >= 4.3.0)
pod 'NAMSDK/MediationNDARich' # Naver Premium ads (requires >= 7.2.0)
pod 'NAMSDK/MediationDFP'
pod 'NAMSDK/MediationIMA'
pod 'NAMSDK/MediationFAN'
pod 'NAMSDK/MediationInMobi'
pod 'NAMSDK/MediationUnity'
pod 'NAMSDK/MediationAppLovin'
pod 'NAMSDK/MediationVungle'
pod 'NAMSDK/MediationDT' # (requires >= 6.4.0)
pod 'NAMSDK/MediationIronSource' # (requires >= 7.0.0)
pod 'NAMSDK/MediationAPS' # (requires >= 7.2.0)
pod 'NAMSDK/MediationLAN' # (requires >= 7.7.0)
end
List of Supported Ad Networks
Ad Network | Supported Ad Type | Cocoapods Settings |
---|---|---|
NAVER | Banner, Native | pod NAMSDK/MediationNDA |
NAVER | Video | pod NAMSDK/MediationNDAVideo |
NAVER | Native Rich Reward | pod NAMSDK/MediationNDARich |
Google DFP | Banner, Native, Interstitial, Reward | pod NAMSDK/MediationDFP |
Google IMA | Video | pod NAMSDK/MediationIMA |
Banner, Native, Interstitial, Reward | pod NAMSDK/MediationFAN | |
InMobi | Banner, Native | pod NAMSDK/MediationInMobi |
Unity | Banner, Interstitial, Reward | pod NAMSDK/MediationUnity |
AppLovin | Banner, Native, Interstitial, Reward | pod NAMSDK/MediationAppLovin |
Vungle | Interstitial, Reward | pod NAMSDK/MediationVungle |
DigitalTurbine | Banner, Interstitial, Reward | pod NAMSDK/MediationDT |
IronSource | Interstitial, Reward | pod NAMSDK/MediationIronSource |
APS | Reward | pod NAMSDK/MediationAPS |
LAN | Native, Interstitial, Reward | pod NMASDK/MediationLAN |
See the up-to-date list of available ad networks in GFPProviderOptions.swift
GFPBannerProviderOption
GFPVideoProviderOption
GFPNativeProviderOption
GFPCombinedProviderOption
GFPRewardedAdProviderOption
GFPInterstitialAdProviderOption
App Transport Security (ATS) settings
App Transport Security (ATS) has been introduced in iOS 9 which allows apps to make network requests over HTTPS by default.
In order to allow ad requests to external ad networks over HTTP, add following value to your Info.plist
.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Requirements while linking with Google DFP
To link Google DFP, add the following values to your Info.plist
.
Otherwise, you will get “The Google Mobile Ads SDK was initialized incorrectly” error message with the operation suspended.
<key>GADIsAdManagerApp</key>
<true/>
To apply Google DFP >= 10, follow addtional steps in the reference below.
Importing GFPSDK
First, import GFPSDK.
- Objective-C
- Swift
@import GFPSDK;
import GFPSDK
GFPAdManager
Initializing Ad Networks
-
GFP SDK must be initialized prior to requesting ads, once, in your app's life cycle.
-
Ad networks added in your
Podfile
will be automatically initialized with the GFP SDK.- Be minded that ad networks that are not installed by the
Podfile
will be failed to be rendered, despite receiving proper ad response.
- Be minded that ad networks that are not installed by the
-
To initialize GFPAdManager, pass Publisher Code (required) which is registered in GFP dashboard.
-
Pass Service Code (optional) to manage multiple apps separately.
-
You can validate initialization by
isSdkInitialized
property.
For NAMSDK >= 7.3.0 the new ServiceCd is available for initializing SDK. Use ServiceCd (optional) with PublisherCd (required) when managing multiple apps of a same publisher.
See more information about initialization in GFPAdManager.h.
- Objective-C
- Swift
@import GFPSDK;
// 1. Example of initializing without GFPAdConfiguration, with a PublisherCd.
[GFPAdManager setupWithPublisherCd:@"publisherCd" target:self completionHandler:^(GFPError * _Nullable error) {
NSLog(@"Setup ERROR: %@", error);
}];
// 2. Example of initializing without GFPAdConfiguration, with PublisherCd & ServiceCd.
[GFPAdManager setupWithPublisherCd:@"publisherCd" serviceCd:@"serviceCd" target:self completionHandler:^(GFPError * _Nullable error) {
NSLog(@"Setup ERROR: %@", error);
}];
// Check for initialization success.
[GFPAdManager isSdkInitialized];
// Initializing with GFPAdConfiguration: set test mode, request timeouts, log levels, ad redering time, etc.
GFPAdConfiguration *configuration = [[GFPAdConfiguration alloc] init];
[GFPAdManager setupWithPublisherCd:@"publisherCd" serviceCd:@"serviceCd" configuration:configuration target:self completionHandler:^(GFPError * _Nullable error) {
NSLog(@"Setup ERROR: %@", error);
}];
import GFPSDK
// 1. Example of initializing without GFPAdConfiguration, with a PublisherCd.
GFPAdManager.setup(withPublisherCd: "publisherCd" target:self) { (error : GFPError?) in
print("Setup Eror: \(String(describing: error?.description))")
}
// 2. Example of initializing without GFPAdConfiguration, with PublisherCd & ServiceCd.
GFPAdManager.setup(withPublisherCd: "publisherCd", serviceCd: "serviceCd", target: self) { error in
print("Setup Eror: \(String(describing: error?.description))")
}
// Check for initialization success.
GFPAdManager.isSdkInitialized()
// Initializing with GFPAdConfiguration: set test mode, request timeouts, log levels, ad redering time, etc.
let configuration = GFPAdConfiguration()
GFPAdManager.setup(withPublisherCd: nil, serviceCd: "serviceCd", target:self configuration: configuration) { (error : GFPError?) in
print("Setup Eror: \(String(describing: error?.description))")
}
GFPAdManagerDelegate
For NAMSDK >= 3.1.3, you must provide GFPAdManagerDelegate to GFPAdManager.
Implement ad tracking mechanism of your app using Apple ATTrackingManager and provide tracking status to GFPAdManagerDelegate
@protocol GFPAdManagerDelegate <NSObject>
- (GFPATTAuthorizationStatus)attStatus;
@end
typedef NS_ENUM(NSInteger, GFPATTAuthorizationStatus) {
GFPATTAuthorizeNotDetermined = 0, // = ATTrackingManager.AuthorizationStatus.notDetermined
GFPATTAuthorizeRestricted, // = ATTrackingManager.AuthorizationStatus.restricted
GFPATTAuthorizeDenied, // = ATTrackingManager.AuthorizationStatus.denied
GFPATTAuthorizeAuthorized // = ATTrackingManager.AuthorizationStatus.authorized
};
- Objective-C
- Swift
- (GFPATTAuthorizationStatus)attStatus {
if (@available(iOS 14.5, *)) {
switch (ATTrackingManager.trackingAuthorizationStatus) {
case ATTrackingManagerAuthorizationStatusNotDetermined:
return GFPATTAuthorizeNotDetermined;
case ATTrackingManagerAuthorizationStatusRestricted:
return GFPATTAuthorizeRestricted;
case ATTrackingManagerAuthorizationStatusDenied:
return GFPATTAuthorizeDenied;
case ATTrackingManagerAuthorizationStatusAuthorized:
return GFPATTAuthorizeAuthorized;
}
} else {
if ([[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]) {
return GFPATTAuthorizeAuthorized;
}
return GFPATTAuthorizeNotDetermined;
}
}
func attStatus() -> GFPATTAuthorizationStatus {
if #available(iOS 14, *) {
switch ATTrackingManager.trackingAuthorizationStatus {
case .notDetermined: return .authorizeNotDetermined
case .restricted: return .authorizeRestricted
case .denied: return .authorizeDenied
case .authorized: return .authorizeAuthorized
default: print("value is invalid."); return .authorizeNotDetermined
}
} else {
if ASIdentifierManager.shared().isAdvertisingTrackingEnabled {
return GFPATTAuthorizeAuthorized
}
return GFPATTAuthorizeNotDetermined
}
}
Available settings in GFPAdConfiguration
- Banner ad request timeout (default: 60 seconds)
- Video ad request timeout (default: 60 seconds)
- Native ad request timeout (default: 60 seconds)
- Integrated ad request timeout (default: 60 seconds)
- Rewarded ad request timeout (default: 60 seconds)
- Interstitial ad request timeout (default: 60 seconds)
- DFP test ad setting (default: NO)
- FAN test ad setting (default: NO)
- NAMSDK log level settings (default: no logs)
- Enable default user agent (default: NO)
- Ad interface style settings (default: Light)
- Disable crash report external ad network SDKs (default: NO)
- Global customUserParam settings
- Mute audio by default for rewarded video ads (applies to Naver and most of other ad network ads) (default: YES)
- Language settings for advertising UI components (default: none)
Ad language settings
Language settings for advertising UI components (default: none). However, this applies only to advertisements served through s2s.
- Supported languages: Korean, English, Thai, French, Spanish, Indonesian, Simplified/Traditional Chinese, Japanese, German
When set to none, it is rendered based on the device's language, and if the language is not supported, it is displayed in English.
This must be set before loading the ad, and if you change it after loading, the language of the already loaded ad will not change. When changing language settings, ad loading must be re-loaded.
- Objective-C
- Swift
[GFPAdManager adConfiguration].preferredLanguage = GFPLanguageType_ko;
GFPAdManager.adConfiguration().preferredLanguage = .ko
Advertising Cookie settings
You can also setup Naver user identifiers with GFPAdManager.
- Objective-C
- Swift
NSDictionary <NSString *, NSString *> *cookie = @{@"key1": @"value1", @"key2": @"value2"};
[GFPAdManager setCookie:cookie];
[GFPAdManager appendCookie: @{@"key3": @"value3"}];
[GFPAdManager clearCookie];
let cookie = ["key1": "value1", "key2": "value2"]
GFPAdManager.setCookie(cookie)
GFPAdManager.appendCookie(["key3":"value3"])
GFPAdManager.clearCookie()
Test Mode Settings
You can enable test modes which limits to non-commercial test ads from some ad networks.
- Supports Google and Facebook test modes.
See more information about test modes in GFPAdProviderSetting.h
Interface Styles
Interface Style changes "AdMute" icon at the corner of ad, according to user device's theme settings.
- Objective-C
- Swift
[GFPAdManager adConfiguration].adInterfaceStyle = GFPAdInterfaceStyleLight;
[GFPAdManager adConfiguration].adInterfaceStyle = GFPAdInterfaceStyleDark;
[GFPAdManager adConfiguration].adInterfaceStyle = GFPAdInterfaceStyleSystem;
GFPAdManager.adConfiguration().adInterfaceStyle = .light
GFPAdManager.adConfiguration().adInterfaceStyle = .dark
GFPAdManager.adConfiguration().adInterfaceStyle = .system
Global CustomParam Settings
-
(GFP SDK >= 6.0.0) Some apps might be advised to set CustomParams for better algorithm.
-
Set CustomParam in a form of dictionary of both key and value strings.
-
For dictionary values that must contain mutiple values should separate them with "|" letter (not array of strings).
-
GFPAdParam.customUserParam is prioritized over GFPAdConfiguration.customParam
- Objective-C
- Swift
[GFPAdManager adConfiguration].customParam = @{@"key1": @"value1", @"key2": @"value2", @"key3":@"a|b|c"};
GFPAdManager.adConfiguration().customParam = ["key1": "value1", "key2": "value2", "key3":"a|b|c"]
A/B Test Parameters
- (GFP SDK >= 6.5.0) Some Naver apps that demands A/B Test can use abt param.
- Objective-C
- Swift
NSString *abt = @"SUBS:V0;HOME:V2;NEWS:V1";
GFPAdConfiguration *configuration = GFPAdManager.adConfiguration;
configuration.abt = abt;
GFPAdManager.adConfiguration = configuration;
let abt = "SUBS:V0;HOME:V2;NEWS:V1"
let configuration = GFPAdManager.adConfiguration
configuration.abt = abt
GFPAdManager.adConfiguration = configuration