From 52d94763bb440df978b5ff4001e22d7d6ef06c01 Mon Sep 17 00:00:00 2001 From: Elliot Hesp Date: Tue, 20 Jun 2017 13:22:09 +0100 Subject: [PATCH] [ios][admob] Check AdMob exists --- ios/RNFirebase/admob/BannerComponent.h | 3 ++- ios/RNFirebase/admob/BannerComponent.m | 4 ++++ ios/RNFirebase/admob/NativeExpressComponent.h | 3 +-- ios/RNFirebase/admob/NativeExpressComponent.m | 4 ++++ ios/RNFirebase/admob/RNFirebaseAdMob.h | 2 +- ios/RNFirebase/admob/RNFirebaseAdMob.m | 11 +++++++++++ ios/RNFirebase/admob/RNFirebaseAdMobBannerManager.m | 5 +++++ ios/RNFirebase/admob/RNFirebaseAdMobInterstitial.h | 2 +- ios/RNFirebase/admob/RNFirebaseAdMobInterstitial.m | 4 ++++ .../admob/RNFirebaseAdMobNativeExpressManager.m | 4 ++++ ios/RNFirebase/admob/RNFirebaseAdMobRewardedVideo.h | 2 +- ios/RNFirebase/admob/RNFirebaseAdMobRewardedVideo.m | 4 ++++ lib/modules/admob/AdMobComponent.js | 1 - 13 files changed, 42 insertions(+), 7 deletions(-) diff --git a/ios/RNFirebase/admob/BannerComponent.h b/ios/RNFirebase/admob/BannerComponent.h index d9df7a0d..cb0e9489 100644 --- a/ios/RNFirebase/admob/BannerComponent.h +++ b/ios/RNFirebase/admob/BannerComponent.h @@ -4,6 +4,7 @@ #if __has_include() #import "GoogleMobileAds/GADBannerView.h" +#import "GoogleMobileAds/GADBannerViewDelegate.h" @interface BannerComponent : UIView @@ -21,7 +22,7 @@ @end #else -@interface BannerComponent : NSObject { +@interface BannerComponent : NSObject { } @end diff --git a/ios/RNFirebase/admob/BannerComponent.m b/ios/RNFirebase/admob/BannerComponent.m index b7c28c17..12e6b72d 100644 --- a/ios/RNFirebase/admob/BannerComponent.m +++ b/ios/RNFirebase/admob/BannerComponent.m @@ -4,6 +4,8 @@ @implementation BannerComponent +#if __has_include() + - (void)initBanner:(GADAdSize)adSize { if (_requested) { [_banner removeFromSuperview]; @@ -82,4 +84,6 @@ [self sendEvent:@"onAdLeftApplication" payload:nil]; } +#endif + @end \ No newline at end of file diff --git a/ios/RNFirebase/admob/NativeExpressComponent.h b/ios/RNFirebase/admob/NativeExpressComponent.h index 0e0b16eb..1b1302e7 100644 --- a/ios/RNFirebase/admob/NativeExpressComponent.h +++ b/ios/RNFirebase/admob/NativeExpressComponent.h @@ -9,7 +9,6 @@ @interface NativeExpressComponent : UIView @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 { +@interface NativeExpressComponent : NSObject { } @end diff --git a/ios/RNFirebase/admob/NativeExpressComponent.m b/ios/RNFirebase/admob/NativeExpressComponent.m index 03d80d3d..1d1c7ed1 100644 --- a/ios/RNFirebase/admob/NativeExpressComponent.m +++ b/ios/RNFirebase/admob/NativeExpressComponent.m @@ -4,6 +4,8 @@ @implementation NativeExpressComponent +#if __has_include() + - (void)initBanner:(GADAdSize)adSize { if (_requested) { [_banner removeFromSuperview]; @@ -115,4 +117,6 @@ }]; } +#endif + @end \ No newline at end of file diff --git a/ios/RNFirebase/admob/RNFirebaseAdMob.h b/ios/RNFirebase/admob/RNFirebaseAdMob.h index 6ac1f772..86817a19 100644 --- a/ios/RNFirebase/admob/RNFirebaseAdMob.h +++ b/ios/RNFirebase/admob/RNFirebaseAdMob.h @@ -23,7 +23,7 @@ @end #else -@interface RNFirebaseAdMob : NSObject { +@interface RNFirebaseAdMob : NSObject { } @end #endif diff --git a/ios/RNFirebase/admob/RNFirebaseAdMob.m b/ios/RNFirebase/admob/RNFirebaseAdMob.m index 04eaf119..d17add89 100644 --- a/ios/RNFirebase/admob/RNFirebaseAdMob.m +++ b/ios/RNFirebase/admob/RNFirebaseAdMob.m @@ -1,4 +1,7 @@ #import "RNFirebaseAdMob.h" + +#if __has_include() + #import "GoogleMobileAds/GADMobileAds.h" #import "RNFirebaseAdMobInterstitial.h" @@ -202,3 +205,11 @@ RCT_EXPORT_METHOD(rewardedVideoShowAd: } @end + +#else + +@interface RNFirebaseAdMobRewardedVideo : NSObject { +} +@end + +#endif \ No newline at end of file diff --git a/ios/RNFirebase/admob/RNFirebaseAdMobBannerManager.m b/ios/RNFirebase/admob/RNFirebaseAdMobBannerManager.m index 76946367..e295e090 100644 --- a/ios/RNFirebase/admob/RNFirebaseAdMobBannerManager.m +++ b/ios/RNFirebase/admob/RNFirebaseAdMobBannerManager.m @@ -5,6 +5,9 @@ RCT_EXPORT_MODULE(); +#if __has_include() + + @synthesize bridge = _bridge; - (UIView *)view @@ -24,4 +27,6 @@ RCT_EXPORT_VIEW_PROPERTY(request, NSDictionary); RCT_EXPORT_VIEW_PROPERTY(onBannerEvent, RCTBubblingEventBlock); +#endif + @end \ No newline at end of file diff --git a/ios/RNFirebase/admob/RNFirebaseAdMobInterstitial.h b/ios/RNFirebase/admob/RNFirebaseAdMobInterstitial.h index 9f6600e6..e8fa0863 100644 --- a/ios/RNFirebase/admob/RNFirebaseAdMobInterstitial.h +++ b/ios/RNFirebase/admob/RNFirebaseAdMobInterstitial.h @@ -25,7 +25,7 @@ @end #else -@interface RNFirebaseAdMobInterstitial : NSObject { +@interface RNFirebaseAdMobInterstitial : NSObject { } @end #endif diff --git a/ios/RNFirebase/admob/RNFirebaseAdMobInterstitial.m b/ios/RNFirebase/admob/RNFirebaseAdMobInterstitial.m index 3473bf08..0846632a 100644 --- a/ios/RNFirebase/admob/RNFirebaseAdMobInterstitial.m +++ b/ios/RNFirebase/admob/RNFirebaseAdMobInterstitial.m @@ -2,6 +2,8 @@ @implementation RNFirebaseAdMobInterstitial +#if __has_include() + - (id)initWithProps:(NSString *)adUnit delegate:(RNFirebaseAdMob *)delegate { self = [super init]; if (self) { @@ -56,4 +58,6 @@ [self sendJSEvent:@"onAdLeftApplication" payload:@{}]; } +#endif + @end diff --git a/ios/RNFirebase/admob/RNFirebaseAdMobNativeExpressManager.m b/ios/RNFirebase/admob/RNFirebaseAdMobNativeExpressManager.m index a428cfb7..d1f7ce4d 100644 --- a/ios/RNFirebase/admob/RNFirebaseAdMobNativeExpressManager.m +++ b/ios/RNFirebase/admob/RNFirebaseAdMobNativeExpressManager.m @@ -5,6 +5,8 @@ RCT_EXPORT_MODULE(); +#if __has_include() + @synthesize bridge = _bridge; - (UIView *)view @@ -25,4 +27,6 @@ RCT_EXPORT_VIEW_PROPERTY(video, NSDictionary); RCT_EXPORT_VIEW_PROPERTY(onBannerEvent, RCTBubblingEventBlock); +#endif + @end \ No newline at end of file diff --git a/ios/RNFirebase/admob/RNFirebaseAdMobRewardedVideo.h b/ios/RNFirebase/admob/RNFirebaseAdMobRewardedVideo.h index 39fae67c..1fd60155 100644 --- a/ios/RNFirebase/admob/RNFirebaseAdMobRewardedVideo.h +++ b/ios/RNFirebase/admob/RNFirebaseAdMobRewardedVideo.h @@ -25,7 +25,7 @@ @end #else -@interface RNFirebaseAdMobRewardedVideo : NSObject { +@interface RNFirebaseAdMobRewardedVideo : NSObject { } @end #endif diff --git a/ios/RNFirebase/admob/RNFirebaseAdMobRewardedVideo.m b/ios/RNFirebase/admob/RNFirebaseAdMobRewardedVideo.m index 9cc47f56..6c08ac09 100644 --- a/ios/RNFirebase/admob/RNFirebaseAdMobRewardedVideo.m +++ b/ios/RNFirebase/admob/RNFirebaseAdMobRewardedVideo.m @@ -2,6 +2,8 @@ @implementation RNFirebaseAdMobRewardedVideo +#if __has_include() + - (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 \ No newline at end of file diff --git a/lib/modules/admob/AdMobComponent.js b/lib/modules/admob/AdMobComponent.js index 8eea2e4a..2d53877b 100644 --- a/lib/modules/admob/AdMobComponent.js +++ b/lib/modules/admob/AdMobComponent.js @@ -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;