VaultDesign VaultDesign - 2 years ago 271
Objective-C Question

Admob Interstitial Cocos2d Objective C

i'm searching on google but i only find the way to integrate the AdMob Banner View on my app in Cocos2d. Now I need to put the full screen AdMob interstitial and i don't find the way to do it :. Please Help me, how i can do it??

I'm not sure what source code i need to post... I would like to show the interstitial when the app startup and when there is the game over.

I already tried this

but it gave me some error.

Answer Source

In AppDelegate.h, add GADInterstitialDelegate

@interface AppController : NSObject <UIApplicationDelegate, CCDirectorDelegate, GADInterstitialDelegate>

#define App ((AppController *)[[UIApplication sharedApplication] delegate])

In AppDelegate.m

    GADInterstitial  *interstitial_ = [[GADInterstitial alloc] init];
    interstitial_.adUnitID = @"ca-app-pub-YOUR_ID";
    interstitial_.delegate = self;
    [interstitial_ loadRequest:[GADRequest request]];


- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial
    [interstitial presentFromRootViewController:[CCDirector sharedDirector]];

// In GameOver class, add #import "AppDelegate.h" then use below function

   [App showAdmobFullScreenAds];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download