[ios][admob] Check AdMob exists
This commit is contained in:
parent
1ce252fbf3
commit
52d94763bb
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
|
@ -23,7 +23,7 @@
|
|||
@end
|
||||
|
||||
#else
|
||||
@interface RNFirebaseAdMob : NSObject <RCTBridgeModule> {
|
||||
@interface RNFirebaseAdMob : NSObject {
|
||||
}
|
||||
@end
|
||||
#endif
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -25,7 +25,7 @@
|
|||
@end
|
||||
|
||||
#else
|
||||
@interface RNFirebaseAdMobInterstitial : NSObject <RCTBridgeModule> {
|
||||
@interface RNFirebaseAdMobInterstitial : NSObject {
|
||||
}
|
||||
@end
|
||||
#endif
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -25,7 +25,7 @@
|
|||
@end
|
||||
|
||||
#else
|
||||
@interface RNFirebaseAdMobRewardedVideo : NSObject <RCTBridgeModule> {
|
||||
@interface RNFirebaseAdMobRewardedVideo : NSObject {
|
||||
}
|
||||
@end
|
||||
#endif
|
||||
|
|
|
@ -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
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue