Getting Started
Supported Versions
- iOS 13.0 or later
- Xcode 12.0 or later
Starting from NAMSDK 4.3.0, Xcode 12.0 or later is required (supports iOS 14 or later).
Starting from NAMSDK 6.0.0, Xcode 14.1 or later is required when using Google DFP.
Starting from NAMSDK 7.0.0, Xcode 15 or later is required when using Unity or IronSource.
Starting from NAMSDK 8.0.0, Xcode 16 or later is required.
Integrating the Ad SDK
Adding Cocoapods Dependencies
Add 'NAMSDK' to your Podfile.
Add the Mediation Pods for the ad networks you plan to use.
target 'MyApplication' do
pod 'NAMSDK' # SDK Core
pod 'NAMSDK/MediationNDA' # Naver in-house Banner & Native Ads
pod 'NAMSDK/MediationNDAVideo' # Naver in-house Video Ads
pod 'NAMSDK/MediationNDARich' # Naver in-house Premium Ads (requires 7.2.0>=)
pod 'NAMSDKMediationDFP' # Google DFP (since 8.0.0)
pod 'NAMSDKMediationFAN' # Facebook FAN (since 8.0.0)
pod 'NAMSDKMediationInMobi' # InMobi (since 8.0.0)
pod 'NAMSDKMediationUnity' # Unity (since 8.0.0)
pod 'NAMSDKMediationAppLovin' # AppLovin (since 8.0.0)
pod 'NAMSDKMediationVungle' # Vungle (since 8.0.0)
pod 'NAMSDKMediationDT' # Digital Turbine (since 8.0.0)
pod 'NAMSDKMediationIronSource' # Iron Source (since 8.0.0)
pod 'NAMSDKMediationAPS' # APS (since 8.0.0)
pod 'NAMSDKMediationLAN' # LAN (since 8.0.0)
end
Adding Dependencies with Swift Package Manager
SPM is supported from NAMSDK version 8.10.0 and above.
SPM cannot be used when using external mediation. If you're using external mediation, it's recommended to integrate via CocoaPods.
Add the NAMSDK package dependency to your project:
- In Xcode, click File > Add Package Dependencies.
- In the top-right Search or Enter Package URL field, enter the NAMSDK Swift package GitHub repository:
https://github.com/naver/nam-sdk-ios.git
- Select the Swift package version you want to use.
- In Xcode, go to App Target > Build Settings > Other Linker Flags, and add the -ObjC option.
List of In-house Ads
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 |
List of Mediated Ad Networks
Ad Network | Supported Ad Type | Cocoapods Settings |
---|---|---|
Google DFP | Banner, Native, Interstitial, Reward | pod NAMSDKMediationDFP |
Google IMA | Video | pod NAMSDKMediationIMA |
Banner, Native, Interstitial, Reward | pod NAMSDKMediationFAN | |
InMobi | Banner, Native | pod NAMSDKMediationInMobi |
Unity | Banner, Interstitial, Reward | pod NAMSDKMediationUnity |
AppLovin | Banner, Native, Interstitial, Reward | pod NAMSDKMediationAppLovin |
Vungle | Banner, Native, Interstitial, Reward | pod NAMSDKMediationVungle |
DigitalTurbine | Banner, Interstitial, Reward | pod NAMSDKMediationDT |
IronSource | Interstitial, Reward | pod NAMSDKMediationIronSource |
APS | Reward | pod NAMSDKMediationAPS |
LAN | Native, Interstitial, Reward | pod NAMSDKMediationLAN |
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 NAMSDK
First, import GFPSDK.
- Swift
- Objective-C
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.- Note that ads from networks not included in your Podfile will fail to render, even if a valid ad response is received.
-
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.
- Swift
- Objective-C
import GFPSDK
// 1. Example of initializing without GFPAdConfiguration, with a PublisherCd.
GFPAdManager.setup(withPublisherCd: "publisherCd" target:self) { (error : GFPError?) in
print("Setup Error: \(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 Error: \(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 Error: \(String(describing: error?.description))")
}
@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);
}];
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
};
- Swift
- Objective-C
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
}
}
- (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;
}
}
Registering WebViews
Starting from SDK 8.2.0, it is required to register any WKWebViews used in the app with our manager.
Follow instructions in Registering WebViews
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)
- Disable ADID colletion option (default: NO)
- Using Default In APP Browser Landing option (default: NO)