I am working on my app, which is built using Sprite Kit. I tried to add the function to load the ad, but the ad is not loading. I am not sure whether this is because my app is not live yet, and I need to turn on some sort of 'sandboxing', or whether I am doing something wrong. The point of display of the ad is called from an SKScene
, and the ad display functions and methods (the loading, displaying, as well as the delegate) is in the parent UIViewController
.
Below is the code for directing the app to the ViewController
from the SKScene
:
GameViewController *vc = (GameViewController*)self.view.window.rootViewController;
[vc loadInterstitial];
GameViewController
is the parent view controller of the SKScene
. Below is the code contained in the 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);
}
The method interstitialAdDidLoad
is not being called, nor am I receiving any errors.