跳至主要內容

插屏广告

大约 3 分钟

插屏广告

概述

插屏广告是移动广告的一种常见形式,一般在应用使用过程中弹出,用户可以选择点击广告以访问目标网址,或者关闭广告以返回应用。
插屏广告有两种形式:半屏和全屏。两者都覆盖整个屏幕,区别在于广告内容的展示区域大小。半屏广告在展示区域之外,背景为半透明。

SAInterstitialAd 方法和属性介绍

属性说明是否必选
可选,建议必填
如果插屏广告素材为视频,可以设置视频是否静音,默认不静音可选
方法说明
构造方法,传入广告位ID和广告大小。adSize对广告展示已不再产生影响,可传屏幕尺寸。
加载广告
- (BOOL)showAdFromRootViewController:(UIViewController *)rootViewController;展示插屏广告
预先加载的开屏广告在需要展示时可能已经失效,需要调用此方法进行判断。

SAInterstitialAd 代理方法说明

/// 插屏广告代理协议
@protocol SAInterstitialAdDelegate <NSObject>
@optional
/// 插屏广告加载成功
- (void)sa_interstitialAdLoadSuccess:(SAInterstitialAd *)interstitialAd;
/// 插屏广告的各种错误信息
- (void)sa_interstitialAd:(SAInterstitialAd *)interstitialAd didFailWithError:(NSError *_Nullable)error;
/// 插屏广告即将展示
- (void)sa_interstitialAdWillShow:(SAInterstitialAd *)interstitialAd;
/// 插屏广告已经展示
- (void)sa_interstitialAdDidShow:(SAInterstitialAd *)interstitialAd;
/// 点击了插屏广告
- (void)sa_interstitialAdDidClick:(SAInterstitialAd *)interstitialAd;
/// 插屏广告即将被关闭
- (void)sa_interstitialAdWillClose:(SAInterstitialAd *)interstitialAd;
/// 插屏广告已经被关闭
- (void)sa_interstitialAdDidClose:(SAInterstitialAd *)interstitialAd;
/// 插屏广告已曝光
- (void)sa_interstitialAdDidExposed:(SAInterstitialAd *)rewardVideoAd;
@end

插屏广告接入示例

@import SAAdSDK;

@interface SADInterstitialViewController ()<SAInterstitialAdDelegate, UITextFieldDelegate>
@property (strong, nonatomic) SAInterstitialAd *interstitialAd;
@end

@implementation SADInterstitialViewController

- (void)loadInterstitial {
    NSString *posID = SADAdConfig.current.interstitialId;
    _interstitialAd = [[SAInterstitialAd alloc] initWithSlotId: posID adSize:UIScreen.mainScreen.bounds.size];
    _interstitialAd.delegate = self;
    _interstitialAd.videoMuted = !_muteSwitch.on;
    [_interstitialAd loadAd];
}

//MARK: - SAInterstitialAdDelegate
/// 插屏广告加载成功
- (void)sa_interstitialAdLoadSuccess:(SAInterstitialAd *)interstitialAd {
    [_interstitialAd showAdFromRootViewController:self];
}

上次编辑于: