[android][ios][js] Detect missing native module rather than using empty function

This commit is contained in:
Chris Bianca 2017-05-31 15:22:15 +01:00
parent dcd6321561
commit a1cff881e1
18 changed files with 87 additions and 105 deletions

View File

@ -7,5 +7,4 @@ RCT_EXPORT_METHOD(log:(NSString *)message) {
}
RCT_EXPORT_METHOD(nativeSDKMissing) {}
@end

View File

@ -34,7 +34,5 @@ RCT_EXPORT_METHOD(setSessionTimeoutDuration:(nonnull NSNumber *) milliseconds) {
#else
@implementation RNFirebaseAnalytics
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(nativeSDKMissing) {}
@end
#endif

View File

@ -729,7 +729,5 @@ RCT_EXPORT_METHOD(fetchProvidersForEmail:(NSString *)email resolver:(RCTPromiseR
#else
@implementation RNFirebaseAuth
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(nativeSDKMissing) {}
@end
#endif

View File

@ -23,7 +23,5 @@ RCT_EXPORT_METHOD(report:(NSString *) message) {
#else
@implementation RNFirebaseCrash
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(nativeSDKMissing) {}
@end
#endif

View File

@ -511,7 +511,5 @@ RCT_EXPORT_METHOD(goOnline) {
#else
@implementation RNFirebaseDatabase
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(nativeSDKMissing) {}
@end
#endif

View File

@ -420,7 +420,5 @@ RCT_EXPORT_METHOD(finishNotificationResponse: (NSString *)completionHandlerId) {
#else
@implementation RNFirebaseMessaging
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(nativeSDKMissing) {}
@end
#endif

View File

@ -49,7 +49,5 @@ RCT_EXPORT_METHOD(incrementCounter:
#else
@implementation RNFirebasePerformance
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(nativeSDKMissing) {}
@end
#endif

View File

@ -132,7 +132,5 @@ RCT_EXPORT_METHOD(setDefaultsFromResource:(NSString *)fileName) {
#else
@implementation RNFirebaseRemoteConfig
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(nativeSDKMissing) {}
@end
#endif

View File

@ -450,7 +450,5 @@ RCT_EXPORT_METHOD(putFile:(NSString *) path localPath:(NSString *)localPath meta
#else
@implementation RNFirebaseStorage
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(nativeSDKMissing) {}
@end
#endif

View File

@ -8,13 +8,13 @@ import Banner from './Banner';
import { Base } from './../base';
const FirebaseAdMob = NativeModules.RNFirebaseAdMob;
const FirebaseAdMobEvt = new NativeEventEmitter(FirebaseAdMob);
const FirebaseAdMobEvt = FirebaseAdMob && new NativeEventEmitter(FirebaseAdMob);
export default class Admob extends Base {
constructor() {
super();
if (FirebaseAdMob.nativeSDKMissing) {
if (!FirebaseAdMob) {
return nativeSDKMissing('admob');
}

View File

@ -23,7 +23,7 @@ const ReservedEventNames = [
export default class Analytics {
constructor() {
if (FirebaseAnalytics.nativeSDKMissing) {
if (!FirebaseAnalytics) {
return nativeSDKMissing('analytics');
}
}

View File

@ -13,7 +13,7 @@ import TwitterAuthProvider from './providers/Twitter';
import GithubAuthProvider from './providers/Github';
const FirebaseAuth = NativeModules.RNFirebaseAuth;
const FirebaseAuthEvt = new NativeEventEmitter(FirebaseAuth);
const FirebaseAuthEvt = FirebaseAuth && new NativeEventEmitter(FirebaseAuth);
export default class Auth extends Base {
_user: User | null;
@ -22,7 +22,7 @@ export default class Auth extends Base {
constructor(firebase: Object, options: Object = {}) {
super(firebase, options);
if (FirebaseAuth.nativeSDKMissing) {
if (!FirebaseAuth) {
return nativeSDKMissing('auth');
}

View File

@ -16,7 +16,7 @@ type RemoteConfigOptions = {}
export default class RemoteConfig extends Base {
constructor(firebase: Object, options: RemoteConfigOptions = {}) {
super(firebase, options);
if (FirebaseRemoteConfig.nativeSDKMissing) {
if (!FirebaseRemoteConfig) {
return nativeSDKMissing('remote config');
}

View File

@ -6,7 +6,7 @@ const FirebaseCrash = NativeModules.RNFirebaseCrash;
export default class Crash {
constructor() {
if (FirebaseCrash.nativeSDKMissing) {
if (!FirebaseCrash) {
return nativeSDKMissing('crash');
}
}

View File

@ -11,7 +11,7 @@ import TransactionHandler from './transaction';
import { promisify, nativeSDKMissing } from './../../utils';
const FirebaseDatabase = NativeModules.RNFirebaseDatabase;
const FirebaseDatabaseEvt = new NativeEventEmitter(FirebaseDatabase);
const FirebaseDatabaseEvt = FirebaseDatabase && new NativeEventEmitter(FirebaseDatabase);
/**
* @class Database
@ -19,7 +19,7 @@ const FirebaseDatabaseEvt = new NativeEventEmitter(FirebaseDatabase);
export default class Database extends Base {
constructor(firebase: Object, options: Object = {}) {
super(firebase, options);
if (FirebaseDatabase.nativeSDKMissing) {
if (!FirebaseDatabase) {
return nativeSDKMissing('database');
}

View File

@ -4,7 +4,7 @@ import { nativeSDKMissing } from './../../utils';
import RemoteMessage from './RemoteMessage';
const FirebaseMessaging = NativeModules.RNFirebaseMessaging;
const FirebaseMessagingEvt = new NativeEventEmitter(FirebaseMessaging);
const FirebaseMessagingEvt = FirebaseMessaging && new NativeEventEmitter(FirebaseMessaging);
const EVENT_TYPE = {
RefreshToken: 'messaging_token_refreshed',
@ -77,7 +77,7 @@ function finish(data) {
export default class Messaging extends Base {
constructor(firebase, options = {}) {
super(firebase, options);
if (FirebaseMessaging.nativeSDKMissing) {
if (!FirebaseMessaging) {
return nativeSDKMissing('messaging');
}

View File

@ -7,7 +7,7 @@ const FirebasePerformance = NativeModules.RNFirebasePerformance;
export default class PerformanceMonitoring {
constructor() {
if (FirebasePerformance.nativeSDKMissing) {
if (!FirebasePerformance) {
return nativeSDKMissing('perf');
}
}

View File

@ -6,7 +6,7 @@ import { nativeSDKMissing } from './../../utils';
import StorageRef from './reference';
const FirebaseStorage = NativeModules.RNFirebaseStorage;
const FirebaseStorageEvt = new NativeEventEmitter(FirebaseStorage);
const FirebaseStorageEvt = FirebaseStorage && new NativeEventEmitter(FirebaseStorage);
type StorageOptionsType = {
storageBucket?: ?string,
@ -20,7 +20,7 @@ export default class Storage extends Base {
*/
constructor(firebase: Object, options: StorageOptionsType = {}) {
super(firebase, options);
if (FirebaseStorage.nativeSDKMissing) {
if (!FirebaseStorage) {
return nativeSDKMissing('storage');
}
@ -160,4 +160,3 @@ export const statics = {
FILETYPE_DIRECTORY: FirebaseStorage.FILETYPE_DIRECTORY,
},
};