-
Notifications
You must be signed in to change notification settings - Fork 6
Implementation for native ads
Please refer to the link below if you have not downloaded the SDK or created an ad space.
If you have not added the SDK into the Project, please add it by the following methods.
There are 3 steps to implement Native Ads.
- Assign View with the ad information Layout
- Load Native Ads
- Showing the loaded ad information in View
Please prepare View in order to display ads from the app side.
For ad display View - UIView and its subclass must be based on the NADNativeViewRendering protocol.
For NADNativeViewRenderingProtocol, we will provide IF so the app can notify the SDK with the following elements below.
- Ad Explicitly
- Ad content
- Ad sentence
- Promotion name
- Promotion URL
- Action button
- Ad image
- Logo image
Details of each IF is as follows:
| Message | Implementation | Details |
|---|---|---|
| - (UILabel *)prTextLabel | required | Please return UILabel to display ad explicitly. |
| - (UILabel *)shortTextLabel | optional | Please return UILabel to display ad content. |
| - (UILabel *)longTextLabel | optional | Please return UILabel to display ad sentence. |
| - (UILabel *)promotionNameLabel | optional | Please return UILabel to display promotion name. |
| - (UILabel *)promotionUrlLabel | optional | Please return UILabel to display the URL. |
| - (UILabel *)actionButtonTextLabel | optional | Please return UILabel to display action button text. |
| - (UIImageView *)adImageView | optional | Please return UILabel to display ad image. |
| - (UIImageView *)logoImageView | optional | Please return UILabel to display logo image. |
For View that is returned through NADNativeViewRendering, it is required to be the descendent of View that conforms to the NADNativeViewRendering Protocol
Please display the native ads withing the following limits:
- It is required to display the ad explicitly
- Either Ad content, sentence or promotion needs to be displayed
- Ad image must be displayed if you select this option in the ad space
- The image needs to be displayed by the following limits:
| Element | Scale | Clip |
|---|---|---|
| Ad Image | 30%~150% | Up and down, left and right, below 6% each |
| Logo Image | No limits | prohibited |
| Please make sure the ratio is the same when scaling. |

