Skip to content

Commit

Permalink
#41 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
gumaciel committed Jan 12, 2021
1 parent 5bcaa36 commit fc0548a
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 44 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ data_*/

example/android
ios/admob/lib
.DS_Store
.DS_Store

*.o
*.d
4 changes: 2 additions & 2 deletions android/admob/admob/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.poing.admob">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.INTERNET"/>
<application>
<meta-data
android:name="org.godotengine.plugin.v1.AdMob"
android:value="com.poing.admob.AdMob" />
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/> <!--CHANGE FOR YOUR AdMob App ID-->
android:value="ca-app-pub-3940256099942544~3347511713"/>
</application>

</manifest>
11 changes: 8 additions & 3 deletions ios/admob/src/AdMob.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#ifndef ADMOB_H
#define ADMOB_H

#include "reference.h"
#include "object.h"



#ifdef __OBJC__
#include "AdMobBanner.h"
#include "AdMobInterstitial.h"
#include "AdMobRewarded.h"

@class AdMobBanner;
typedef AdMobBanner *bannerPtr;
@class AdMobInterstitial;
Expand All @@ -18,9 +23,9 @@ typedef void *rewardedPtr;
#endif


class AdMob : public Reference {
class AdMob : public Object {

GDCLASS(AdMob, Reference);
GDCLASS(AdMob, Object);

bool initialized;
static AdMob *instance;
Expand Down
14 changes: 4 additions & 10 deletions ios/admob/src/AdMob.mm
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
instance = this;
}

AdMob::~AdMob() {
if (initialized) {
[banner release]; //free banner
[interstitial release]; //free interstitial
[rewarded release]; //free rewarded
}

AdMob::~AdMob() {
if (instance == this) {
instance = NULL;
}
Expand Down Expand Up @@ -86,9 +80,9 @@
}

initialized = true;
banner = [[AdMobBanner alloc] initialize :instance_id: is_personalized];
interstitial = [[AdMobInterstitial alloc] initialize :instance_id : is_personalized];
rewarded = [[AdMobRewarded alloc] initialize :instance_id : is_personalized];
banner = [[AdMobBanner alloc] init :instance_id: is_personalized];
interstitial = [[AdMobInterstitial alloc] init :instance_id : is_personalized];
rewarded = [[AdMobRewarded alloc] init :instance_id : is_personalized];
}


Expand Down
8 changes: 7 additions & 1 deletion ios/admob/src/AdMobBanner.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#import <GoogleMobileAds/GADBannerView.h>
#import <GoogleMobileAds/GADExtras.h>
#import "app_delegate.h"
#import "view_controller.h"
#import "godot_view.h"
#include "reference.h"

@class AdMobBanner;

@interface AdMobBanner: NSObject <GADBannerViewDelegate> {
GADBannerView *bannerView;
Expand All @@ -11,8 +16,9 @@
NSString *adUnitId;
ViewController *rootController;
}
@property (nonatomic, strong) AdMobBanner *adMobBanner;

- (instancetype)initialize: (int) instance_id : (bool) is_personalized;
- (instancetype)init: (int) instance_id : (bool) is_personalized;
- (void)load_banner: (NSString*) ad_unit_id : (int) position : (NSString*) size;
- (void)destroy_banner;

Expand Down
15 changes: 7 additions & 8 deletions ios/admob/src/AdMobBanner.mm
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#import "AdMobBanner.h"
#include "reference.h"

@implementation AdMobBanner

- (void)dealloc {
bannerView.delegate = nil;
[bannerView release];
[super dealloc];
}

- (instancetype)initialize: (int)instance_id : (bool) is_personalized {
self = [super init];
if (self) {
- (instancetype)init: (int)instance_id : (bool) is_personalized {
NSLog(@"Initializing banner");
if ((self = [super init])) {
NSLog(@"Initializing banner2");
initialized = true;
instanceId = instance_id;
isPersonalized = is_personalized;
rootController = [AppDelegate getViewController];
rootController = (ViewController *)((AppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController;
NSLog(@"Initializing banner3");
}
return self;
}
Expand Down Expand Up @@ -65,7 +64,7 @@ - (void) load_banner:(NSString*)ad_unit_id :(int)position :(NSString*)size {
}

bannerView.adUnitID = ad_unit_id;

bannerView.delegate = self;
bannerView.rootViewController = rootController;

Expand Down
11 changes: 10 additions & 1 deletion ios/admob/src/AdMobInterstitial.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#import <GoogleMobileAds/GADInterstitial.h>
#import <GoogleMobileAds/GADExtras.h>
#import "app_delegate.h"
#import "view_controller.h"
#import "godot_view.h"
#include "reference.h"

@class AdMobInterstitial;


@interface AdMobInterstitial: NSObject <GADInterstitialDelegate> {
GADInterstitial *interstitial;
Expand All @@ -11,7 +17,10 @@
ViewController *rootController;
}

- (instancetype)initialize: (int) instance_id : (bool) is_personalized;
@property (nonatomic, strong) AdMobInterstitial *adMobInterstitial;


- (instancetype)init: (int) instance_id : (bool) is_personalized;
- (void)load_interstitial: (NSString*)ad_unit_id;
- (void)show_interstitial;

Expand Down
10 changes: 3 additions & 7 deletions ios/admob/src/AdMobInterstitial.mm
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
#import "AdMobInterstitial.h"
#include "reference.h"

@implementation AdMobInterstitial

- (void)dealloc {
interstitial.delegate = nil;
[interstitial release];
[super dealloc];
}

- (instancetype)initialize: (int)instance_id : (bool) is_personalized{
self = [super init];
if (self) {
- (instancetype)init: (int)instance_id : (bool) is_personalized{
if ((self = [super init])) {
initialized = true;
instanceId = instance_id;
isPersonalized = is_personalized;
rootController = [AppDelegate getViewController];
rootController = (ViewController *)((AppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController;
}
return self;
}
Expand Down
10 changes: 9 additions & 1 deletion ios/admob/src/AdMobRewarded.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#import <GoogleMobileAds/GADRewardedAd.h>
#import <GoogleMobileAds/GADExtras.h>
#import "app_delegate.h"
#import "view_controller.h"
#import "godot_view.h"
#include "reference.h"

@class AdMobRewarded;


@interface AdMobRewarded: NSObject <GADRewardedAdDelegate> {
GADRewardedAd *rewarded;
Expand All @@ -10,8 +16,10 @@
NSString *adUnitId;
ViewController *rootController;
}
@property (nonatomic, strong) AdMobRewarded *adMobRewarded;


- (instancetype)initialize: (int) instance_id: (bool) is_personalized;
- (instancetype)init: (int) instance_id: (bool) is_personalized;
- (void)load_rewarded: (NSString*) ad_unit_id;
- (void)show_rewarded;

Expand Down
13 changes: 3 additions & 10 deletions ios/admob/src/AdMobRewarded.mm
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
#import "AdMobRewarded.h"
#include "reference.h"

@implementation AdMobRewarded

- (void)dealloc {
[rewarded release];
[super dealloc];
}

- (instancetype)initialize:(int) instance_id : (bool) is_personalized{
self = [super init];
if (self) {
- (instancetype)init:(int) instance_id : (bool) is_personalized{
if ((self = [super init])) {
initialized = true;
instanceId = instance_id;
isPersonalized = is_personalized;
rootController = [AppDelegate getViewController];
rootController = (ViewController *)((AppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController;
}
return self;
}
Expand Down

0 comments on commit fc0548a

Please sign in to comment.