[ios][admob] Check AdMob exists

This commit is contained in:
Elliot Hesp 2017-06-20 13:22:09 +01:00
parent 1ce252fbf3
commit 52d94763bb
13 changed files with 42 additions and 7 deletions

View File

@ -4,6 +4,7 @@
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
#import "GoogleMobileAds/GADBannerView.h"
#import "GoogleMobileAds/GADBannerViewDelegate.h"
@interface BannerComponent : UIView <GADBannerViewDelegate>
@ -21,7 +22,7 @@
@end
#else
@interface BannerComponent : NSObject <RCTBridgeModule> {
@interface BannerComponent : NSObject {
}
@end

View File

@ -4,6 +4,8 @@
@implementation BannerComponent
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
- (void)initBanner:(GADAdSize)adSize {
if (_requested) {
[_banner removeFromSuperview];
@ -82,4 +84,6 @@
[self sendEvent:@"onAdLeftApplication" payload:nil];
}
#endif
@end

View File

@ -9,7 +9,6 @@
@interface NativeExpressComponent : UIView <GADNativeExpressAdViewDelegate, GADVideoControllerDelegate>
@property GADNativeExpressAdView *banner;
//@property(nonatomic, weak) IBOutlet GADNativeExpressAdView *banner;
@property (nonatomic, assign) BOOL requested;
@property (nonatomic, copy) NSString *size;
@ -24,7 +23,7 @@
@end
#else
@interface NativeExpressComponent : NSObject <RCTBridgeModule> {
@interface NativeExpressComponent : NSObject {
}
@end

View File

@ -4,6 +4,8 @@
@implementation NativeExpressComponent
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
- (void)initBanner:(GADAdSize)adSize {
if (_requested) {
[_banner removeFromSuperview];
@ -115,4 +117,6 @@
}];
}
#endif
@end

View File

@ -23,7 +23,7 @@
@end
#else
@interface RNFirebaseAdMob : NSObject <RCTBridgeModule> {
@interface RNFirebaseAdMob : NSObject {
}
@end
#endif

View File

@ -1,4 +1,7 @@
#import "RNFirebaseAdMob.h"
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
#import "GoogleMobileAds/GADMobileAds.h"
#import "RNFirebaseAdMobInterstitial.h"
@ -202,3 +205,11 @@ RCT_EXPORT_METHOD(rewardedVideoShowAd:
}
@end
#else
@interface RNFirebaseAdMobRewardedVideo : NSObject <RCTBridgeModule> {
}
@end
#endif

View File

@ -5,6 +5,9 @@
RCT_EXPORT_MODULE();
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
@synthesize bridge = _bridge;
- (UIView *)view
@ -24,4 +27,6 @@ RCT_EXPORT_VIEW_PROPERTY(request, NSDictionary);
RCT_EXPORT_VIEW_PROPERTY(onBannerEvent, RCTBubblingEventBlock);
#endif
@end

View File

@ -25,7 +25,7 @@
@end
#else
@interface RNFirebaseAdMobInterstitial : NSObject <RCTBridgeModule> {
@interface RNFirebaseAdMobInterstitial : NSObject {
}
@end
#endif

View File

@ -2,6 +2,8 @@
@implementation RNFirebaseAdMobInterstitial
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
- (id)initWithProps:(NSString *)adUnit delegate:(RNFirebaseAdMob *)delegate {
self = [super init];
if (self) {
@ -56,4 +58,6 @@
[self sendJSEvent:@"onAdLeftApplication" payload:@{}];
}
#endif
@end

View File

@ -5,6 +5,8 @@
RCT_EXPORT_MODULE();
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
@synthesize bridge = _bridge;
- (UIView *)view
@ -25,4 +27,6 @@ RCT_EXPORT_VIEW_PROPERTY(video, NSDictionary);
RCT_EXPORT_VIEW_PROPERTY(onBannerEvent, RCTBubblingEventBlock);
#endif
@end

View File

@ -25,7 +25,7 @@
@end
#else
@interface RNFirebaseAdMobRewardedVideo : NSObject <RCTBridgeModule> {
@interface RNFirebaseAdMobRewardedVideo : NSObject {
}
@end
#endif

View File

@ -2,6 +2,8 @@
@implementation RNFirebaseAdMobRewardedVideo
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
- (id)initWithProps:(NSString *)adUnit delegate:(RNFirebaseAdMob *)delegate {
self = [super init];
if (self) {
@ -69,4 +71,6 @@
[self sendJSEvent:@"onAdFailedToLoad" payload:[RNFirebaseAdMob errorCodeToDictionary:error]];
}
#endif
@end

View File

@ -60,7 +60,6 @@ class AdMobComponent extends React.Component {
* @param nativeEvent
*/
onBannerEvent = ({ nativeEvent }) => {
console.log('EVENT', nativeEvent)
if (this.props[nativeEvent.type]) {
if (nativeEvent.type === 'onAdFailedToLoad') {
const { code, message } = nativeEvent.payload;