3

我正在开发我的应用程序,该应用程序是使用 Sprite Kit 构建的。我尝试添加加载广告的功能,但未加载广告。我不确定这是否是因为我的应用程序还没有上线,我需要打开某种“沙盒”,或者我是否做错了什么。广告的展示点是从 中调用的SKScene,广告展示的函数和方法(加载、展示以及委托)在父级中UIViewController

以下是将应用程序定向到ViewControllerfrom 的代码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没有被调用,我也没有收到任何错误。

4

2 回答 2

1

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

于 2016-07-13T20:16:08.897 回答
0

添加FBInterstitialAdDelegate到您的GameViewController界面。

于 2016-01-07T14:01:59.973 回答