[ios][admob] Check AdMob exists
This commit is contained in:
parent
1ce252fbf3
commit
52d94763bb
|
@ -4,6 +4,7 @@
|
||||||
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
|
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
|
||||||
|
|
||||||
#import "GoogleMobileAds/GADBannerView.h"
|
#import "GoogleMobileAds/GADBannerView.h"
|
||||||
|
#import "GoogleMobileAds/GADBannerViewDelegate.h"
|
||||||
|
|
||||||
@interface BannerComponent : UIView <GADBannerViewDelegate>
|
@interface BannerComponent : UIView <GADBannerViewDelegate>
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@
|
||||||
@end
|
@end
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@interface BannerComponent : NSObject <RCTBridgeModule> {
|
@interface BannerComponent : NSObject {
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
@implementation BannerComponent
|
@implementation BannerComponent
|
||||||
|
|
||||||
|
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
|
||||||
|
|
||||||
- (void)initBanner:(GADAdSize)adSize {
|
- (void)initBanner:(GADAdSize)adSize {
|
||||||
if (_requested) {
|
if (_requested) {
|
||||||
[_banner removeFromSuperview];
|
[_banner removeFromSuperview];
|
||||||
|
@ -82,4 +84,6 @@
|
||||||
[self sendEvent:@"onAdLeftApplication" payload:nil];
|
[self sendEvent:@"onAdLeftApplication" payload:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
|
@ -9,7 +9,6 @@
|
||||||
@interface NativeExpressComponent : UIView <GADNativeExpressAdViewDelegate, GADVideoControllerDelegate>
|
@interface NativeExpressComponent : UIView <GADNativeExpressAdViewDelegate, GADVideoControllerDelegate>
|
||||||
|
|
||||||
@property GADNativeExpressAdView *banner;
|
@property GADNativeExpressAdView *banner;
|
||||||
//@property(nonatomic, weak) IBOutlet GADNativeExpressAdView *banner;
|
|
||||||
@property (nonatomic, assign) BOOL requested;
|
@property (nonatomic, assign) BOOL requested;
|
||||||
|
|
||||||
@property (nonatomic, copy) NSString *size;
|
@property (nonatomic, copy) NSString *size;
|
||||||
|
@ -24,7 +23,7 @@
|
||||||
@end
|
@end
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@interface NativeExpressComponent : NSObject <RCTBridgeModule> {
|
@interface NativeExpressComponent : NSObject {
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
@implementation NativeExpressComponent
|
@implementation NativeExpressComponent
|
||||||
|
|
||||||
|
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
|
||||||
|
|
||||||
- (void)initBanner:(GADAdSize)adSize {
|
- (void)initBanner:(GADAdSize)adSize {
|
||||||
if (_requested) {
|
if (_requested) {
|
||||||
[_banner removeFromSuperview];
|
[_banner removeFromSuperview];
|
||||||
|
@ -115,4 +117,6 @@
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
|
@ -23,7 +23,7 @@
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@interface RNFirebaseAdMob : NSObject <RCTBridgeModule> {
|
@interface RNFirebaseAdMob : NSObject {
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
#import "RNFirebaseAdMob.h"
|
#import "RNFirebaseAdMob.h"
|
||||||
|
|
||||||
|
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
|
||||||
|
|
||||||
#import "GoogleMobileAds/GADMobileAds.h"
|
#import "GoogleMobileAds/GADMobileAds.h"
|
||||||
|
|
||||||
#import "RNFirebaseAdMobInterstitial.h"
|
#import "RNFirebaseAdMobInterstitial.h"
|
||||||
|
@ -202,3 +205,11 @@ RCT_EXPORT_METHOD(rewardedVideoShowAd:
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
@interface RNFirebaseAdMobRewardedVideo : NSObject <RCTBridgeModule> {
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif
|
|
@ -5,6 +5,9 @@
|
||||||
|
|
||||||
RCT_EXPORT_MODULE();
|
RCT_EXPORT_MODULE();
|
||||||
|
|
||||||
|
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
|
||||||
|
|
||||||
|
|
||||||
@synthesize bridge = _bridge;
|
@synthesize bridge = _bridge;
|
||||||
|
|
||||||
- (UIView *)view
|
- (UIView *)view
|
||||||
|
@ -24,4 +27,6 @@ RCT_EXPORT_VIEW_PROPERTY(request, NSDictionary);
|
||||||
|
|
||||||
RCT_EXPORT_VIEW_PROPERTY(onBannerEvent, RCTBubblingEventBlock);
|
RCT_EXPORT_VIEW_PROPERTY(onBannerEvent, RCTBubblingEventBlock);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
|
@ -25,7 +25,7 @@
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@interface RNFirebaseAdMobInterstitial : NSObject <RCTBridgeModule> {
|
@interface RNFirebaseAdMobInterstitial : NSObject {
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
@implementation RNFirebaseAdMobInterstitial
|
@implementation RNFirebaseAdMobInterstitial
|
||||||
|
|
||||||
|
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
|
||||||
|
|
||||||
- (id)initWithProps:(NSString *)adUnit delegate:(RNFirebaseAdMob *)delegate {
|
- (id)initWithProps:(NSString *)adUnit delegate:(RNFirebaseAdMob *)delegate {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
|
@ -56,4 +58,6 @@
|
||||||
[self sendJSEvent:@"onAdLeftApplication" payload:@{}];
|
[self sendJSEvent:@"onAdLeftApplication" payload:@{}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
RCT_EXPORT_MODULE();
|
RCT_EXPORT_MODULE();
|
||||||
|
|
||||||
|
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
|
||||||
|
|
||||||
@synthesize bridge = _bridge;
|
@synthesize bridge = _bridge;
|
||||||
|
|
||||||
- (UIView *)view
|
- (UIView *)view
|
||||||
|
@ -25,4 +27,6 @@ RCT_EXPORT_VIEW_PROPERTY(video, NSDictionary);
|
||||||
|
|
||||||
RCT_EXPORT_VIEW_PROPERTY(onBannerEvent, RCTBubblingEventBlock);
|
RCT_EXPORT_VIEW_PROPERTY(onBannerEvent, RCTBubblingEventBlock);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
|
@ -25,7 +25,7 @@
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@interface RNFirebaseAdMobRewardedVideo : NSObject <RCTBridgeModule> {
|
@interface RNFirebaseAdMobRewardedVideo : NSObject {
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
@implementation RNFirebaseAdMobRewardedVideo
|
@implementation RNFirebaseAdMobRewardedVideo
|
||||||
|
|
||||||
|
#if __has_include(<GoogleMobileAds/GADMobileAds.h>)
|
||||||
|
|
||||||
- (id)initWithProps:(NSString *)adUnit delegate:(RNFirebaseAdMob *)delegate {
|
- (id)initWithProps:(NSString *)adUnit delegate:(RNFirebaseAdMob *)delegate {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
|
@ -69,4 +71,6 @@
|
||||||
[self sendJSEvent:@"onAdFailedToLoad" payload:[RNFirebaseAdMob errorCodeToDictionary:error]];
|
[self sendJSEvent:@"onAdFailedToLoad" payload:[RNFirebaseAdMob errorCodeToDictionary:error]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
|
@ -60,7 +60,6 @@ class AdMobComponent extends React.Component {
|
||||||
* @param nativeEvent
|
* @param nativeEvent
|
||||||
*/
|
*/
|
||||||
onBannerEvent = ({ nativeEvent }) => {
|
onBannerEvent = ({ nativeEvent }) => {
|
||||||
console.log('EVENT', nativeEvent)
|
|
||||||
if (this.props[nativeEvent.type]) {
|
if (this.props[nativeEvent.type]) {
|
||||||
if (nativeEvent.type === 'onAdFailedToLoad') {
|
if (nativeEvent.type === 'onAdFailedToLoad') {
|
||||||
const { code, message } = nativeEvent.payload;
|
const { code, message } = nativeEvent.payload;
|
||||||
|
|
Loading…
Reference in New Issue