Merge remote-tracking branch 'origin/master'

This commit is contained in:
Salakar
2020-05-08 08:28:42 +01:00
9 changed files with 33 additions and 37 deletions

View File

@@ -38,7 +38,8 @@ module.exports = {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-ignore': 'warn',
// off for validation tests
'@typescript-eslint/ban-ts-ignore': 'off',
},
globals: {
__DEV__: true,

View File

@@ -65,19 +65,26 @@ console.log(firebase.apps);
## Switching app instance
You can switch app instances at any time whilst developing by calling the `app` method:
You can switch app instances at any time whilst developing by calling the `app` method with the name of the secondary app:
```js
import firebase from '@react-native-firebase/app';
import '@react-native-firebase/auth';
// Example using auth
firebase.app('SECONDARY_APP').auth().currentUser;
```
The `firebase` instance is also exported on modules for added convenience, for example:
Or pass the secondary app instance you created above directly to the desired module, for example:
```js
import auth, { firebase } from '@react-native-firebase/auth';
import firebase from '@react-native-firebase/app';
import auth from '@react-native-firebase/auth';
// create secondary app as described above
const secondaryApp = await firebase.initalizeApp(credentials, config);
// Example using auth with passing the secondary app instance
auth(secondaryApp).currentUser;
```
## Deleting instances

View File

@@ -1,6 +1,6 @@
---
title: Phone Authentication
description: Sign-in with users with their phone number.
description: Sign-in users with their phone number.
next: /firestore/usage
previous: /auth/social-auth
---

View File

@@ -26,6 +26,7 @@ jest.doMock('react-native', () => {
],
},
RNFBPerfModule: {},
RNFBCrashlyticsModule: {},
},
},
ReactNative,

View File

@@ -710,7 +710,7 @@ export namespace FirebaseAdMobTypes {
* });
* ```
*/
location?: string[];
location?: [number, number];
/**
* Sets the location accuracy if the location is set, in meters.

View File

@@ -0,0 +1,11 @@
import { firebase } from '../lib';
describe('Crashlytics', () => {
describe('namespace', () => {
it('accessible from firebase.app()', () => {
const app = firebase.app();
expect(app.crashlytics).toBeDefined();
expect(app.crashlytics().app).toEqual(app);
});
});
});

View File

@@ -16,14 +16,6 @@
*/
describe('crashlytics()', () => {
describe('namespace', () => {
it('accessible from firebase.app()', () => {
const app = firebase.app();
should.exist(app.crashlytics);
app.crashlytics().app.should.equal(app);
});
});
// Run locally only - flakey on CI
xdescribe('crash()', () => {
it('crashes the app', async () => {

View File

@@ -25,16 +25,12 @@ describe('Cloud Functions', () => {
describe('httpcallable()', () => {
it('throws an error with an incorrect timeout', () => {
try {
const app = firebase.app();
const app = firebase.app();
// @ts-ignore
app.functions().httpsCallable('example', { timeout: 'test' });
return Promise.reject(new Error('Did not throw'));
} catch (e) {
expect(e.message).toEqual('HttpsCallableOptions.timeout expected a Number in milliseconds');
return Promise.resolve();
}
// @ts-ignore
expect(() => app.functions().httpsCallable('example', { timeout: 'test' })).toThrow(
'HttpsCallableOptions.timeout expected a Number in milliseconds',
);
});
});
});

View File

@@ -198,20 +198,8 @@ class FirebaseMessagingModule extends FirebaseModule {
}
const subscription = this.emitter.addListener('messaging_token_refresh', event => {
// TODO remove after v7.0.0, see: https://github.com/invertase/react-native-firebase/issues/2889
const { token } = event;
const tokenStringWithTokenAccessor = String(token);
Object.defineProperty(tokenStringWithTokenAccessor, 'token', {
enumerable: false,
get() {
// eslint-disable-next-line no-console
console.warn(
'firebase.messaging().onTokenRefresh(event => event.token) is deprecated, use onTokenRefresh(token => token) or call getToken() instead',
);
return token;
},
});
listener(tokenStringWithTokenAccessor);
listener(token);
});
return () => subscription.remove();
}