如何在tvOS中集成横幅广告?

时间:2016-05-05 07:24:10

标签: swift tvos advertisement banner-ads

在我的应用程序中,我使用tvOS广告。我已尝试使用AppLovin SDK进行广告实施,但它会显示全屏广告。

我希望在我的tvOS应用中显示滚动数据更新的横幅视图。我可以在tvOS上使用iAd或AdMob实现这一目标吗?

我正在使用

ALSdk.shared()!.adService.loadNextAd(ALAdSize.sizeInterstitial(), andNotify: self)

加载广告。

然后,一旦广告可用,我就会使用以下内容展示广告:

ALInterstitialAd.shared().adDisplayDelegate = self
ALInterstitialAd.shared().adVideoPlaybackDelegate = self

if let ad = self.ad
{            
    ALInterstitialAd.shared().showOver(UIApplication.sharedApplication().keyWindow!, andRender: ad)
}

2 个答案:

答案 0 :(得分:1)

正如Daniel Storm所说,横幅广告在电视上真的没有意义。但如果你坚持,你可以创建自己的横幅natively

例如,在视图控制器中:

@interface ALDemoNativeAdProgrammaticViewController ()<ALNativeAdLoadDelegate, ALNativeAdPrecacheDelegate, ALPostbackDelegate>
@property (nonatomic, strong) ALNativeAd *nativeAd;
@end

- (void)viewDidLoad
{
  [super viewDidLoad];
  [[ALSdk shared].nativeAdService loadNativeAdGroupOfCount: 1 andNotify: self];
}

#pragma mark - Native Ad Load Delegate

- (void)nativeAdService:(nonnull ALNativeAdService *)service didLoadAds:(nonnull NSArray *)ads
{
    // At this point, the native ad is loaded, but assets not retrieved yet.
    self.nativeAd = [ads firstObject];

    // You can use AppLovin's pre-caching to retrieve assets (app icon, ad image, ad video) locally. OR you can do it with your preferred caching framework.
    // iconURL, imageURL, videoURL needs to be retrieved manually before you can render them. For our example, we'll use AppLovin's caching framework.
    [[ALSdk shared].nativeAdService precacheResourcesForNativeAd: self.nativeAd andNotify: self];
}

- (void)nativeAdService:(nonnull ALNativeAdService *)service didFailToLoadAdsWithError:(NSInteger)code
{
  // Handle error
}

#pragma mark - Native Ad Precache Delegate

- (void)nativeAdService:(nonnull ALNativeAdService *)service didPrecacheImagesForAd:(nonnull ALNativeAd *)ad { }

- (void)nativeAdService:(nonnull ALNativeAdService *)service didPrecacheVideoForAd:(nonnull ALNativeAd *)ad
{
    // This delegate method will get called whether an ad actually has a video to precache or not
    //
    // FINALLY, perform whatever view logic you want with the assets provided in your ALNativeAd property, and show the ad.
}

- (void)nativeAdService:(nonnull ALNativeAdService *)service didFailToPrecacheImagesForAd:(nonnull ALNativeAd *)ad withError:(NSInteger)errorCode 
{
  // Handle error
}

- (void)nativeAdService:(nonnull ALNativeAdService *)service didFailToPrecacheVideoForAd:(nonnull ALNativeAd *)ad withError:(NSInteger)errorCode 
{
  // Handle error
}

请注意,不保证在主队列上调用AppLovin的回调。

跟踪自己的展示次数也是您的责任

[[ALSdk shared].postbackService dispatchPostbackAsync: ad.impressionTrackingURL andNotify: self];

并在点击时启动App商店

 [self.nativeAd launchClickTarget];

答案 1 :(得分:0)

iAd不支持tvOS和is being discontinued,AdMob也不支持tvOS,AppLovin仅支持tvOS上的全屏插页式广告。因此,截至目前,横幅广告无法在tvOS上播出。我不希望他们很快就能看到横幅广告在电视上没有多大意义。