Swift 如何在tvOS中整合横幅广告?

Swift 如何在tvOS中整合横幅广告?,swift,tvos,ads,banner-ads,Swift,Tvos,Ads,Banner Ads,在我的应用程序中,我使用tvOS的广告。我曾尝试使用AppLovin SDK来实现广告,但它显示了一个全屏广告 我想在我的tvOS应用程序中显示横幅视图,如滚动数据更新。我可以通过电视操作系统上的iAd或AdMob实现这一点吗 我正在使用 ALSdk.shared()!.adService.loadNextAd(ALAdSize.sizeInterstitial(), andNotify: self) 加载广告 然后,一旦广告可用,我将使用以下方式显示广告: ALInterstitialAd.

在我的应用程序中,我使用tvOS的广告。我曾尝试使用AppLovin SDK来实现广告,但它显示了一个全屏广告

我想在我的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)
}

iAd不支持电视操作系统,AdMob也不支持电视操作系统,AppLovin仅支持电视操作系统上的全屏间隙广告。因此,到目前为止,横幅广告在电视上是不可能的。我也不认为它们会很快出现,因为横幅广告在电视上没有多大意义。

正如丹尼尔·斯托姆所说,横幅广告在电视上没有多大意义。但如果你坚持,你可以创建自己的横幅

例如,在视图控制器中:

@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
}
并在单击时启动应用商店

 [self.nativeAd launchClickTarget];

你应该提供代码来帮助其他人谢谢@ThomasTang,我将删除评论。AppLovin在2017年停止了对tvOS的支持。
 [self.nativeAd launchClickTarget];