Facebook受众网络插页式广告没有显示

时间:2015-09-29 17:18:44

标签: objective-c facebook-sdk-4.x facebook-audience-network

我正在使用我的应用程序,它是使用Sprite Kit构建的。我尝试添加加载广告的功能,但广告未加载。我不确定这是因为我的应用程序尚未生效,我需要打开某种沙盒,或者我是否做错了什么。广告的显示点是从SKScene调用的,广告显示功能和方法(加载,显示以及委托)位于父UIViewController中。

以下是将应用从ViewController引导至SKScene的代码:

GameViewController *vc = (GameViewController*)self.view.window.rootViewController;
[vc loadInterstitial];

GameViewControllerSKScene的父视图控制器。以下是GameViewController中包含的代码:

- (void)loadInterstitial
{
    self.interstitialAd =
    [[FBInterstitialAd alloc] initWithPlacementID:@"Placement ID"];
    self.interstitialAd.delegate = self;
    [self.interstitialAd loadAd];
}

- (void)interstitialAdDidLoad:(FBInterstitialAd *)interstitialAd
{
    NSLog(@"Interstitial ad is loaded and ready to be displayed");

    // You can now display the full screen ad using this code:
    [interstitialAd showAdFromRootViewController:self];
}

- (void)interstitialAd:(FBInterstitialAd *)interstitialAd
      didFailWithError:(NSError *)error
{
    NSLog(@"Interstitial ad is failed to load with error: %@", error);
}

方法interstitialAdDidLoad未被调用,我也没有收到任何错误。

2 个答案:

答案 0 :(得分:1)

当我在loadInterstitial方法中声明FBInterstitialAd实例时,我遇到了没有显示插页式广告的问题。在方法之外移动声明之后,它神奇地起作用了。请在此处查看Facebook Audience网络示例:https://github.com/fbsamples/audience-network-support

答案 1 :(得分:0)

FBInterstitialAdDelegate添加到您的GameViewController界面。