Getting Started
Supported Versions
- iOS 13.0 or later
- Xcode 12.0 or later
Starting from GFPSDK 4.3.0, Xcode 12.0 or later is required (supports iOS 14 or later).
Starting from GFPSDK 6.0.0, Xcode 14.1 or later is required when using Google DFP.
Starting from GFPSDK 7.0.0, Xcode 15 or later is required when using Unity or IronSource.
Starting from GFPSDK 8.0.0, Xcode 16 or later is required.
Integrating the Ad SDK
Adding Cocoapods Dependencies
Add 'GFPSDK' to your Podfile.
Add the Mediation Pods for the ad networks you plan to use.
target 'MyApplication' do
pod 'GFPSDK' # SDK Core
pod 'GFPSDK/MediationNDA' # Naver in-house Banner & Native Ads
pod 'GFPSDK/MediationNDAVideo' # Naver in-house Video Ads
pod 'GFPSDK/MediationNDARich' # Naver in-house Premium Ads (requires 7.2.0>=)
pod 'GFPSDKMediationDFP' # Google DFP (since 8.0.0)
pod 'GFPSDKMediationFAN' # Facebook FAN (since 8.0.0)
pod 'GFPSDKMediationInMobi' # InMobi (since 8.0.0)
pod 'GFPSDKMediationUnity' # Unity (since 8.0.0)
pod 'GFPSDKMediationAppLovin' # AppLovin (since 8.0.0)
pod 'GFPSDKMediationVungle' # Vungle (since 8.0.0)
pod 'GFPSDKMediationDT' # Digital Turbine (since 8.0.0)
pod 'GFPSDKMediationIronSource' # Iron Source (since 8.0.0)
pod 'GFPSDKMediationAPS' # APS (since 8.0.0)
pod 'GFPSDKMediationLAN' # LAN (since 8.0.0)
pod 'GFPSDKMediationChartBoost' # ChartBoost (since 8.4.0)
pod 'GFPSDKMediationBidMachine' # BidMachine (since 8.4.0)
pod 'GFPSDKMediationPangle' # Pangle (since 8.13.0)
end
List of In-house Ads
| Ad Network | Supported Ad Type | Cocoapods Settings |
|---|---|---|
| NAVER | Banner, Native | pod GFPSDK/MediationNDA |
| NAVER | Video | pod GFPSDK/MediationNDAVideo |
| NAVER | Native Rich Reward | pod GFPSDK/MediationNDARich |
List of Mediated Ad Networks
| Ad Network | Supported Ad Type | Cocoapods Settings |
|---|---|---|
| Google DFP | Banner, Native, Interstitial, Reward | pod GFPSDKMediationDFP |
| Google IMA | Video | pod GFPSDKMediationIMA |
| Banner, Native, Interstitial, Reward | pod GFPSDKMediationFAN | |
| InMobi | Banner, Native | pod GFPSDKMediationInMobi |
| Unity | Banner, Interstitial, Reward | pod GFPSDKMediationUnity |
| AppLovin | Banner, Native, Interstitial, Reward | pod GFPSDKMediationAppLovin |
| Vungle | Banner, Native, Interstitial, Reward | pod GFPSDKMediationVungle |
| DigitalTurbine | Banner, Interstitial, Reward | pod GFPSDKMediationDT |
| IronSource | Interstitial, Reward | pod GFPSDKMediationIronSource |
| APS | Reward | pod GFPSDKMediationAPS |
| LAN | Native, Interstitial, Reward | pod GFPSDKMediationLAN |
| ChartBoost | Banner, Interstitial, Reward | pod GFPSDKMediationChartBoost |
| BidMachine | Banner, Interstitial, Reward | pod GFPSDKMediationBidMachine |
| Pangle | Banner, Native, Interstitial, Reward | pod GFPSDKMediationPangle |
See the up-to-date list of available ad networks in GFPProviderOptions.swift
GFPBannerProviderOptionGFPVideoProviderOptionGFPNativeProviderOptionGFPCombinedProviderOptionGFPRewardedAdProviderOptionGFPInterstitialAdProviderOption
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.
- 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
Podfilewill 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.
When calling setup(), pass the Publisher Code and Service Code obtained from your GFP account manager.
Publisher Code is required. Omitting it will cause an initialization error.
Service Code is an optional value for publishers running multiple services under the same Publisher Code. If this does not apply, you can omit the Service Code and only provide the Publisher Code.
You can validate initialization by isSdkInitialized property.
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 rendering time, etc.
let configuration = GFPAdConfiguration()
// 3. Example of initializing with GFPAdConfiguration, with a PublisherCd.
GFPAdManager.setup(withPublisherCd: "publisherCd", target:self, configuration: configuration) { (error : GFPError?) in
print("Setup Error: \(String(describing: error?.description))")
}
// 4. Example of initializing with GFPAdConfiguration, with PublisherCd & ServiceCd.
GFPAdManager.setup(withPublisherCd: "publisherCd", 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 rendering time, etc.
GFPAdConfiguration *configuration = [[GFPAdConfiguration alloc] init];
// 3. Example of initializing with GFPAdConfiguration, with a PublisherCd.
[GFPAdManager setupWithPublisherCd:@"publisherCd" target:self configuration:configuration completionHandler:^(GFPError * _Nullable error) {
NSLog(@"Setup Error: %@", error);
}];
// 4. Example of initializing with GFPAdConfiguration, with PublisherCd & ServiceCd.
[GFPAdManager setupWithPublisherCd:@"publisherCd" serviceCd:@"serviceCd" configuration:configuration target:self completionHandler:^(GFPError * _Nullable error) {
NSLog(@"Setup Error: %@", error);
}];
GFPAdManagerDelegate
For GFPSDK >= 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)
- GFPSDK 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)
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
If set to 'none', ads will be rendered based on the device's language. For unsupported languages, English will be displayed by default.
Set this before loading ads. Changes made afterward won’t affect ads already loaded. The new language setting will only apply to ads loaded after the change.
- Swift
- Objective-C
GFPAdManager.adConfiguration().preferredLanguage = .ko
[GFPAdManager adConfiguration].preferredLanguage = GFPLanguageType_ko;
Advertising Cookie settings
You can also setup Naver user identifiers with GFPAdManager.
- Swift
- Objective-C
let cookie = ["key1": "value1", "key2": "value2"]
GFPAdManager.setCookie(cookie)
GFPAdManager.appendCookie(["key3":"value3"])
GFPAdManager.clearCookie()
NSDictionary <NSString *, NSString *> *cookie = @{@"key1": @"value1", @"key2": @"value2"};
[GFPAdManager setCookie:cookie];
[GFPAdManager appendCookie: @{@"key3": @"value3"}];
[GFPAdManager clearCookie];
Test Mode Settings
You can enable test modes, which restrict ad delivery to non-commercial test ads from certain 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.
- Swift
- Objective-C
GFPAdManager.adConfiguration().adInterfaceStyle = .light
GFPAdManager.adConfiguration().adInterfaceStyle = .dark
GFPAdManager.adConfiguration().adInterfaceStyle = .system
[GFPAdManager adConfiguration].adInterfaceStyle = GFPAdInterfaceStyleLight;
[GFPAdManager adConfiguration].adInterfaceStyle = GFPAdInterfaceStyleDark;
[GFPAdManager adConfiguration].adInterfaceStyle = GFPAdInterfaceStyleSystem;
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
- Swift
- Objective-C
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.
- Swift
- Objective-C
let abt = "SUBS:V0;HOME:V2;NEWS:V1"
let configuration = GFPAdManager.adConfiguration
configuration.abt = abt
GFPAdManager.adConfiguration = configuration
NSString *abt = @"SUBS:V0;HOME:V2;NEWS:V1";
GFPAdConfiguration *configuration = GFPAdManager.adConfiguration;
configuration.abt = abt;
GFPAdManager.adConfiguration = configuration;
Deprecated
Adding Cocoapods Dependencies (until 7.x.x)
Add 'GFPSDK' to your Podfile.
Add the Mediation Pods for the ad networks you plan to use.
target 'MyApplication' do
pod 'GFPSDK' #
pod 'GFPSDK/MediationNDA' # Naver Banner & Native ads
pod 'GFPSDK/MediationNDAVideo' # Naver Video ads (requires >= 4.3.0)
pod 'GFPSDK/MediationNDARich' # Naver Premium ads (requires >= 7.2.0)
pod 'GFPSDK/MediationDFP'
pod 'GFPSDK/MediationIMA'
pod 'GFPSDK/MediationFAN'
pod 'GFPSDK/MediationInMobi'
pod 'GFPSDK/MediationUnity'
pod 'GFPSDK/MediationAppLovin'
pod 'GFPSDK/MediationVungle'
pod 'GFPSDK/MediationDT' # (requires >= 6.4.0)
pod 'GFPSDK/MediationIronSource' # (requires >= 7.0.0)
pod 'GFPSDK/MediationAPS' # (requires >= 7.2.0)
pod 'GFPSDK/MediationLAN' # (requires >= 7.7.0)
end
List of Supported Ad Networks (until 7.x.x)
| Ad Network | Supported Ad Type | Cocoapods Settings |
|---|---|---|
| NAVER | Banner, Native | pod GFPSDK/MediationNDA |
| NAVER | Video | pod GFPSDK/MediationNDAVideo |
| NAVER | Native Rich Reward | pod GFPSDK/MediationNDARich |
| Google DFP | Banner, Native, Interstitial, Reward | pod GFPSDK/MediationDFP |
| Google IMA | Video | pod GFPSDK/MediationIMA |
| Banner, Native, Interstitial, Reward | pod GFPSDK/MediationFAN | |
| InMobi | Banner, Native | pod GFPSDK/MediationInMobi |
| Unity | Banner, Interstitial, Reward | pod GFPSDK/MediationUnity |
| AppLovin | Banner, Native, Interstitial, Reward | pod GFPSDK/MediationAppLovin |
| Vungle | Interstitial, Reward | pod GFPSDK/MediationVungle |
| DigitalTurbine | Banner, Interstitial, Reward | pod GFPSDK/MediationDT |
| IronSource | Interstitial, Reward | pod GFPSDK/MediationIronSource |
| APS | Reward | pod GFPSDK/MediationAPS |
| LAN | Native, Interstitial, Reward | pod GFPSDK/MediationLAN |