[android] Support RN 0.47.0 breaking changes and align to REST API
This commit is contained in:
parent
79090f59a6
commit
d3912fbc3e
|
@ -141,14 +141,13 @@ public class RNFirebaseLinks extends ReactContextBaseJavaModule implements Activ
|
|||
Map<String, Object> m = Utils.recursivelyDeconstructReadableMap(parameters);
|
||||
|
||||
parametersBuilder.setLink(Uri.parse((String)m.get("link")));
|
||||
parametersBuilder.setDynamicLinkDomain((String)m.get("domain"));
|
||||
parametersBuilder.setDynamicLinkDomain((String)m.get("dynamicLinkDomain"));
|
||||
|
||||
setAndroidParameters(m, parametersBuilder);
|
||||
setIosParameters(m, parametersBuilder);
|
||||
//setNavigationInfoParameters(m, parametersBuilder);
|
||||
setSocialMetaTagParameters(m, parametersBuilder);
|
||||
setGoogleAnalyticsParameters(m, parametersBuilder);
|
||||
setItunesConnectAnalyticsParameters(m, parametersBuilder);
|
||||
setAnalyticsParameters(m, parametersBuilder);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "error while building parameters " + e.getMessage());
|
||||
|
@ -158,121 +157,129 @@ public class RNFirebaseLinks extends ReactContextBaseJavaModule implements Activ
|
|||
}
|
||||
|
||||
private void setAndroidParameters(final Map<String, Object> m, final DynamicLink.Builder parametersBuilder) {
|
||||
Map<String, Object> androidParameters = (Map<String, Object>) m.get("androidParameters");
|
||||
Map<String, Object> androidParameters = (Map<String, Object>) m.get("androidInfo");
|
||||
if (androidParameters != null) {
|
||||
DynamicLink.AndroidParameters.Builder androidParametersBuilder =
|
||||
androidParameters.containsKey("packageName") ?
|
||||
new DynamicLink.AndroidParameters.Builder((String)androidParameters.get("packageName")) :
|
||||
androidParameters.containsKey("androidPackageName") ?
|
||||
new DynamicLink.AndroidParameters.Builder((String)androidParameters.get("androidPackageName")) :
|
||||
new DynamicLink.AndroidParameters.Builder();
|
||||
|
||||
if (androidParameters.containsKey("fallbackUrl")) {
|
||||
androidParametersBuilder.setFallbackUrl(Uri.parse((String)androidParameters.get("fallbackUrl")));
|
||||
if (androidParameters.containsKey("androidFallbackLink")) {
|
||||
androidParametersBuilder.setFallbackUrl(Uri.parse((String)androidParameters.get("androidFallbackLink")));
|
||||
}
|
||||
if (androidParameters.containsKey("minimumVersion")) {
|
||||
androidParametersBuilder.setMinimumVersion(((Double)androidParameters.get("minimumVersion")).intValue());
|
||||
if (androidParameters.containsKey("androidMinPackageVersionCode")) {
|
||||
androidParametersBuilder.setMinimumVersion(((Double)androidParameters.get("androidMinPackageVersionCode")).intValue());
|
||||
}
|
||||
parametersBuilder.setAndroidParameters(androidParametersBuilder.build());
|
||||
}
|
||||
}
|
||||
|
||||
private void setIosParameters(final Map<String, Object> m, final DynamicLink.Builder parametersBuilder) {
|
||||
Map<String, Object> iosParameters = (Map<String, Object>) m.get("iosParameters");
|
||||
Map<String, Object> iosParameters = (Map<String, Object>) m.get("iosInfo");
|
||||
//TODO: see what happens if bundleId is missing
|
||||
if (iosParameters != null && iosParameters.containsKey("bundleId")) {
|
||||
DynamicLink.IosParameters.Builder iosParametersBuilder = new DynamicLink.IosParameters.Builder((String)iosParameters.get("bundleId"));
|
||||
if (iosParameters.containsKey("appStoreId")) {
|
||||
iosParametersBuilder.setAppStoreId((String)iosParameters.get("appStoreId"));
|
||||
if (iosParameters != null && iosParameters.containsKey("iosBundleId")) {
|
||||
DynamicLink.IosParameters.Builder iosParametersBuilder = new DynamicLink.IosParameters.Builder((String)iosParameters.get("iosBundleId"));
|
||||
if (iosParameters.containsKey("iosAppStoreId")) {
|
||||
iosParametersBuilder.setAppStoreId((String)iosParameters.get("iosAppStoreId"));
|
||||
}
|
||||
if (iosParameters.containsKey("customScheme")) {
|
||||
iosParametersBuilder.setCustomScheme((String)iosParameters.get("customScheme"));
|
||||
if (iosParameters.containsKey("iosCustomScheme")) {
|
||||
iosParametersBuilder.setCustomScheme((String)iosParameters.get("iosCustomScheme"));
|
||||
}
|
||||
if (iosParameters.containsKey("fallbackUrl")) {
|
||||
iosParametersBuilder.setFallbackUrl(Uri.parse((String)iosParameters.get("fallbackUrl")));
|
||||
if (iosParameters.containsKey("iosFallbackLink")) {
|
||||
iosParametersBuilder.setFallbackUrl(Uri.parse((String)iosParameters.get("iosFallbackLink")));
|
||||
}
|
||||
if (iosParameters.containsKey("ipadBundleId")) {
|
||||
iosParametersBuilder.setIpadBundleId((String)iosParameters.get("ipadBundleId"));
|
||||
if (iosParameters.containsKey("iosIpadBundleId")) {
|
||||
iosParametersBuilder.setIpadBundleId((String)iosParameters.get("iosIpadBundleId"));
|
||||
}
|
||||
if (iosParameters.containsKey("ipadFallbackUrl")) {
|
||||
iosParametersBuilder.setIpadFallbackUrl(Uri.parse((String)iosParameters.get("ipadFallbackUrl")));
|
||||
if (iosParameters.containsKey("iosIpadFallbackLink")) {
|
||||
iosParametersBuilder.setIpadFallbackUrl(Uri.parse((String)iosParameters.get("iosIpadFallbackLink")));
|
||||
}
|
||||
if (iosParameters.containsKey("minimumVersion")) {
|
||||
iosParametersBuilder.setMinimumVersion((String)iosParameters.get("minimumVersion"));
|
||||
if (iosParameters.containsKey("iosMinPackageVersionCode")) {
|
||||
iosParametersBuilder.setMinimumVersion((String)iosParameters.get("iosMinPackageVersionCode"));
|
||||
}
|
||||
parametersBuilder.setIosParameters(iosParametersBuilder.build());
|
||||
}
|
||||
}
|
||||
|
||||
// private void setNavigationInfoParameters(final Map<String, Object> m, final DynamicLink.Builder parametersBuilder) {
|
||||
// Map<String, Object> navigationInfoParameters = (Map<String, Object>) m.get("navigationInfoParameters");
|
||||
// Map<String, Object> navigationInfoParameters = (Map<String, Object>) m.get("navigationInfo");
|
||||
// if (navigationInfoParameters != null) {
|
||||
// DynamicLink.NavigationInfoParameters.Builder navigationInfoParametersBuilder =
|
||||
// new DynamicLink.NavigationInfoParameters.Builder();
|
||||
//
|
||||
// if (navigationInfoParameters.containsKey("forcedRedirectEnabled")) {
|
||||
// navigationInfoParametersBuilder.setForcedRedirectEnabled((boolean)navigationInfoParameters.get("forcedRedirectEnabled"));
|
||||
// if (navigationInfoParameters.containsKey("enableForcedRedirect")) {
|
||||
// navigationInfoParametersBuilder.setForcedRedirectEnabled((boolean)navigationInfoParameters.get("enableForcedRedirect"));
|
||||
// }
|
||||
// parametersBuilder.setNavigationInfoParameters(navigationInfoParametersBuilder.build());
|
||||
// }
|
||||
// }
|
||||
|
||||
private void setSocialMetaTagParameters(final Map<String, Object> m, final DynamicLink.Builder parametersBuilder) {
|
||||
Map<String, Object> socialMetaTagParameters = (Map<String, Object>) m.get("socialMetaTagParameters");
|
||||
Map<String, Object> socialMetaTagParameters = (Map<String, Object>) m.get("socialMetaTagInfo");
|
||||
if (socialMetaTagParameters != null) {
|
||||
DynamicLink.SocialMetaTagParameters.Builder socialMetaTagParametersBuilder =
|
||||
new DynamicLink.SocialMetaTagParameters.Builder();
|
||||
|
||||
if (socialMetaTagParameters.containsKey("description")) {
|
||||
socialMetaTagParametersBuilder.setDescription((String)socialMetaTagParameters.get("description"));
|
||||
if (socialMetaTagParameters.containsKey("socialDescription")) {
|
||||
socialMetaTagParametersBuilder.setDescription((String)socialMetaTagParameters.get("socialDescription"));
|
||||
}
|
||||
if (socialMetaTagParameters.containsKey("imageUrl")) {
|
||||
socialMetaTagParametersBuilder.setImageUrl(Uri.parse((String)socialMetaTagParameters.get("imageUrl")));
|
||||
if (socialMetaTagParameters.containsKey("socialImageLink")) {
|
||||
socialMetaTagParametersBuilder.setImageUrl(Uri.parse((String)socialMetaTagParameters.get("socialImageLink")));
|
||||
}
|
||||
if (socialMetaTagParameters.containsKey("title")) {
|
||||
socialMetaTagParametersBuilder.setTitle((String)socialMetaTagParameters.get("title"));
|
||||
if (socialMetaTagParameters.containsKey("socialTitle")) {
|
||||
socialMetaTagParametersBuilder.setTitle((String)socialMetaTagParameters.get("socialTitle"));
|
||||
}
|
||||
parametersBuilder.setSocialMetaTagParameters(socialMetaTagParametersBuilder.build());
|
||||
}
|
||||
}
|
||||
|
||||
private void setAnalyticsParameters (final Map<String, Object> m, final DynamicLink.Builder parametersBuilder) {
|
||||
Map<String, Object> analyticsParameters = (Map<String, Object>) m.get("analyticsInfo");
|
||||
if (analyticsParameters != null) {
|
||||
setGoogleAnalyticsParameters(analyticsParameters, parametersBuilder);
|
||||
setItunesConnectAnalyticsParameters(analyticsParameters, parametersBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
private void setGoogleAnalyticsParameters(final Map<String, Object> m, final DynamicLink.Builder parametersBuilder) {
|
||||
Map<String, Object> googleAnalyticsParameters = (Map<String, Object>) m.get("googleAnalyticsParameters");
|
||||
Map<String, Object> googleAnalyticsParameters = (Map<String, Object>) m.get("googlePlayAnalytics");
|
||||
if (googleAnalyticsParameters != null) {
|
||||
DynamicLink.GoogleAnalyticsParameters.Builder googleAnalyticsParametersBuilder =
|
||||
new DynamicLink.GoogleAnalyticsParameters.Builder();
|
||||
|
||||
if (googleAnalyticsParameters.containsKey("campaign")) {
|
||||
googleAnalyticsParametersBuilder.setCampaign((String)googleAnalyticsParameters.get("campaign"));
|
||||
if (googleAnalyticsParameters.containsKey("utmCampaign")) {
|
||||
googleAnalyticsParametersBuilder.setCampaign((String)googleAnalyticsParameters.get("utmCampaign"));
|
||||
}
|
||||
if (googleAnalyticsParameters.containsKey("content")) {
|
||||
googleAnalyticsParametersBuilder.setContent((String)googleAnalyticsParameters.get("content"));
|
||||
if (googleAnalyticsParameters.containsKey("utmContent")) {
|
||||
googleAnalyticsParametersBuilder.setContent((String)googleAnalyticsParameters.get("utmContent"));
|
||||
}
|
||||
if (googleAnalyticsParameters.containsKey("medium")) {
|
||||
googleAnalyticsParametersBuilder.setMedium((String)googleAnalyticsParameters.get("medium"));
|
||||
if (googleAnalyticsParameters.containsKey("utmMedium")) {
|
||||
googleAnalyticsParametersBuilder.setMedium((String)googleAnalyticsParameters.get("utmMedium"));
|
||||
}
|
||||
if (googleAnalyticsParameters.containsKey("source")) {
|
||||
googleAnalyticsParametersBuilder.setSource((String)googleAnalyticsParameters.get("source"));
|
||||
if (googleAnalyticsParameters.containsKey("utmSource")) {
|
||||
googleAnalyticsParametersBuilder.setSource((String)googleAnalyticsParameters.get("utmSource"));
|
||||
}
|
||||
if (googleAnalyticsParameters.containsKey("term")) {
|
||||
googleAnalyticsParametersBuilder.setTerm((String)googleAnalyticsParameters.get("term"));
|
||||
if (googleAnalyticsParameters.containsKey("utmTerm")) {
|
||||
googleAnalyticsParametersBuilder.setTerm((String)googleAnalyticsParameters.get("utmTerm"));
|
||||
}
|
||||
parametersBuilder.setGoogleAnalyticsParameters(googleAnalyticsParametersBuilder.build());
|
||||
}
|
||||
}
|
||||
|
||||
private void setItunesConnectAnalyticsParameters(final Map<String, Object> m, final DynamicLink.Builder parametersBuilder) {
|
||||
Map<String, Object> itunesConnectAnalyticsParameters = (Map<String, Object>) m.get("itunesConnectAnalyticsParameters");
|
||||
Map<String, Object> itunesConnectAnalyticsParameters = (Map<String, Object>) m.get("itunesConnectAnalytics");
|
||||
if (itunesConnectAnalyticsParameters != null) {
|
||||
DynamicLink.ItunesConnectAnalyticsParameters.Builder itunesConnectAnalyticsParametersBuilder =
|
||||
new DynamicLink.ItunesConnectAnalyticsParameters.Builder();
|
||||
|
||||
if (itunesConnectAnalyticsParameters.containsKey("affiliateToken")) {
|
||||
itunesConnectAnalyticsParametersBuilder.setAffiliateToken((String)itunesConnectAnalyticsParameters.get("affiliateToken"));
|
||||
if (itunesConnectAnalyticsParameters.containsKey("at")) {
|
||||
itunesConnectAnalyticsParametersBuilder.setAffiliateToken((String)itunesConnectAnalyticsParameters.get("at"));
|
||||
}
|
||||
if (itunesConnectAnalyticsParameters.containsKey("campaignToken")) {
|
||||
itunesConnectAnalyticsParametersBuilder.setCampaignToken((String)itunesConnectAnalyticsParameters.get("campaignToken"));
|
||||
if (itunesConnectAnalyticsParameters.containsKey("ct")) {
|
||||
itunesConnectAnalyticsParametersBuilder.setCampaignToken((String)itunesConnectAnalyticsParameters.get("ct"));
|
||||
}
|
||||
if (itunesConnectAnalyticsParameters.containsKey("providerToken")) {
|
||||
itunesConnectAnalyticsParametersBuilder.setProviderToken((String)itunesConnectAnalyticsParameters.get("providerToken"));
|
||||
if (itunesConnectAnalyticsParameters.containsKey("pt")) {
|
||||
itunesConnectAnalyticsParametersBuilder.setProviderToken((String)itunesConnectAnalyticsParameters.get("pt"));
|
||||
}
|
||||
parametersBuilder.setItunesConnectAnalyticsParameters(itunesConnectAnalyticsParametersBuilder.build());
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class RNFirebaseLinksPackage implements ReactPackage {
|
|||
* listed here. Also listing a native module here doesn't imply that the JS implementation of it
|
||||
* will be automatically included in the JS bundle.
|
||||
*/
|
||||
@Override
|
||||
// TODO: Removed in 0.47.0. Here for backwards compatability
|
||||
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
|
179
lib/firebase.js
179
lib/firebase.js
|
@ -2,106 +2,121 @@
|
|||
* @providesModule Firebase
|
||||
* @flow
|
||||
*/
|
||||
import { NativeModules } from 'react-native';
|
||||
import { NativeModules } from 'react-native'
|
||||
|
||||
import Log from './utils/log';
|
||||
import { isObject } from './utils';
|
||||
import Log from './utils/log'
|
||||
import { isObject } from './utils'
|
||||
|
||||
// modules
|
||||
import Auth, { statics as AuthStatics } from './modules/auth';
|
||||
import Storage, { statics as StorageStatics } from './modules/storage';
|
||||
import Database, { statics as DatabaseStatics } from './modules/database';
|
||||
import Messaging, { statics as MessagingStatics } from './modules/messaging';
|
||||
import Analytics from './modules/analytics';
|
||||
import Crash from './modules/crash';
|
||||
import RemoteConfig from './modules/config';
|
||||
import Performance from './modules/perf';
|
||||
import AdMob, { statics as AdMobStatics } from './modules/admob';
|
||||
import Links, { statis as LinksStatics } from './modules/links';
|
||||
import Auth, { statics as AuthStatics } from './modules/auth'
|
||||
import Storage, { statics as StorageStatics } from './modules/storage'
|
||||
import Database, { statics as DatabaseStatics } from './modules/database'
|
||||
import Messaging, { statics as MessagingStatics } from './modules/messaging'
|
||||
import Analytics from './modules/analytics'
|
||||
import Crash from './modules/crash'
|
||||
import RemoteConfig from './modules/config'
|
||||
import Performance from './modules/perf'
|
||||
import AdMob, { statics as AdMobStatics } from './modules/admob'
|
||||
import Links, { statics as LinksStatics } from './modules/links'
|
||||
|
||||
const instances: Object = { default: null };
|
||||
const FirebaseModule = NativeModules.RNFirebase;
|
||||
const instances: Object = { default: null }
|
||||
const FirebaseModule = NativeModules.RNFirebase
|
||||
|
||||
/**
|
||||
* @class Firebase
|
||||
*/
|
||||
export default class Firebase {
|
||||
_log: ?Object;
|
||||
_auth: ?Object;
|
||||
_store: ?Object;
|
||||
_storage: ?Object;
|
||||
_database: ?Object;
|
||||
_presence: ?Object;
|
||||
_analytics: ?Object;
|
||||
_constants: ?Object;
|
||||
_messaging: ?Object;
|
||||
_config: ?Object;
|
||||
_crash: ?Object;
|
||||
_perf: ?Object;
|
||||
_admob: ?Object;
|
||||
_links: ?Object;
|
||||
_log: ?Object
|
||||
_auth: ?Object
|
||||
_store: ?Object
|
||||
_storage: ?Object
|
||||
_database: ?Object
|
||||
_presence: ?Object
|
||||
_analytics: ?Object
|
||||
_constants: ?Object
|
||||
_messaging: ?Object
|
||||
_config: ?Object
|
||||
_crash: ?Object
|
||||
_perf: ?Object
|
||||
_admob: ?Object
|
||||
_links: ?Object
|
||||
|
||||
auth: Function;
|
||||
crash: Function;
|
||||
storage: Function;
|
||||
database: Function;
|
||||
analytics: Function;
|
||||
messaging: Function;
|
||||
config: Function;
|
||||
perf: Function;
|
||||
admob: Function;
|
||||
links: Function;
|
||||
auth: Function
|
||||
crash: Function
|
||||
storage: Function
|
||||
database: Function
|
||||
analytics: Function
|
||||
messaging: Function
|
||||
config: Function
|
||||
perf: Function
|
||||
admob: Function
|
||||
links: Function
|
||||
|
||||
eventHandlers: Object;
|
||||
debug: boolean;
|
||||
eventHandlers: Object
|
||||
debug: boolean
|
||||
options: {
|
||||
errorOnMissingPlayServices: boolean,
|
||||
debug?: boolean,
|
||||
persistence?: boolean
|
||||
};
|
||||
persistence?: boolean,
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param options
|
||||
*/
|
||||
constructor(options: Object = {}) {
|
||||
this.eventHandlers = {};
|
||||
this.debug = options.debug || false;
|
||||
this.options = Object.assign({ errorOnMissingPlayServices: true, promptOnMissingPlayServices: true }, options);
|
||||
this.eventHandlers = {}
|
||||
this.debug = options.debug || false
|
||||
this.options = Object.assign(
|
||||
{ errorOnMissingPlayServices: true, promptOnMissingPlayServices: true },
|
||||
options
|
||||
)
|
||||
|
||||
if (this.debug) {
|
||||
Log.enable(this.debug);
|
||||
Log.enable(this.debug)
|
||||
}
|
||||
|
||||
this._log = new Log('firebase');
|
||||
this._log = new Log('firebase')
|
||||
|
||||
if (!this.googleApiAvailability.isAvailable) {
|
||||
if (this.options.promptOnMissingPlayServices && this.googleApiAvailability.isUserResolvableError) {
|
||||
FirebaseModule.promptPlayServices();
|
||||
if (
|
||||
this.options.promptOnMissingPlayServices &&
|
||||
this.googleApiAvailability.isUserResolvableError
|
||||
) {
|
||||
FirebaseModule.promptPlayServices()
|
||||
} else {
|
||||
const error = `Google Play Services is required to run this application but no valid installation was found (Code ${this.googleApiAvailability.status}).`;
|
||||
const error = `Google Play Services is required to run this application but no valid installation was found (Code ${this
|
||||
.googleApiAvailability.status}).`
|
||||
if (this.options.errorOnMissingPlayServices) {
|
||||
throw new Error(error);
|
||||
throw new Error(error)
|
||||
} else {
|
||||
console.warn(error);
|
||||
console.warn(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.auth = this._staticsOrInstance('auth', AuthStatics, Auth);
|
||||
this.storage = this._staticsOrInstance('storage', StorageStatics, Storage);
|
||||
this.database = this._staticsOrInstance('database', DatabaseStatics, Database);
|
||||
this.messaging = this._staticsOrInstance('messaging', MessagingStatics, Messaging);
|
||||
this.analytics = this._staticsOrInstance('analytics', {}, Analytics);
|
||||
this.crash = this._staticsOrInstance('crash', {}, Crash);
|
||||
this.config = this._staticsOrInstance('config', {}, RemoteConfig);
|
||||
this.perf = this._staticsOrInstance('perf', {}, Performance);
|
||||
this.admob = this._staticsOrInstance('admob', AdMobStatics, AdMob);
|
||||
this.links = this._staticsOrInstance('links', LinksStatics, Links);
|
||||
this.auth = this._staticsOrInstance('auth', AuthStatics, Auth)
|
||||
this.storage = this._staticsOrInstance('storage', StorageStatics, Storage)
|
||||
this.database = this._staticsOrInstance(
|
||||
'database',
|
||||
DatabaseStatics,
|
||||
Database
|
||||
)
|
||||
this.messaging = this._staticsOrInstance(
|
||||
'messaging',
|
||||
MessagingStatics,
|
||||
Messaging
|
||||
)
|
||||
this.analytics = this._staticsOrInstance('analytics', {}, Analytics)
|
||||
this.crash = this._staticsOrInstance('crash', {}, Crash)
|
||||
this.config = this._staticsOrInstance('config', {}, RemoteConfig)
|
||||
this.perf = this._staticsOrInstance('perf', {}, Performance)
|
||||
this.admob = this._staticsOrInstance('admob', AdMobStatics, AdMob)
|
||||
this.links = this._staticsOrInstance('links', LinksStatics, Links)
|
||||
|
||||
// init auth to start listeners
|
||||
if (NativeModules.RNFirebaseAuth) {
|
||||
this.auth();
|
||||
this.auth()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,23 +128,29 @@ export default class Firebase {
|
|||
*/
|
||||
static initializeApp(options: Object = {}, name: string = 'default') {
|
||||
if (!isObject(options)) {
|
||||
throw new Error('Firebase.initializeApp(options <- requires a configuration object');
|
||||
throw new Error(
|
||||
'Firebase.initializeApp(options <- requires a configuration object'
|
||||
)
|
||||
}
|
||||
|
||||
if (typeof name !== 'string') {
|
||||
throw new Error('Firebase.initializeApp(options, name <- requires a string value');
|
||||
throw new Error(
|
||||
'Firebase.initializeApp(options, name <- requires a string value'
|
||||
)
|
||||
}
|
||||
|
||||
if (name !== 'default') {
|
||||
throw new Error('RNFirebase currently only supports one instance of firebase - the default one.');
|
||||
throw new Error(
|
||||
'RNFirebase currently only supports one instance of firebase - the default one.'
|
||||
)
|
||||
}
|
||||
|
||||
if (!instances[name]) instances[name] = new Firebase(options);
|
||||
return instances[name];
|
||||
if (!instances[name]) instances[name] = new Firebase(options)
|
||||
return instances[name]
|
||||
}
|
||||
|
||||
get apps(): Array<string> {
|
||||
return Object.keys(instances);
|
||||
return Object.keys(instances)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,14 +159,16 @@ export default class Firebase {
|
|||
*/
|
||||
get googleApiAvailability(): GoogleApiAvailabilityType {
|
||||
// if not available then return a fake object for ios - saves doing platform specific logic.
|
||||
return FirebaseModule.googleApiAvailability || { isAvailable: true, status: 0 };
|
||||
return (
|
||||
FirebaseModule.googleApiAvailability || { isAvailable: true, status: 0 }
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Logger
|
||||
*/
|
||||
get log(): Log {
|
||||
return this._log;
|
||||
return this._log
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,19 +181,19 @@ export default class Firebase {
|
|||
*/
|
||||
_staticsOrInstance(name, statics, InstanceClass): Function {
|
||||
const getInstance = () => {
|
||||
const internalPropName = `_${name}`;
|
||||
const internalPropName = `_${name}`
|
||||
|
||||
// $FlowFixMe
|
||||
if (!this[internalPropName]) {
|
||||
// $FlowFixMe
|
||||
this[internalPropName] = new InstanceClass(this);
|
||||
this[internalPropName] = new InstanceClass(this)
|
||||
}
|
||||
|
||||
// $FlowFixMe
|
||||
return this[internalPropName];
|
||||
};
|
||||
return this[internalPropName]
|
||||
}
|
||||
|
||||
Object.assign(getInstance, statics || {});
|
||||
return getInstance;
|
||||
Object.assign(getInstance, statics || {})
|
||||
return getInstance
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue