2016-05-05 49 views
0

在我的應用程序中,我正在爲tvOS使用廣告。我曾嘗試使用AppLovin SDK進行廣告實施,但它顯示的是全屏廣告。如何在tvOS中集成橫幅廣告?

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

時,應提供代碼,以幫助其他幫助您 – TommyBs

回答

0

的iAd不支持tvOS和is being discontinued,AdMob不支持tvOS也和AppLovin只支持全屏插頁式廣告tvOS。所以,截至目前,橫幅廣告在tvOS上是不可能的。我不希望他們很快就能看到,因爲橫幅廣告在電視上沒什麼意義。

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的回調不guanranteed主隊列被調用。

這也是你的責任點擊

[self.nativeAd launchClickTarget]; 
+0

@armatita跟蹤你自己的印象

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

,並推出了應用程序商店:我已經更新我的回答相應。 –

+0

謝謝@ThomasTang,我將刪除評論評論。 – armatita