Swift
import NendAd
class YourNativeAdView: UIView, NADNativeViewRendering {
@IBOutlet private weak var nativeAdPrTextLabel: UILabel!
@IBOutlet private weak var nativeAdShortTextLabel: UILabel!
@IBOutlet private weak var nativeAdLongTextLabel: UILabel!
@IBOutlet private weak var nativeAdPromotionNameLabel: UILabel!
@IBOutlet private weak var nativeAdPromotionUrlLabel: UILabel!
@IBOutlet private weak var nativeAdActionButtonTextLabel: UILabel!
@IBOutlet private weak var nativeAdImageView: UIImageView!
@IBOutlet private weak var nativeAdLogoImageView: UIImageView!
// MARK: - NADNativeViewRendering
func prTextLabel() -> UILabel! {
return self.nativeAdPrTextLabel
}
func shortTextLabel() -> UILabel! {
return self.nativeAdShortTextLabel
}
func longTextLabel() -> UILabel! {
return self.nativeAdLongTextLabel
}
func promotionNameLabel() -> UILabel! {
return self.nativeAdPromotionNameLabel
}
func promotionUrlLabel() -> UILabel! {
return self.nativeAdPromotionUrlLabel
}
func actionButtonTextLabel() -> UILabel! {
return self.nativeAdActionButtonTextLabel
}
func adImageView() -> UIImageView! {
return self.nativeAdImageView
}
func logoImageView() -> UIImageView! {
return self.nativeAdLogoImageView
}
}Objective-C
#import <NendAd/NADNativeViewRendering.h>
@interface YourNativeAdView () <NADNativeViewRendering>
@property (nonatomic, weak) IBOutlet UILabel *nativeAdPrTextLabel;
@property (nonatomic, weak) IBOutlet UILabel *nativeAdShortTextLabel;
@property (nonatomic, weak) IBOutlet UILabel *nativeAdLongTextLabel;
@property (nonatomic, weak) IBOutlet UILabel *nativeAdPromotionNameLabel;
@property (nonatomic, weak) IBOutlet UILabel *nativeAdPromotionUrlLabel;
@property (nonatomic, weak) IBOutlet UILabel *nativeAdActionButtonTextLabel;
@property (nonatomic, weak) IBOutlet UIImageView *nativeAdImageView;
@property (nonatomic, weak) IBOutlet UIImageView *nativeAdLogoImageView;
@end
@implementation YourNativeAdView
...
#pragma mark - NADNativeViewRendering
- (UILabel *)prTextLabel
{
return self.nativeAdPrTextLabel;
}
- (UILabel *)shortTextLabel
{
return self.nativeAdShortTextLabel;
}
- (UILabel *)longTextLabel
{
return self.nativeAdLongTextLabel;
}
- (UILabel *)promotionNameLabel
{
return self.nativeAdPromotionNameLabel;
}
- (UILabel *)promotionUrlLabel
{
return self.nativeAdPromotionUrlLabel;
}
- (UILabel *)actionButtonTextLabel
{
return self.nativeAdActionButtonTextLabel;
}
- (UIImageView *)adImageView
{
return self.nativeAdImageView;
}
- (UIImageView *)logoImageView
{
return self.nativeAdLogoImageView;
}
@endFirst, generate NADNAtiveClient Class Instance.
Swift
import NendAd
// Maintain Instance
private var client: NADNativeClient!
...
self.client = NADNativeClient(spotID: spotID, apiKey: "apiKey")Objective-C
#import <NendAd/NADNativeClient.h>
// Maintain Instance
@property (nonatomic, strong) NADNativeClient *client;
...
self.client = [[NADNativeClient alloc] initWithSpotID:spotID apiKey:@"apiKey"];The information to generate Instance are as follows:
| Argument Name | Type | Explanation |
|---|---|---|
| spotID | NSInteger |
SpotID issued from the dashboard |
| apiKey | NSString |
ApiKey issued from the dashboard |
Next, you will load the ad by the loadWithCompletionBlock: method of NADNativeClient Class.
If loading is successful, then the NADNative object will be passed to the argument Blocks.
If the load fails, then the NSError Object will be passed to the argument Blocks with the error information.
Swift
self.client.load() { (ad, error) in
if let nativeAd = ad {
// Success
} else {
// Failed
print("error:\(error!)")
}
}Objective-C
[self.client loadWithCompletionBlock:^(NADNative *ad, NSError *error) {
if (ad) {
// Success
} else {
// Failed
NSLog(@"error: %@", error);
}
}];The following are the error codes of NSError when loading fails:
| Code | Details | Note |
|---|---|---|
| kNADNativeErrorCodeFailedToRequest | Request failed | No internet connection, etc. (You can check the localizedDescription in NSError for more information) |
| kNADNativeErrorCodeInvalidResponseType | Invalid Response Type | SDK Internal error (rare case) |
You can display the ad information within View by the intoView:advertisingExplicitly: method in NADNative Class that was acquired before.
Information is as follows:
| Argument Name | Type | Explanation |
|---|---|---|
| adView | UIView<NADNativeViewRendering> |
View of the ad information layout |
| advertisingExplicitly | NADNativeAdvertisingExplicitly |
Wording of the ad explicitly |
The definition of NADNativeAdvertisingExplicitly is as follows:
| Name | Wording |
|---|---|
| NADNativeAdvertisingExplicitlyPR | PR |
| NADNativeAdvertisingExplicitlySponsored | Sponsored |
| NADNativeAdvertisingExplicitlyAD | 広告 |
| NADNativeAdvertisingExplicitlyPromotion | プロモーション |
Swift
var nativeAd: NADNative = ... // Ad Object
var adView: YourNativeAdView = ... // View of the ad information layout
nativeAd.intoView(adView, advertisingExplicitly: .PR)Objective-C
NADNative *nativeAd = ...; // Ad Object
YourNativeAdView *adView = ...; // View of the ad information layout
[nativeAd intoView:adView advertisingExplicitly:NADNativeAdvertisingExplicitlyPR];You can reload ads by the enableAutoReloadWithInterval:completionBlock method of NADNativeClient Class.
Swift
self.client.enableAutoReload(withInterval: interval, completionBlock: { (ad, error) in
if let nativeAd = ad {
// Successful
} else {
// Failed
}
})Objective-C
[self.client enableAutoReloadWithInterval:interval completionBlock:^(NADNative *ad, NSError *error) {
if (ad) {
// Successful
} else {
// Failed
NSLog(@"error: %@", error);
}
}];| Argument Name | Type | Explanation |
|---|---|---|
| interval | NSTimeInterval |
Auto Reload Interval |
Please set the reload interval time to at least 30 seconds.
You can stop auto reload by the disableAutoReload Method in NADNativeClient Class.
Swift
self.client.disableAutoReload()Objective-C
[self.client disableAutoReload];You can receive ad event notifications by setting the NADNativeDelegate Protocol of NADNative Class to delegate.
Swift
class YourClass: NSObject, NADNativeDelegate {
private var client: NADNativeClient!
...
private func exampleLoadAd() {
self.client.load() { (ad, error) in
if let nativeAd = ad {
nativeAd.delegate = self
}
}
}
// MARK: - NADNativeDelegate
// It will be called when the ad is clicked
func nadNativeDidClickAd(_ ad: NADNative!) {
print("Click ad.")
}
}Objective-C
#import <NendAd/NADNativeClient.h>
@interface YourClass : NSObject <NADNativeDelegate>
@property (nonatomic, strong) NADNativeClient *client;
@end
...
import NendAd
@implementation YourClass
...
__weak typeof(self) weakSelf = self;
[self.client loadWithCompletionBlock:^(NADNative *ad, NSError *error) {
if (ad) {
ad.delegate = weakSelf;
...
}
}];
...
@end
...
#pragma mark - NADNativeDelegate
///-----------------------------------------------
/// @optional
///-----------------------------------------------
// It will be called when the ad is clicked
- (void)nadNativeDidClickAd:(NADNative *)ad
{
NSLog(@"click ad.");
}-
v7.0.4 以降のバージョンから SKAdNetwork を使用した広告配信を行っております。最新版のSDKへのアップデートを推奨します。
更新履歴はこちらを参照ください。 -
iOS14以降では、広告の効果を測定するためにアプリに追加の設定を行う必要があります。
詳細はこちらを参照ください。 -
2023年9月1日より、SDK v6.0.0未満では動画広告の配信を停止いたします。新しいバージョンのご利用をご検討ください。
-
We recommend updating to latest version. v7.0.4 or higher it using advertise SKAdNetwork.
For details, please Release Notes. -
Need to configure the app for ad conversion tracking for iOS14.
For details, please check here. -
Effective September 1, 2023, we will stop serving video ads with SDK under v6.0.0. Please consider using a newer version.
- バナー型広告
- インタースティシャル広告
- ネイティブ広告
- フルボード広告
- 動画広告
- 動画ネイティブ広告
- Release Notes
- Preparation
- Supported Environments
- nendSDK Data Collection Items
- Privacy Policy
- About Information Button
- Add Manually
- Use CocoaPods
- Preparing for iOS14 or later
- When updating from nendSDK before version 3.2.2
- Banner Ad
- Interstitial Ad
- Native Ad
- Fullscreen Ad
- Video Ad
- Native Video Ad