Я попытался проверить другие связанные вопросы, но безуспешно. Я следую коду примера, расположенному здесь. Программа успешно работает на моем iPhone, но когда я сначала вызываю рекламу, она зависает на self.interstitial = [[GADInterstitial alloc] init]; . Нет сообщения об ошибке, оно просто перестает работать с выделенной выше строкой. Я попытался запустить его в GameViewController и в моей реальной сцене набора спрайтов. Любая помощь будет оценена по достоинству. Образец проекта, который я скачал, работает отлично.
GameViewController.h
@property (strong,nonatomic) GADInterstitial *interstitial;
-(void)createAndLoadInterstitial;
-(void)loadAd;
GameViewController.m
- (void)createAndLoadInterstitial {
self.interstitial = [[GADInterstitial alloc] init];
self.interstitial.adUnitID = @"ca-app-pub-9726509502990875/8489925949";
self.interstitial.delegate = self;
GADRequest *request = [GADRequest request];
// Request test ads on devices you specify. Your test device ID is printed to the console when
// an ad request is made.
request.testDevices = @[ GAD_SIMULATOR_ID, @"MY_TEST_DEVICE_ID" ];
[self.interstitial loadRequest:request];
}
-(void)loadAd {
if (self.interstitial.isReady) {
[self.interstitial presentFromRootViewController:self];
} else {
[[[UIAlertView alloc] initWithTitle:@"Interstitial not ready"
message:@"The interstitial didn't finish loading or failed to load"
delegate:self
cancelButtonTitle:@"Drat"
otherButtonTitles:nil] show];
}
}
GameScene.h
@property (nonatomic, strong) GameViewController *GameViewController;
GameScene.m
//this is in -(void)gameOver which is called on contact call in -(void)didBeginContact
self.GameViewController = [[GameViewController alloc] init];
[self.GameViewController createAndLoadInterstitial];
[self.GameViewController loadAd];