Merge branch 'master' into fcm-rewrite
# Conflicts: # lib/modules/messaging/index.js # lib/types/index.js # tests/ios/Podfile.lock
This commit is contained in:
commit
804a8e4c65
30
.flowconfig
30
.flowconfig
|
@ -3,7 +3,7 @@
|
|||
.*/*[.]android.js
|
||||
|
||||
; Ignore "BUCK" generated dirs
|
||||
.*/node_modules/react-native/\.buckd/
|
||||
<PROJECT_ROOT>/\.buckd/
|
||||
|
||||
; Ignore unexpected extra "@providesModule"
|
||||
.*/node_modules/.*/node_modules/fbjs/.*
|
||||
|
@ -16,22 +16,8 @@
|
|||
; Ignore polyfills
|
||||
.*/Libraries/polyfills/.*
|
||||
|
||||
# React Native problems
|
||||
.*/node_modules/metro-bundler/src/DeltaBundler/DeltaCalculator.js.flow
|
||||
.*/node_modules/metro-bundler/src/DeltaBundler/DeltaPatcher.js.flow
|
||||
.*/node_modules/metro-bundler/src/node-haste/AssetResolutionCache.js.flow
|
||||
.*/node_modules/metro-bundler/src/node-haste/DependencyGraph.js.flow
|
||||
#.*/node_modules/react-native/Libraries/Animated/src/nodes/AnimatedStyle.js
|
||||
#.*/node_modules/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js
|
||||
#.*/node_modules/react-native/Libraries/Experimental/SwipeableRow/SwipeableFlatList.js
|
||||
#.*/node_modules/react-native/Libraries/Experimental/SwipeableRow/SwipeableListView.js
|
||||
#.*/node_modules/react-native/Libraries/Image/ImageBackground.js
|
||||
#.*/node_modules/react-native/Libraries/Lists/FlatList.js
|
||||
#.*/node_modules/react-native/Libraries/Lists/MetroListView.js
|
||||
#.*/node_modules/react-native/Libraries/Lists/SectionList.js
|
||||
#.*/node_modules/react-native/Libraries/Lists/ViewabilityHelper.js
|
||||
#.*/node_modules/react-native/Libraries/Lists/VirtualizedList.js
|
||||
#.*/node_modules/react-native/Libraries/Lists/VirtualizedSectionList.js
|
||||
; Ignore metro
|
||||
.*/node_modules/metro/.*
|
||||
|
||||
# Ignore dist folder
|
||||
.*/dist/.*
|
||||
|
@ -44,12 +30,13 @@
|
|||
[libs]
|
||||
node_modules/react-native/Libraries/react-native/react-native-interface.js
|
||||
node_modules/react-native/flow/
|
||||
node_modules/react-native/flow-github/
|
||||
|
||||
[options]
|
||||
module.system=haste
|
||||
|
||||
emoji=true
|
||||
|
||||
module.system=haste
|
||||
|
||||
munge_underscores=true
|
||||
|
||||
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
|
||||
|
@ -63,10 +50,9 @@ suppress_type=$FlowIssue
|
|||
suppress_type=$FlowFixMe
|
||||
suppress_type=$FlowFixMeProps
|
||||
suppress_type=$FlowFixMeState
|
||||
suppress_type=$FixMe
|
||||
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-6]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-6]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowBug.*
|
||||
|
|
|
@ -5,7 +5,7 @@ The issue list of this repo is exclusively for bug reports.
|
|||
|
||||
1) For feature requests, please use our Canny board: https://react-native-firebase.canny.io/feature-requests
|
||||
|
||||
2) For questions and support please use our Discord chat: https://discord.gg/t6bdqMs or Stack Overflow: https://stackoverflow.com/questions/tagged/react-native-firebase
|
||||
2) For questions and support please use our Discord chat: https://discord.gg/C9aK28N or Stack Overflow: https://stackoverflow.com/questions/tagged/react-native-firebase
|
||||
|
||||
3) If this is a setup issue then please make sure you've correctly followed the setup guides, most setup issues such as 'duplicate dex files', 'default app has not been initialized' etc are all down to an incorrect setup as the guides haven't been correctly followed.
|
||||
-->
|
||||
|
@ -14,26 +14,30 @@ The issue list of this repo is exclusively for bug reports.
|
|||
|
||||
<!--- Please write your issue here, provide as much detail as you can, code snippets, key files which will help us to debug such as your `Podfile` and/or `app/build.gradle` file). -->
|
||||
|
||||
|
||||
|
||||
### Environment
|
||||
|
||||
<!--- (e.g. iOS, Android, Both) --->
|
||||
|
||||
1. Application Target Platform:
|
||||
|
||||
<!--- (e.g. macOS Sierra, Windows 10) --->
|
||||
|
||||
2. Development Operating System:
|
||||
|
||||
<!--- (Xcode or Android Studio version, iOS or Android SDK version - if relevant) --->
|
||||
|
||||
3. Build Tools:
|
||||
|
||||
<!--- (e.g. 0.45.1) --->
|
||||
|
||||
4. React Native version:
|
||||
|
||||
<!--- (e.g. 2.1.3) --->
|
||||
|
||||
5. RNFirebase Version:
|
||||
|
||||
<!--- (e.g. database, auth, messaging, analytics etc - or N/A if not applicable) --->
|
||||
|
||||
6. Firebase Module:
|
||||
|
||||
<!-- Love react-native-firebase? Please consider supporting our collective:
|
||||
|
|
|
@ -5,15 +5,16 @@
|
|||
First, thank you for considering contributing to react-native-firebase! It's people like you that make the open source community such a great community! 😊
|
||||
|
||||
We welcome any type of contribution, not only code. You can help with
|
||||
- **QA**: file bug reports, the more details you can give the better (e.g. screenshots with the console open)
|
||||
- **Marketing**: writing blog posts, howto's, printing stickers, ...
|
||||
- **Community**: presenting the project at meetups, organizing a dedicated meetup for the local community, ...
|
||||
- **Code**: take a look at the [open issues](issues). Even if you can't write code, commenting on them, showing that you care about a given issue matters. It helps us triage them.
|
||||
- **Money**: we welcome financial contributions in full transparency on our [open collective](https://opencollective.com/react-native-firebase).
|
||||
|
||||
* **QA**: file bug reports, the more details you can give the better (e.g. screenshots with the console open)
|
||||
* **Marketing**: writing blog posts, howto's, printing stickers, ...
|
||||
* **Community**: presenting the project at meetups, organizing a dedicated meetup for the local community, ...
|
||||
* **Code**: take a look at the [open issues](issues). Even if you can't write code, commenting on them, showing that you care about a given issue matters. It helps us triage them.
|
||||
* **Money**: we welcome financial contributions in full transparency on our [open collective](https://opencollective.com/react-native-firebase).
|
||||
|
||||
## Your First Contribution
|
||||
|
||||
Working on your first Pull Request? You can learn how from this *free* series, [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
|
||||
Working on your first Pull Request? You can learn how from this _free_ series, [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
|
||||
|
||||
## Submitting code
|
||||
|
||||
|
@ -41,14 +42,12 @@ You can also reach us at oss@invertase.io
|
|||
Thank you to all the people who have already contributed to react-native-firebase!
|
||||
<a href="graphs/contributors"><img src="https://opencollective.com/react-native-firebase/contributors.svg?width=890" /></a>
|
||||
|
||||
|
||||
### Backers
|
||||
|
||||
Thank you to all our backers! [[Become a backer](https://opencollective.com/react-native-firebase#backer)]
|
||||
|
||||
<a href="https://opencollective.com/react-native-firebase#backers" target="_blank"><img src="https://opencollective.com/react-native-firebase/backers.svg?width=890"></a>
|
||||
|
||||
|
||||
### Sponsors
|
||||
|
||||
Thank you to all our sponsors! (please ask your company to also support this open source project by [becoming a sponsor](https://opencollective.com/react-native-firebase#sponsor))
|
||||
|
|
15
README.md
15
README.md
|
@ -11,7 +11,7 @@
|
|||
<a href="/LICENSE"><img src="https://img.shields.io/npm/l/react-native-firebase.svg?style=flat-square" alt="License"></a>
|
||||
<a href="#backers"><img src="https://opencollective.com/react-native-firebase/backers/badge.svg" alt="Backers on Open Collective"></a>
|
||||
<a href="#sponsors"><img src="https://opencollective.com/react-native-firebase/sponsors/badge.svg" alt="Sponsors on Open Collective"></a>
|
||||
<a href="https://discord.gg/t6bdqMs"><img src="https://img.shields.io/badge/chat-on%20discord-7289da.svg?style=flat-square" alt="Chat"></a>
|
||||
<a href="https://discord.gg/C9aK28N"><img src="https://img.shields.io/discord/295953187817521152.svg?logo=discord&style=flat-square&colorA=7289da&label=discord" alt="Chat"></a>
|
||||
<a href="https://twitter.com/rnfirebase"><img src="https://img.shields.io/twitter/follow/rnfirebase.svg?style=social&label=Follow" alt="Follow on Twitter"></a>
|
||||
</p>
|
||||
|
||||
|
@ -30,13 +30,13 @@ All in all, RNFirebase provides much faster performance (~2x) over the web SDK a
|
|||
---
|
||||
|
||||
## Supported Firebase Features
|
||||
> The Web SDK column indicates what modules/functionality from the Web SDK are usable within React Native.
|
||||
|
||||
> The Web SDK column indicates what modules/functionality from the Web SDK are usable within React Native.
|
||||
|
||||
> '**?**' indicates partial support
|
||||
|
||||
| Firebase Features | v1.x.x | v2.x.x | v3.x.x | v3.1.x | v3.2.x | Web SDK |
|
||||
| ---------------------- | :---: | :---: | :---: | :---: | :---: | :---: |
|
||||
| -------------------------- | :----: | :----: | :----: | :----: | :----: | :-----: |
|
||||
| **AdMob** | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
||||
| **Analytics** | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
||||
| **App Indexing** | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||
|
@ -58,12 +58,13 @@ All in all, RNFirebase provides much faster performance (~2x) over the web SDK a
|
|||
| **Storage** | ✅ | ✅ | ✅ | ✅ | ✅ | **?** |
|
||||
|
||||
---
|
||||
|
||||
### Supported versions - React Native / Firebase
|
||||
|
||||
> The table below shows the supported versions of React Native and the Firebase SDKs for different versions of `react-native-firebase`
|
||||
|
||||
| | 1.X.X | 2.0.X | 2.1.X / 2.2.X | 3.0.X | 3.1.X | 3.2.X |
|
||||
|------------------------|-------------|-------------|-----------------|----------|-------------|----------|
|
||||
| -------------------- | ----------- | ----------- | ------------- | -------- | ----------- | -------- |
|
||||
| React Native | 0.36 - 0.39 | 0.40 - 0.46 | 0.47 + | 0.48 + | 0.48 - 0.49 | 0.50 + |
|
||||
| Firebase Android SDK | 10.2.0 + | 11.0.0 + | 11.0.0 + | 11.4.2 + | 11.6.0 + | 11.6.2 + |
|
||||
| Firebase iOS SDK | 3.15.0 + | 4.0.0 + | 4.0.0 + | 4.3.0 + | 4.5.0 + | 4.7.0 + |
|
||||
|
@ -76,7 +77,7 @@ To check out our latest docs, visit [rnfirebase.io](https://rnfirebase.io)
|
|||
|
||||
## Questions
|
||||
|
||||
For questions and support please use our [Discord chat](https://discord.gg/t6bdqMs) or [Stack Overflow](https://stackoverflow.com/questions/tagged/react-native-firebase). The issue list of this repo is **exclusively** for bug reports.
|
||||
For questions and support please use our [Discord chat](https://discord.gg/C9aK28N) or [Stack Overflow](https://stackoverflow.com/questions/tagged/react-native-firebase). The issue list of this repo is **exclusively** for bug reports.
|
||||
|
||||
## Issues
|
||||
|
||||
|
@ -96,7 +97,7 @@ Detailed changes for each release are documented in the [releases notes](https:/
|
|||
|
||||
RNFirebase is an Apache-2.0 licensed open source project. It's an independent project with its ongoing development made possible entirely thanks to the support by these awesome [sponsors](#sponsors) and [backers](#backers). If you'd like to join them, please consider:
|
||||
|
||||
- [Become a backer or sponsor on Open Collective](https://opencollective.com/react-native-firebase).
|
||||
* [Become a backer or sponsor on Open Collective](https://opencollective.com/react-native-firebase).
|
||||
|
||||
### Sponsors
|
||||
|
||||
|
@ -131,4 +132,4 @@ Thank you to all the people who have already contributed to RNFirebase!
|
|||
|
||||
## License
|
||||
|
||||
- See [LICENSE](/LICENSE)
|
||||
* See [LICENSE](/LICENSE)
|
||||
|
|
|
@ -3,7 +3,5 @@
|
|||
"allowJs": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
"exclude": ["node_modules"]
|
||||
}
|
|
@ -5,88 +5,77 @@
|
|||
|
||||
declare module "react-native-firebase" {
|
||||
|
||||
type AuthProvider = {
|
||||
PROVIDER_ID: string,
|
||||
credential: (token: string, secret?: string) => AuthCredential,
|
||||
/** 3rd party provider Credentials */
|
||||
type AuthCredential = {
|
||||
providerId: string,
|
||||
token: string,
|
||||
secret: string
|
||||
}
|
||||
|
||||
type FirebaseModuleAndStatics<M, S = {}> = {
|
||||
(): M;
|
||||
nativeModuleExists: boolean;
|
||||
} & S
|
||||
|
||||
// Modules commented-out do not currently have type definitions
|
||||
export class Firebase {
|
||||
private constructor();
|
||||
// admob: FirebaseModuleAndStatics<RNFirebase.admob.AdMob>;
|
||||
analytics: FirebaseModuleAndStatics<RNFirebase.Analytics>;
|
||||
auth: FirebaseModuleAndStatics<RNFirebase.auth.Auth, RNFirebase.auth.AuthStatics>;
|
||||
// config: FirebaseModule<RNFirebase.config.Config>;
|
||||
crash: FirebaseModuleAndStatics<RNFirebase.crash.Crash>;
|
||||
database: FirebaseModuleAndStatics<RNFirebase.database.Database, RNFirebase.database.DatabaseStatics>;
|
||||
fabric: {
|
||||
crashlytics: FirebaseModuleAndStatics<RNFirebase.crashlytics.Crashlytics>;
|
||||
};
|
||||
firestore: FirebaseModuleAndStatics<RNFirebase.firestore.Firestore, RNFirebase.firestore.FirestoreStatics>;
|
||||
links: FirebaseModuleAndStatics<RNFirebase.links.Links>;
|
||||
messaging: FirebaseModuleAndStatics<RNFirebase.messaging.Messaging>;
|
||||
// perf: FirebaseModuleAndStatics<RNFirebase.perf.Perf>;
|
||||
storage: FirebaseModuleAndStatics<RNFirebase.storage.Storage>;
|
||||
// utils: FirebaseModuleAndStatics<RNFirebase.utils.Utils>;
|
||||
initializeApp(options: Firebase.Options, name: string): App;
|
||||
app(name?: string): App;
|
||||
readonly apps: App[];
|
||||
readonly SDK_VERSION: string;
|
||||
}
|
||||
namespace Firebase {
|
||||
interface Options {
|
||||
apiKey: string;
|
||||
appId: string;
|
||||
databaseURL: string;
|
||||
messagingSenderId: string;
|
||||
projectId: string;
|
||||
storageBucket: string;
|
||||
}
|
||||
}
|
||||
const firebase: Firebase;
|
||||
export default firebase;
|
||||
|
||||
export default class FireBase {
|
||||
constructor(config?: RNFirebase.configurationOptions)
|
||||
|
||||
log: any;
|
||||
|
||||
// Modules commented-out do not currently have type definitions
|
||||
export class App {
|
||||
private constructor();
|
||||
// admob(): RNFirebase.admob.AdMob;
|
||||
analytics(): RNFirebase.Analytics;
|
||||
|
||||
on(type: string, handler: (msg: any) => void): any;
|
||||
|
||||
database: {
|
||||
(): RNFirebase.database.Database
|
||||
ServerValue: {
|
||||
TIMESTAMP: number
|
||||
}
|
||||
};
|
||||
|
||||
auth: {
|
||||
(): RNFirebase.auth.Auth
|
||||
EmailAuthProvider: AuthProvider,
|
||||
PhoneAuthProvider: AuthProvider,
|
||||
GoogleAuthProvider: AuthProvider,
|
||||
GithubAuthProvider: AuthProvider,
|
||||
TwitterAuthProvider: AuthProvider,
|
||||
FacebookAuthProvider: AuthProvider,
|
||||
PhoneAuthState: {
|
||||
CODE_SENT: string,
|
||||
AUTO_VERIFY_TIMEOUT: string,
|
||||
AUTO_VERIFIED: string,
|
||||
ERROR: string,
|
||||
},
|
||||
};
|
||||
|
||||
/**RNFirebase mimics the Web Firebase SDK Storage,
|
||||
* whilst providing some iOS and Android specific functionality.
|
||||
*/
|
||||
storage(): RNFirebase.storage.Storage;
|
||||
|
||||
/**
|
||||
* Firebase Cloud Messaging (FCM) allows you to send push messages at no cost to both Android & iOS platforms.
|
||||
* Assuming the installation instructions have been followed, FCM is ready to go.
|
||||
* As the Firebase Web SDK has limited messaging functionality,
|
||||
* the following methods within react-native-firebase have been created to handle FCM in the React Native environment.
|
||||
*/
|
||||
messaging(): RNFirebase.messaging.Messaging;
|
||||
|
||||
/**
|
||||
* RNFirebase provides crash reporting for your app out of the box.
|
||||
* Please note crashes do not appear in real-time on the console,
|
||||
* they tend to take a number of hours to appear
|
||||
* If you want to manually report a crash,
|
||||
* such as a pre-caught exception this is possible by using the report method.
|
||||
*/
|
||||
auth(): RNFirebase.auth.Auth;
|
||||
// config(): RNFirebase.config.Config;
|
||||
crash(): RNFirebase.crash.Crash;
|
||||
|
||||
/**
|
||||
* Firebase Dynamic Links are links that work the way you want, on multiple
|
||||
* platforms, and whether or not your app is already installed.
|
||||
* See the official Firebase docs:
|
||||
* https://firebase.google.com/docs/dynamic-links/
|
||||
*/
|
||||
links(): RNFirebase.links.Links;
|
||||
|
||||
static fabric: {
|
||||
crashlytics(): RNFirebase.crashlytics.Crashlytics;
|
||||
database(): RNFirebase.database.Database;
|
||||
fabric: {
|
||||
crashlytics(): RNFirebase.crashlytics.Crashlytics,
|
||||
};
|
||||
|
||||
apps: Array<string>;
|
||||
googleApiAvailability: RNFirebase.GoogleApiAvailabilityType;
|
||||
|
||||
static initializeApp(options?: any | RNFirebase.configurationOptions, name?: string): FireBase;
|
||||
|
||||
static app(name?: string): FireBase;
|
||||
|
||||
[key: string]: any;
|
||||
firestore(): RNFirebase.firestore.Firestore;
|
||||
links(): RNFirebase.links.Links;
|
||||
messaging(): RNFirebase.messaging.Messaging;
|
||||
// perf(): RNFirebase.perf.Performance;
|
||||
storage(): RNFirebase.storage.Storage;
|
||||
// utils(): RNFirebase.utils.Utils;
|
||||
readonly name: string;
|
||||
readonly options: Firebase.Options;
|
||||
}
|
||||
|
||||
namespace RNFirebase {
|
||||
export namespace RNFirebase {
|
||||
interface RnError extends Error {
|
||||
code?: string;
|
||||
}
|
||||
|
@ -484,6 +473,15 @@ declare module "react-native-firebase" {
|
|||
|
||||
update(values: Object, onComplete?: (a: RnError | null) => any): Promise<any>;
|
||||
}
|
||||
|
||||
interface DatabaseStatics {
|
||||
/** @see https://www.firebase.com/docs/java-api/javadoc/com/firebase/client/ServerValue.html#TIMESTAMP */
|
||||
ServerValue: {
|
||||
TIMESTAMP: {
|
||||
[key: string]: string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -533,6 +531,18 @@ declare module "react-native-firebase" {
|
|||
[key: string]: any;
|
||||
}
|
||||
|
||||
type AdditionalUserInfo = {
|
||||
isNewUser: boolean,
|
||||
profile?: Object,
|
||||
providerId: string,
|
||||
username?: string,
|
||||
}
|
||||
|
||||
type UserCredential = {
|
||||
additionalUserInfo?: AdditionalUserInfo,
|
||||
user: User,
|
||||
}
|
||||
|
||||
type UserInfo = {
|
||||
displayName?: string,
|
||||
email?: string,
|
||||
|
@ -547,6 +557,11 @@ declare module "react-native-firebase" {
|
|||
photoURL?: string,
|
||||
}
|
||||
|
||||
type UserMetadata = {
|
||||
creationTime?: string,
|
||||
lastSignInTime?: string,
|
||||
}
|
||||
|
||||
interface User {
|
||||
/**
|
||||
* The user's display name (if available).
|
||||
|
@ -565,6 +580,8 @@ declare module "react-native-firebase" {
|
|||
*/
|
||||
isAnonymous: boolean
|
||||
|
||||
metadata: UserMetadata
|
||||
|
||||
phoneNumber: string | null
|
||||
/**
|
||||
* - The URL of the user's profile picture (if available).
|
||||
|
@ -594,13 +611,19 @@ declare module "react-native-firebase" {
|
|||
*
|
||||
* @param forceRefresh: boolean - default to false
|
||||
*/
|
||||
getIdToken(forceRefresh: boolean?): Promise<string>
|
||||
getIdToken(forceRefresh?: boolean): Promise<string>
|
||||
|
||||
getToken(forceRefresh?: boolean): Promise<string>
|
||||
|
||||
linkAndRetrieveDataWithCredential(credential: AuthCredential): Promise<UserCredential>
|
||||
|
||||
/**
|
||||
* Link the user with a 3rd party credential provider.
|
||||
*/
|
||||
linkWithCredential(credential: AuthCredential): Promise<User>
|
||||
|
||||
reauthenticateAndRetrieveDataWithCredential(credential: AuthCredential): Promise<UserCredential>
|
||||
|
||||
/**
|
||||
* Re-authenticate a user with a third-party authentication provider
|
||||
*/
|
||||
|
@ -642,13 +665,6 @@ declare module "react-native-firebase" {
|
|||
updateProfile(updates: UpdateProfile): Promise<void>
|
||||
}
|
||||
|
||||
/** 3rd party provider Credentials */
|
||||
type AuthCredential {
|
||||
providerId: string,
|
||||
token: string,
|
||||
secret: string
|
||||
}
|
||||
|
||||
type ActionCodeSettings = {
|
||||
android: {
|
||||
installApp?: boolean,
|
||||
|
@ -663,12 +679,11 @@ declare module "react-native-firebase" {
|
|||
}
|
||||
|
||||
interface ActionCodeInfo {
|
||||
email: string,
|
||||
error: string,
|
||||
fromEmail: string,
|
||||
verifyEmail: string,
|
||||
recoverEmail: string,
|
||||
passwordReset: string
|
||||
data: {
|
||||
email?: string,
|
||||
fromEmail?: string
|
||||
},
|
||||
operation: 'PASSWORD_RESET' | 'VERIFY_EMAIL' | 'RECOVER_EMAIL'
|
||||
}
|
||||
|
||||
interface ConfirmationResult {
|
||||
|
@ -705,13 +720,18 @@ declare module "react-native-firebase" {
|
|||
}
|
||||
|
||||
namespace auth {
|
||||
|
||||
type AuthResult = {
|
||||
authenticated: boolean,
|
||||
user: object | null
|
||||
} | null;
|
||||
|
||||
type AuthProvider = {
|
||||
PROVIDER_ID: string,
|
||||
credential: (token: string, secret?: string) => AuthCredential,
|
||||
};
|
||||
|
||||
interface Auth {
|
||||
readonly app: App;
|
||||
/**
|
||||
* Returns the current Firebase authentication state.
|
||||
*/
|
||||
|
@ -719,7 +739,7 @@ declare module "react-native-firebase" {
|
|||
/**
|
||||
* Returns the currently signed-in user (or null). See the User class documentation for further usage.
|
||||
*/
|
||||
user: User | null
|
||||
currentUser: User | null
|
||||
|
||||
/**
|
||||
* Gets/Sets the language for the app instance
|
||||
|
@ -749,12 +769,15 @@ declare module "react-native-firebase" {
|
|||
|
||||
signOut(): Promise<void>
|
||||
|
||||
signInAnonymouslyAndRetrieveData(): Promise<UserCredential>
|
||||
|
||||
/**
|
||||
* Sign an anonymous user.
|
||||
* If the user has already signed in, that user will be returned
|
||||
*/
|
||||
signInAnonymously(): Promise<User>
|
||||
|
||||
createUserAndRetrieveDataWithEmailAndPassword(email: string, password: string): Promise<UserCredential>
|
||||
|
||||
/**
|
||||
* We can create a user by calling the createUserWithEmailAndPassword() function.
|
||||
|
@ -762,12 +785,16 @@ declare module "react-native-firebase" {
|
|||
*/
|
||||
createUserWithEmailAndPassword(email: string, password: string): Promise<User>
|
||||
|
||||
signInAndRetrieveDataWithEmailAndPassword(email: string, password: string): Promise<UserCredential>
|
||||
|
||||
/**
|
||||
* To sign a user in with their email and password, use the signInWithEmailAndPassword() function.
|
||||
* It accepts two parameters, the user's email and password:
|
||||
*/
|
||||
signInWithEmailAndPassword(email: string, password: string): Promise<User>
|
||||
|
||||
signInAndRetrieveDataWithCustomToken(token: string): Promise<UserCredential>
|
||||
|
||||
/**
|
||||
* Sign a user in with a self-signed JWT token.
|
||||
* To sign a user using a self-signed custom token,
|
||||
|
@ -776,6 +803,8 @@ declare module "react-native-firebase" {
|
|||
*/
|
||||
signInWithCustomToken(token: string): Promise<User>
|
||||
|
||||
signInAndRetrieveDataWithCredential(credential: AuthCredential): Promise<UserCredential>
|
||||
|
||||
/**
|
||||
* Sign in the user with a 3rd party credential provider.
|
||||
* credential requires the following properties:
|
||||
|
@ -816,18 +845,31 @@ declare module "react-native-firebase" {
|
|||
*/
|
||||
checkActionCode(code: string): Promise<ActionCodeInfo>
|
||||
|
||||
/**
|
||||
* Get the currently signed in user
|
||||
*/
|
||||
getCurrentUser(): Promise<User | null>
|
||||
|
||||
/**
|
||||
* Returns a list of authentication providers that can be used to sign in a given user (identified by its main email address).
|
||||
*/
|
||||
fetchProvidersForEmail(email: string): Promise<Array<string>>
|
||||
|
||||
verifyPasswordResetCode(code: string): Promise<string>
|
||||
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface AuthStatics {
|
||||
EmailAuthProvider: AuthProvider;
|
||||
PhoneAuthProvider: AuthProvider;
|
||||
GoogleAuthProvider: AuthProvider;
|
||||
GithubAuthProvider: AuthProvider;
|
||||
OAuthProvider: AuthProvider;
|
||||
TwitterAuthProvider: AuthProvider;
|
||||
FacebookAuthProvider: AuthProvider;
|
||||
PhoneAuthState: {
|
||||
CODE_SENT: string;
|
||||
AUTO_VERIFY_TIMEOUT: string;
|
||||
AUTO_VERIFIED: string;
|
||||
ERROR: string;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace messaging {
|
||||
|
@ -1032,7 +1074,7 @@ declare module "react-native-firebase" {
|
|||
* Returns an unsubscribe function, call the returned function to
|
||||
* unsubscribe from all future events.
|
||||
*/
|
||||
onLink(listener: (url) => void): () => void;
|
||||
onLink(listener: (url: string) => void): () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1067,5 +1109,260 @@ declare module "react-native-firebase" {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
namespace firestore {
|
||||
interface Firestore {
|
||||
readonly app: App;
|
||||
batch(): WriteBatch;
|
||||
collection(collectionPath: string): CollectionReference;
|
||||
doc(documentPath: string): DocumentReference;
|
||||
|
||||
/** NOT SUPPORTED YET */
|
||||
// enablePersistence(): Promise<void>;
|
||||
/** NOT SUPPORTED YET */
|
||||
// runTransaction(): Promise<any>;
|
||||
/** NOT SUPPORTED YET */
|
||||
// settings(): void;
|
||||
}
|
||||
|
||||
interface FirestoreStatics {
|
||||
FieldPath: typeof FieldPath;
|
||||
FieldValue: typeof FieldValue;
|
||||
GeoPoint: typeof GeoPoint;
|
||||
enableLogging(enabled: boolean): void;
|
||||
}
|
||||
|
||||
interface CollectionReference {
|
||||
readonly firestore: Firestore;
|
||||
readonly id: string;
|
||||
readonly parent: DocumentReference;
|
||||
add(data: object): Promise<DocumentReference>;
|
||||
doc(documentPath?: string): DocumentReference;
|
||||
endAt(snapshot: DocumentSnapshot): Query;
|
||||
endAt(...varargs: any[]): Query;
|
||||
endBefore(snapshot: DocumentSnapshot): Query;
|
||||
endBefore(...varargs: any[]): Query;
|
||||
get(): Promise<QuerySnapshot>;
|
||||
limit(limit: number): Query;
|
||||
onSnapshot(onNext: Query.ObserverOnNext, onError?: Query.ObserverOnError): () => void;
|
||||
onSnapshot(observer: Query.Observer): () => void;
|
||||
onSnapshot(queryListenOptions: Query.QueryListenOptions, onNext: Query.ObserverOnNext, onError?: Query.ObserverOnError): () => void;
|
||||
onSnapshot(queryListenOptions: Query.QueryListenOptions, observer: Query.Observer): () => void;
|
||||
orderBy(fieldPath: string | FieldPath, directionStr?: Types.QueryDirection): Query;
|
||||
startAfter(snapshot: DocumentSnapshot): Query;
|
||||
startAfter(...varargs: any[]): Query;
|
||||
startAt(snapshot: DocumentSnapshot): Query;
|
||||
startAt(...varargs: any[]): Query;
|
||||
where(fieldPath: string, op: Types.QueryOperator, value: any): Query;
|
||||
}
|
||||
|
||||
interface DocumentChange {
|
||||
readonly doc: DocumentSnapshot;
|
||||
readonly newIndex: number;
|
||||
readonly oldIndex: number;
|
||||
readonly type: string;
|
||||
}
|
||||
|
||||
interface DocumentReference {
|
||||
readonly firestore: Firestore;
|
||||
readonly id: string | null;
|
||||
readonly parent: CollectionReference;
|
||||
readonly path: string;
|
||||
collection(collectionPath: string): CollectionReference;
|
||||
delete(): Promise<void>;
|
||||
get(): Promise<DocumentSnapshot>;
|
||||
onSnapshot(onNext: DocumentReference.ObserverOnNext, onError?: DocumentReference.ObserverOnError): () => void;
|
||||
onSnapshot(observer: DocumentReference.Observer): () => void;
|
||||
onSnapshot(documentListenOptions: DocumentReference.DocumentListenOptions, onNext: DocumentReference.ObserverOnNext, onError?: DocumentReference.ObserverOnError): () => void;
|
||||
onSnapshot(documentListenOptions: DocumentReference.DocumentListenOptions, observer: DocumentReference.Observer): () => void;
|
||||
set(data: object, writeOptions?: Types.WriteOptions): Promise<void>;
|
||||
update(obj: object): Promise<void>;
|
||||
update(key1: Types.UpdateKey, val1: any): Promise<void>;
|
||||
update(key1: Types.UpdateKey, val1: any, key2: Types.UpdateKey, val2: any): Promise<void>;
|
||||
update(key1: Types.UpdateKey, val1: any, key2: Types.UpdateKey, val2: any, key3: Types.UpdateKey, val3: any): Promise<void>;
|
||||
update(key1: Types.UpdateKey, val1: any, key2: Types.UpdateKey, val2: any, key3: Types.UpdateKey, val3: any, key4: Types.UpdateKey, val4: any): Promise<void>;
|
||||
update(key1: Types.UpdateKey, val1: any, key2: Types.UpdateKey, val2: any, key3: Types.UpdateKey, val3: any, key4: Types.UpdateKey, val4: any, key5: Types.UpdateKey, val5: any): Promise<void>;
|
||||
}
|
||||
namespace DocumentReference {
|
||||
interface DocumentListenOptions {
|
||||
includeMetadataChanges: boolean;
|
||||
}
|
||||
|
||||
type ObserverOnNext = (documentSnapshot: DocumentSnapshot) => void;
|
||||
type ObserverOnError = (err: object) => void;
|
||||
interface Observer {
|
||||
next: ObserverOnNext;
|
||||
error?: ObserverOnError;
|
||||
}
|
||||
}
|
||||
|
||||
interface DocumentSnapshot {
|
||||
readonly exists: boolean;
|
||||
readonly id: string | null;
|
||||
readonly metadata: Types.SnapshotMetadata;
|
||||
readonly ref: DocumentReference;
|
||||
data(): object | void;
|
||||
get(fieldPath: string | FieldPath): any | undefined;
|
||||
}
|
||||
|
||||
class FieldPath {
|
||||
static documentId(): FieldPath;
|
||||
constructor(...segments: string[]);
|
||||
}
|
||||
|
||||
class FieldValue {
|
||||
static delete(): FieldValue;
|
||||
static serverTimestamp(): FieldValue;
|
||||
}
|
||||
|
||||
class GeoPoint {
|
||||
constructor(latitude: number, longitude: number);
|
||||
readonly latitude: number;
|
||||
readonly longitude: number;
|
||||
}
|
||||
|
||||
class Path {
|
||||
static fromName(name: string): Path;
|
||||
constructor(pathComponents: string[]);
|
||||
readonly id: string | null;
|
||||
readonly isDocument: boolean;
|
||||
readonly isCollection: boolean;
|
||||
readonly relativeName: string;
|
||||
child(relativePath: string): Path;
|
||||
parent(): Path | null;
|
||||
}
|
||||
|
||||
interface Query {
|
||||
readonly firestore: Firestore;
|
||||
endAt(snapshot: DocumentSnapshot): Query;
|
||||
endAt(...varargs: any[]): Query;
|
||||
endBefore(snapshot: DocumentSnapshot): Query;
|
||||
endBefore(...varargs: any[]): Query;
|
||||
get(): Promise<QuerySnapshot>;
|
||||
limit(limit: number): Query;
|
||||
onSnapshot(onNext: Query.ObserverOnNext, onError?: Query.ObserverOnError): () => void;
|
||||
onSnapshot(observer: Query.Observer): () => void;
|
||||
onSnapshot(queryListenOptions: Query.QueryListenOptions, onNext: Query.ObserverOnNext, onError?: Query.ObserverOnError): () => void;
|
||||
onSnapshot(queryListenOptions: Query.QueryListenOptions, observer: Query.Observer): () => void;
|
||||
orderBy(fieldPath: string | FieldPath, directionStr?: Types.QueryDirection): Query;
|
||||
startAfter(snapshot: DocumentSnapshot): Query;
|
||||
startAfter(...varargs: any[]): Query;
|
||||
startAt(snapshot: DocumentSnapshot): Query;
|
||||
startAt(...varargs: any[]): Query;
|
||||
where(fieldPath: string, op: Types.QueryOperator, value: any): Query;
|
||||
}
|
||||
namespace Query {
|
||||
interface NativeFieldPath {
|
||||
elements?: string[];
|
||||
string?: string;
|
||||
type: 'fieldpath' | 'string';
|
||||
}
|
||||
|
||||
interface FieldFilter {
|
||||
fieldPath: NativeFieldPath;
|
||||
operator: string;
|
||||
value: any;
|
||||
}
|
||||
|
||||
interface FieldOrder {
|
||||
direction: string;
|
||||
fieldPath: NativeFieldPath;
|
||||
}
|
||||
|
||||
interface QueryOptions {
|
||||
endAt?: any[];
|
||||
endBefore?: any[];
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
selectFields?: string[];
|
||||
startAfter?: any[];
|
||||
startAt?: any[];
|
||||
}
|
||||
|
||||
// The JS code expects at least one of 'includeDocumentMetadataChanges'
|
||||
// or 'includeQueryMetadataChanges' to be defined.
|
||||
interface _IncludeDocumentMetadataChanges {
|
||||
includeDocumentMetadataChanges: boolean;
|
||||
}
|
||||
interface _IncludeQueryMetadataChanges {
|
||||
includeQueryMetadataChanges: boolean;
|
||||
}
|
||||
type QueryListenOptions = _IncludeDocumentMetadataChanges | _IncludeQueryMetadataChanges | (_IncludeDocumentMetadataChanges & _IncludeQueryMetadataChanges);
|
||||
|
||||
type ObserverOnNext = (querySnapshot: QuerySnapshot) => void;
|
||||
type ObserverOnError = (err: object) => void;
|
||||
interface Observer {
|
||||
next: ObserverOnNext;
|
||||
error?: ObserverOnError;
|
||||
}
|
||||
}
|
||||
|
||||
interface QuerySnapshot {
|
||||
readonly docChanges: DocumentChange[];
|
||||
readonly docs: DocumentSnapshot[];
|
||||
readonly empty: boolean;
|
||||
readonly metadata: Types.SnapshotMetadata;
|
||||
readonly query: Query;
|
||||
readonly size: number;
|
||||
forEach(callback: (snapshot: DocumentSnapshot) => any): void;
|
||||
}
|
||||
namespace QuerySnapshot {
|
||||
interface NativeData {
|
||||
changes: Types.NativeDocumentChange[];
|
||||
documents: Types.NativeDocumentSnapshot[];
|
||||
metadata: Types.SnapshotMetadata;
|
||||
}
|
||||
}
|
||||
|
||||
interface WriteBatch {
|
||||
commit(): Promise<void>;
|
||||
delete(docRef: DocumentReference): WriteBatch;
|
||||
set(docRef: DocumentReference, data: object, options?: Types.WriteOptions): WriteBatch;
|
||||
// multiple overrides for update() to allow strong-typed var_args
|
||||
update(docRef: DocumentReference, obj: object): WriteBatch;
|
||||
update(docRef: DocumentReference, key1: Types.UpdateKey, val1: any): WriteBatch;
|
||||
update(docRef: DocumentReference, key1: Types.UpdateKey, val1: any, key2: Types.UpdateKey, val2: any): WriteBatch;
|
||||
update(docRef: DocumentReference, key1: Types.UpdateKey, val1: any, key2: Types.UpdateKey, val2: any, key3: Types.UpdateKey, val3: any): WriteBatch;
|
||||
update(docRef: DocumentReference, key1: Types.UpdateKey, val1: any, key2: Types.UpdateKey, val2: any, key3: Types.UpdateKey, val3: any, key4: Types.UpdateKey, val4: any): WriteBatch;
|
||||
update(docRef: DocumentReference, key1: Types.UpdateKey, val1: any, key2: Types.UpdateKey, val2: any, key3: Types.UpdateKey, val3: any, key4: Types.UpdateKey, val4: any, key5: Types.UpdateKey, val5: any): WriteBatch;
|
||||
}
|
||||
|
||||
namespace Types {
|
||||
interface NativeDocumentChange {
|
||||
document: NativeDocumentSnapshot;
|
||||
newIndex: number;
|
||||
oldIndex: number;
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface NativeDocumentSnapshot {
|
||||
data: {
|
||||
[key: string]: TypeMap;
|
||||
};
|
||||
metadata: SnapshotMetadata;
|
||||
path: string;
|
||||
}
|
||||
|
||||
interface SnapshotMetadata {
|
||||
fromCache: boolean;
|
||||
hasPendingWrites: boolean;
|
||||
}
|
||||
|
||||
type QueryDirection = 'asc' | 'ASC' | 'desc' | 'DESC';
|
||||
type QueryOperator = '=' | '==' | '>' | '>=' | '<' | '<=';
|
||||
|
||||
interface TypeMap {
|
||||
type: 'array' | 'boolean' | 'date' | 'documentid' | 'fieldvalue' | 'geopoint' | 'null' | 'number' | 'object' | 'reference' | 'string';
|
||||
value: any;
|
||||
}
|
||||
|
||||
/** The key in update() function for DocumentReference and WriteBatch. */
|
||||
type UpdateKey = string | FieldPath
|
||||
|
||||
interface WriteOptions {
|
||||
merge?: boolean;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
60
lib/index.js
60
lib/index.js
|
@ -3,7 +3,65 @@
|
|||
*/
|
||||
import firebase from './modules/core/firebase';
|
||||
|
||||
export default firebase;
|
||||
|
||||
/*
|
||||
* Export App types
|
||||
*/
|
||||
export type { default as App } from './modules/core/app';
|
||||
|
||||
/*
|
||||
* Export Auth types
|
||||
*/
|
||||
export type {
|
||||
ActionCodeInfo,
|
||||
ActionCodeSettings,
|
||||
AdditionalUserInfo,
|
||||
AuthCredential,
|
||||
UserCredential,
|
||||
UserInfo,
|
||||
UserMetadata,
|
||||
} from './modules/auth/types';
|
||||
export type {
|
||||
default as ConfirmationResult,
|
||||
} from './modules/auth/ConfirmationResult';
|
||||
export type { default as User } from './modules/auth/User';
|
||||
export type { default as Message } from './modules/messaging/Message';
|
||||
|
||||
export default firebase;
|
||||
/*
|
||||
* Export Database types
|
||||
*/
|
||||
export type { default as DataSnapshot } from './modules/database/DataSnapshot';
|
||||
export type { default as OnDisconnect } from './modules/database/OnDisconnect';
|
||||
export type { default as Reference } from './modules/database/Reference';
|
||||
export type { default as DataQuery } from './modules/database/Query';
|
||||
|
||||
/*
|
||||
* Export Firestore types
|
||||
*/
|
||||
export type {
|
||||
DocumentListenOptions,
|
||||
QueryListenOptions,
|
||||
SetOptions,
|
||||
SnapshotMetadata,
|
||||
} from './modules/firestore/types';
|
||||
export type {
|
||||
default as CollectionReference,
|
||||
} from './modules/firestore/CollectionReference';
|
||||
export type {
|
||||
default as DocumentChange,
|
||||
} from './modules/firestore/DocumentChange';
|
||||
export type {
|
||||
default as DocumentReference,
|
||||
} from './modules/firestore/DocumentReference';
|
||||
export type {
|
||||
default as DocumentSnapshot,
|
||||
} from './modules/firestore/DocumentSnapshot';
|
||||
export type { default as FieldPath } from './modules/firestore/FieldPath';
|
||||
export type { default as FieldValue } from './modules/firestore/FieldValue';
|
||||
export type { default as GeoPoint } from './modules/firestore/GeoPoint';
|
||||
export type { default as Query } from './modules/firestore/Query';
|
||||
export type {
|
||||
default as QuerySnapshot,
|
||||
} from './modules/firestore/QuerySnapshot';
|
||||
export type { default as WriteBatch } from './modules/firestore/WriteBatch';
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/**
|
||||
* @flow
|
||||
*/
|
||||
export default {
|
||||
onAdLoaded: 'onAdLoaded',
|
||||
onAdOpened: 'onAdOpened',
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
import { NativeModules, Platform } from 'react-native';
|
||||
import { Platform } from 'react-native';
|
||||
import { statics } from './';
|
||||
import AdRequest from './AdRequest';
|
||||
import { SharedEventEmitter } from '../../utils/events';
|
||||
import { getNativeModule } from '../../utils/native';
|
||||
import { nativeToJSError } from '../../utils';
|
||||
|
||||
const FirebaseAdMob = NativeModules.RNFirebaseAdMob;
|
||||
import type AdMob from './';
|
||||
|
||||
let subscriptions = [];
|
||||
|
||||
export default class Interstitial {
|
||||
constructor(admob: Object, adUnit: string) {
|
||||
_admob: AdMob;
|
||||
|
||||
constructor(admob: AdMob, adUnit: string) {
|
||||
// Interstitials on iOS require a new instance each time
|
||||
if (Platform.OS === 'ios') {
|
||||
FirebaseAdMob.clearInterstitial(adUnit);
|
||||
getNativeModule(admob).clearInterstitial(adUnit);
|
||||
}
|
||||
|
||||
for (let i = 0, len = subscriptions.length; i < len; i++) {
|
||||
|
@ -20,7 +22,7 @@ export default class Interstitial {
|
|||
}
|
||||
subscriptions = [];
|
||||
|
||||
this.admob = admob;
|
||||
this._admob = admob;
|
||||
this.adUnit = adUnit;
|
||||
this.loaded = false;
|
||||
SharedEventEmitter.removeAllListeners(`interstitial_${adUnit}`);
|
||||
|
@ -67,7 +69,10 @@ export default class Interstitial {
|
|||
adRequest = new AdRequest().addTestDevice().build();
|
||||
}
|
||||
|
||||
return FirebaseAdMob.interstitialLoadAd(this.adUnit, adRequest);
|
||||
return getNativeModule(this._admob).interstitialLoadAd(
|
||||
this.adUnit,
|
||||
adRequest
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +89,7 @@ export default class Interstitial {
|
|||
*/
|
||||
show() {
|
||||
if (this.loaded) {
|
||||
FirebaseAdMob.interstitialShowAd(this.adUnit);
|
||||
getNativeModule(this._admob).interstitialShowAd(this.adUnit);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
import { NativeModules } from 'react-native';
|
||||
import { statics } from './';
|
||||
import AdRequest from './AdRequest';
|
||||
import { SharedEventEmitter } from '../../utils/events';
|
||||
import { getNativeModule } from '../../utils/native';
|
||||
import { nativeToJSError } from '../../utils';
|
||||
|
||||
const FirebaseAdMob = NativeModules.RNFirebaseAdMob;
|
||||
import type AdMob from './';
|
||||
|
||||
let subscriptions = [];
|
||||
|
||||
export default class RewardedVideo {
|
||||
constructor(admob: Object, adUnit: string) {
|
||||
_admob: AdMob;
|
||||
|
||||
constructor(admob: AdMob, adUnit: string) {
|
||||
for (let i = 0, len = subscriptions.length; i < len; i++) {
|
||||
subscriptions[i].remove();
|
||||
}
|
||||
subscriptions = [];
|
||||
|
||||
this.admob = admob;
|
||||
this._admob = admob;
|
||||
this.adUnit = adUnit;
|
||||
this.loaded = false;
|
||||
SharedEventEmitter.removeAllListeners(`rewarded_video_${adUnit}`);
|
||||
|
@ -62,7 +63,10 @@ export default class RewardedVideo {
|
|||
adRequest = new AdRequest().addTestDevice().build();
|
||||
}
|
||||
|
||||
return FirebaseAdMob.rewardedVideoLoadAd(this.adUnit, adRequest);
|
||||
return getNativeModule(this._admob).rewardedVideoLoadAd(
|
||||
this.adUnit,
|
||||
adRequest
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,7 +83,7 @@ export default class RewardedVideo {
|
|||
*/
|
||||
show() {
|
||||
if (this.loaded) {
|
||||
FirebaseAdMob.rewardedVideoShowAd(this.adUnit);
|
||||
getNativeModule(this._admob).rewardedVideoShowAd(this.adUnit);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import EventTypes, {
|
|||
RewardedVideoEventTypes,
|
||||
} from './EventTypes';
|
||||
|
||||
import type App from '../core/firebase-app';
|
||||
import type App from '../core/app';
|
||||
|
||||
type NativeEvent = {
|
||||
adUnit: string,
|
||||
|
@ -29,7 +29,7 @@ type NativeEvent = {
|
|||
|
||||
const NATIVE_EVENTS = ['interstitial_event', 'rewarded_video_event'];
|
||||
|
||||
export const MODULE_NAME = 'RNFirebaseAdmob';
|
||||
export const MODULE_NAME = 'RNFirebaseAdMob';
|
||||
export const NAMESPACE = 'admob';
|
||||
|
||||
export default class AdMob extends ModuleBase {
|
||||
|
@ -61,7 +61,7 @@ export default class AdMob extends ModuleBase {
|
|||
const { adUnit } = event;
|
||||
const jsEventType = `interstitial_${adUnit}`;
|
||||
|
||||
if (!SharedEventEmitter.hasListeners(jsEventType)) {
|
||||
if (SharedEventEmitter.listeners(jsEventType).length === 0) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ export default class AdMob extends ModuleBase {
|
|||
const { adUnit } = event;
|
||||
const jsEventType = `rewarded_video_${adUnit}`;
|
||||
|
||||
if (!SharedEventEmitter.hasListeners(jsEventType)) {
|
||||
if (SharedEventEmitter.listeners(jsEventType).length === 0) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import ModuleBase from '../../utils/ModuleBase';
|
||||
import { getNativeModule } from '../../utils/native';
|
||||
|
||||
import type App from '../core/firebase-app';
|
||||
import type App from '../core/app';
|
||||
|
||||
const AlphaNumericUnderscore = /^[a-zA-Z0-9_]+$/;
|
||||
|
||||
|
|
|
@ -11,18 +11,10 @@ import type {
|
|||
AuthCredential,
|
||||
NativeUser,
|
||||
UserCredential,
|
||||
UserInfo,
|
||||
UserMetadata,
|
||||
} from './types';
|
||||
|
||||
type UserInfo = {
|
||||
displayName?: string,
|
||||
email?: string,
|
||||
phoneNumber?: string,
|
||||
photoURL?: string,
|
||||
providerId: string,
|
||||
uid: string,
|
||||
};
|
||||
|
||||
type UpdateProfile = {
|
||||
displayName?: string,
|
||||
photoURL?: string,
|
||||
|
|
|
@ -22,26 +22,19 @@ import FacebookAuthProvider from './providers/FacebookAuthProvider';
|
|||
import PhoneAuthListener from './PhoneAuthListener';
|
||||
|
||||
import type {
|
||||
ActionCodeInfo,
|
||||
ActionCodeSettings,
|
||||
AuthCredential,
|
||||
NativeUser,
|
||||
NativeUserCredential,
|
||||
UserCredential,
|
||||
} from './types';
|
||||
import type App from '../core/firebase-app';
|
||||
import type App from '../core/app';
|
||||
|
||||
type AuthState = {
|
||||
user?: NativeUser,
|
||||
};
|
||||
|
||||
type ActionCodeInfo = {
|
||||
data: {
|
||||
email?: string,
|
||||
fromEmail?: string,
|
||||
},
|
||||
operation: 'PASSWORD_RESET' | 'VERIFY_EMAIL' | 'RECOVER_EMAIL',
|
||||
};
|
||||
|
||||
const NATIVE_EVENTS = [
|
||||
'auth_state_changed',
|
||||
'auth_id_token_changed',
|
||||
|
|
|
@ -3,6 +3,14 @@
|
|||
*/
|
||||
import type User from './User';
|
||||
|
||||
export type ActionCodeInfo = {
|
||||
data: {
|
||||
email?: string,
|
||||
fromEmail?: string,
|
||||
},
|
||||
operation: 'PASSWORD_RESET' | 'VERIFY_EMAIL' | 'RECOVER_EMAIL',
|
||||
};
|
||||
|
||||
export type ActionCodeSettings = {
|
||||
android: {
|
||||
installApp?: boolean,
|
||||
|
@ -16,7 +24,7 @@ export type ActionCodeSettings = {
|
|||
url: string,
|
||||
};
|
||||
|
||||
type AdditionalUserInfo = {
|
||||
export type AdditionalUserInfo = {
|
||||
isNewUser: boolean,
|
||||
profile?: Object,
|
||||
providerId: string,
|
||||
|
|
|
@ -6,7 +6,7 @@ import { getLogger } from '../../utils/log';
|
|||
import ModuleBase from '../../utils/ModuleBase';
|
||||
import { getNativeModule } from '../../utils/native';
|
||||
|
||||
import type App from '../core/firebase-app';
|
||||
import type App from '../core/app';
|
||||
|
||||
type NativeValue = {
|
||||
stringValue?: string,
|
||||
|
|
|
@ -6,7 +6,7 @@ import { NativeModules } from 'react-native';
|
|||
|
||||
import APPS from '../../utils/apps';
|
||||
import INTERNALS from '../../utils/internals';
|
||||
import App from './firebase-app';
|
||||
import App from './app';
|
||||
import VERSION from '../../version';
|
||||
|
||||
// module imports
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import ModuleBase from '../../utils/ModuleBase';
|
||||
import { getNativeModule } from '../../utils/native';
|
||||
|
||||
import type App from '../core/firebase-app';
|
||||
import type App from '../core/app';
|
||||
import type { FirebaseError } from '../../types';
|
||||
|
||||
export const MODULE_NAME = 'RNFirebaseCrash';
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
/**
|
||||
* @flow
|
||||
* Snapshot representation wrapper
|
||||
* DataSnapshot representation wrapper
|
||||
*/
|
||||
import { isObject, deepGet, deepExists } from './../../utils';
|
||||
import type Reference from './reference';
|
||||
import type Reference from './Reference';
|
||||
|
||||
/**
|
||||
* @class DataSnapshot
|
||||
* @link https://firebase.google.com/docs/reference/js/firebase.database.DataSnapshot
|
||||
*/
|
||||
export default class Snapshot {
|
||||
export default class DataSnapshot {
|
||||
ref: Reference;
|
||||
key: string;
|
||||
|
||||
|
@ -50,10 +50,10 @@ export default class Snapshot {
|
|||
* @link https://firebase.google.com/docs/reference/js/firebase.database.DataSnapshot#forEach
|
||||
* @returns {Snapshot}
|
||||
*/
|
||||
child(path: string): Snapshot {
|
||||
child(path: string): DataSnapshot {
|
||||
const value = deepGet(this._value, path);
|
||||
const childRef = this.ref.child(path);
|
||||
return new Snapshot(childRef, {
|
||||
return new DataSnapshot(childRef, {
|
||||
value,
|
||||
key: childRef.key,
|
||||
exists: value !== null,
|
|
@ -1,17 +1,17 @@
|
|||
/**
|
||||
* @flow
|
||||
* Disconnect representation wrapper
|
||||
* OnDisconnect representation wrapper
|
||||
*/
|
||||
import { typeOf } from '../../utils';
|
||||
import { getNativeModule } from '../../utils/native';
|
||||
import type Database from './';
|
||||
import type Reference from './reference';
|
||||
import type Reference from './Reference';
|
||||
|
||||
/**
|
||||
* @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect
|
||||
* @class Disconnect
|
||||
* @class OmDisconnect
|
||||
*/
|
||||
export default class Disconnect {
|
||||
export default class OnDisconnect {
|
||||
_database: Database;
|
||||
ref: Reference;
|
||||
path: string;
|
|
@ -5,7 +5,7 @@
|
|||
import { objectToUniqueId } from '../../utils';
|
||||
|
||||
import type { DatabaseModifier } from '../../types';
|
||||
import type Reference from './reference';
|
||||
import type Reference from './Reference';
|
||||
|
||||
// todo doc methods
|
||||
|
|
@ -2,9 +2,9 @@
|
|||
* @flow
|
||||
* Database Reference representation wrapper
|
||||
*/
|
||||
import Query from './query';
|
||||
import Snapshot from './snapshot';
|
||||
import Disconnect from './disconnect';
|
||||
import Query from './Query';
|
||||
import DataSnapshot from './DataSnapshot';
|
||||
import OnDisconnect from './OnDisconnect';
|
||||
import { getLogger } from '../../utils/log';
|
||||
import { getNativeModule } from '../../utils/native';
|
||||
import ReferenceBase from '../../utils/ReferenceBase';
|
||||
|
@ -218,7 +218,11 @@ export default class Reference extends ReferenceBase {
|
|||
*/
|
||||
transaction(
|
||||
transactionUpdate: Function,
|
||||
onComplete: (error: ?Error, committed: boolean, snapshot: ?Snapshot) => *,
|
||||
onComplete: (
|
||||
error: ?Error,
|
||||
committed: boolean,
|
||||
snapshot: ?DataSnapshot
|
||||
) => *,
|
||||
applyLocally: boolean = false
|
||||
) {
|
||||
if (!isFunction(transactionUpdate)) {
|
||||
|
@ -233,14 +237,14 @@ export default class Reference extends ReferenceBase {
|
|||
if (error) {
|
||||
onComplete(error, committed, null);
|
||||
} else {
|
||||
onComplete(null, committed, new Snapshot(this, snapshotData));
|
||||
onComplete(null, committed, new DataSnapshot(this, snapshotData));
|
||||
}
|
||||
}
|
||||
|
||||
if (error) return reject(error);
|
||||
return resolve({
|
||||
committed,
|
||||
snapshot: new Snapshot(this, snapshotData),
|
||||
snapshot: new DataSnapshot(this, snapshotData),
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -264,14 +268,14 @@ export default class Reference extends ReferenceBase {
|
|||
*/
|
||||
once(
|
||||
eventName: string = 'value',
|
||||
successCallback: (snapshot: Object) => void,
|
||||
successCallback: (snapshot: DataSnapshot) => void,
|
||||
cancelOrContext: (error: FirebaseError) => void,
|
||||
context?: Object
|
||||
) {
|
||||
return getNativeModule(this._database)
|
||||
.once(this._getRefKey(), this.path, this._query.getModifiers(), eventName)
|
||||
.then(({ snapshot }) => {
|
||||
const _snapshot = new Snapshot(this, snapshot);
|
||||
const _snapshot = new DataSnapshot(this, snapshot);
|
||||
|
||||
if (isFunction(successCallback)) {
|
||||
if (isObject(cancelOrContext))
|
||||
|
@ -470,10 +474,10 @@ export default class Reference extends ReferenceBase {
|
|||
|
||||
/**
|
||||
*
|
||||
* @returns {Disconnect}
|
||||
* @returns {OnDisconnect}
|
||||
*/
|
||||
onDisconnect(): Disconnect {
|
||||
return new Disconnect(this);
|
||||
onDisconnect(): OnDisconnect {
|
||||
return new OnDisconnect(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -691,7 +695,7 @@ export default class Reference extends ReferenceBase {
|
|||
*/
|
||||
on(
|
||||
eventType: string,
|
||||
callback: Snapshot => any,
|
||||
callback: DataSnapshot => any,
|
||||
cancelCallbackOrContext?: Object => any | Object,
|
||||
context?: Object
|
||||
): Function {
|
|
@ -4,12 +4,12 @@
|
|||
*/
|
||||
import { NativeModules } from 'react-native';
|
||||
|
||||
import Reference from './reference';
|
||||
import Reference from './Reference';
|
||||
import TransactionHandler from './transaction';
|
||||
import ModuleBase from '../../utils/ModuleBase';
|
||||
import { getNativeModule } from '../../utils/native';
|
||||
|
||||
import type App from '../core/firebase-app';
|
||||
import type App from '../core/app';
|
||||
|
||||
const NATIVE_EVENTS = [
|
||||
'database_transaction_event',
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import ModuleBase from '../../../utils/ModuleBase';
|
||||
import { getNativeModule } from '../../../utils/native';
|
||||
|
||||
import type App from '../../core/firebase-app';
|
||||
import type App from '../../core/app';
|
||||
|
||||
export const MODULE_NAME = 'RNFirebaseCrashlytics';
|
||||
export const NAMESPACE = 'crashlytics';
|
||||
|
|
|
@ -8,17 +8,13 @@ import { firestoreAutoId } from '../../utils';
|
|||
|
||||
import type Firestore from './';
|
||||
import type {
|
||||
FirestoreQueryDirection,
|
||||
FirestoreQueryOperator,
|
||||
} from '../../types';
|
||||
QueryDirection,
|
||||
QueryListenOptions,
|
||||
QueryOperator,
|
||||
} from './types';
|
||||
import type FieldPath from './FieldPath';
|
||||
import type Path from './Path';
|
||||
import type {
|
||||
Observer,
|
||||
ObserverOnError,
|
||||
ObserverOnNext,
|
||||
QueryListenOptions,
|
||||
} from './Query';
|
||||
import type { Observer, ObserverOnError, ObserverOnNext } from './Query';
|
||||
import type QuerySnapshot from './QuerySnapshot';
|
||||
|
||||
/**
|
||||
|
@ -95,10 +91,7 @@ export default class CollectionReference {
|
|||
);
|
||||
}
|
||||
|
||||
orderBy(
|
||||
fieldPath: string | FieldPath,
|
||||
directionStr?: FirestoreQueryDirection
|
||||
): Query {
|
||||
orderBy(fieldPath: string | FieldPath, directionStr?: QueryDirection): Query {
|
||||
return this._query.orderBy(fieldPath, directionStr);
|
||||
}
|
||||
|
||||
|
@ -110,7 +103,7 @@ export default class CollectionReference {
|
|||
return this._query.startAt(snapshotOrVarArgs);
|
||||
}
|
||||
|
||||
where(fieldPath: string, opStr: FirestoreQueryOperator, value: any): Query {
|
||||
where(fieldPath: string, opStr: QueryOperator, value: any): Query {
|
||||
return this._query.where(fieldPath, opStr, value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import DocumentSnapshot from './DocumentSnapshot';
|
||||
|
||||
import type Firestore from './';
|
||||
import type { FirestoreNativeDocumentChange } from '../../types';
|
||||
import type { NativeDocumentChange } from './types';
|
||||
|
||||
/**
|
||||
* @class DocumentChange
|
||||
|
@ -16,7 +16,7 @@ export default class DocumentChange {
|
|||
_oldIndex: number;
|
||||
_type: string;
|
||||
|
||||
constructor(firestore: Firestore, nativeData: FirestoreNativeDocumentChange) {
|
||||
constructor(firestore: Firestore, nativeData: NativeDocumentChange) {
|
||||
this._document = new DocumentSnapshot(firestore, nativeData.document);
|
||||
this._newIndex = nativeData.newIndex;
|
||||
this._oldIndex = nativeData.oldIndex;
|
||||
|
|
|
@ -14,15 +14,12 @@ import { getNativeModule } from '../../utils/native';
|
|||
|
||||
import type Firestore from './';
|
||||
import type {
|
||||
FirestoreNativeDocumentSnapshot,
|
||||
FirestoreWriteOptions,
|
||||
} from '../../types';
|
||||
DocumentListenOptions,
|
||||
NativeDocumentSnapshot,
|
||||
SetOptions,
|
||||
} from './types';
|
||||
import type Path from './Path';
|
||||
|
||||
type DocumentListenOptions = {
|
||||
includeMetadataChanges: boolean,
|
||||
};
|
||||
|
||||
type ObserverOnError = Object => void;
|
||||
type ObserverOnNext = DocumentSnapshot => void;
|
||||
|
||||
|
@ -189,9 +186,7 @@ export default class DocumentReference {
|
|||
}
|
||||
const listenerId = firestoreAutoId();
|
||||
|
||||
const listener = (
|
||||
nativeDocumentSnapshot: FirestoreNativeDocumentSnapshot
|
||||
) => {
|
||||
const listener = (nativeDocumentSnapshot: NativeDocumentSnapshot) => {
|
||||
const documentSnapshot = new DocumentSnapshot(
|
||||
this.firestore,
|
||||
nativeDocumentSnapshot
|
||||
|
@ -227,12 +222,12 @@ export default class DocumentReference {
|
|||
return this._offDocumentSnapshot.bind(this, listenerId, listener);
|
||||
}
|
||||
|
||||
set(data: Object, writeOptions?: FirestoreWriteOptions): Promise<void> {
|
||||
set(data: Object, options?: SetOptions): Promise<void> {
|
||||
const nativeData = buildNativeMap(data);
|
||||
return getNativeModule(this._firestore).documentSet(
|
||||
this.path,
|
||||
nativeData,
|
||||
writeOptions
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,10 +9,7 @@ import { isObject } from '../../utils';
|
|||
import { parseNativeMap } from './utils/serialize';
|
||||
|
||||
import type Firestore from './';
|
||||
import type {
|
||||
FirestoreNativeDocumentSnapshot,
|
||||
FirestoreSnapshotMetadata,
|
||||
} from '../../types';
|
||||
import type { NativeDocumentSnapshot, SnapshotMetadata } from './types';
|
||||
|
||||
const extractFieldPathData = (data: Object | void, segments: string[]): any => {
|
||||
if (!data || !isObject(data)) {
|
||||
|
@ -30,13 +27,10 @@ const extractFieldPathData = (data: Object | void, segments: string[]): any => {
|
|||
*/
|
||||
export default class DocumentSnapshot {
|
||||
_data: Object | void;
|
||||
_metadata: FirestoreSnapshotMetadata;
|
||||
_metadata: SnapshotMetadata;
|
||||
_ref: DocumentReference;
|
||||
|
||||
constructor(
|
||||
firestore: Firestore,
|
||||
nativeData: FirestoreNativeDocumentSnapshot
|
||||
) {
|
||||
constructor(firestore: Firestore, nativeData: NativeDocumentSnapshot) {
|
||||
this._data = parseNativeMap(firestore, nativeData.data);
|
||||
this._metadata = nativeData.metadata;
|
||||
this._ref = new DocumentReference(
|
||||
|
@ -53,7 +47,7 @@ export default class DocumentSnapshot {
|
|||
return this._ref.id;
|
||||
}
|
||||
|
||||
get metadata(): FirestoreSnapshotMetadata {
|
||||
get metadata(): SnapshotMetadata {
|
||||
return this._metadata;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,20 +12,21 @@ import { firestoreAutoId, isFunction, isObject } from '../../utils';
|
|||
import { getNativeModule } from '../../utils/native';
|
||||
|
||||
import type Firestore from './';
|
||||
import type {
|
||||
FirestoreQueryDirection,
|
||||
FirestoreQueryOperator,
|
||||
} from '../../types';
|
||||
import type Path from './Path';
|
||||
import type {
|
||||
QueryDirection,
|
||||
QueryOperator,
|
||||
QueryListenOptions,
|
||||
} from './types';
|
||||
|
||||
const DIRECTIONS: { [FirestoreQueryDirection]: string } = {
|
||||
const DIRECTIONS: { [QueryDirection]: string } = {
|
||||
ASC: 'ASCENDING',
|
||||
asc: 'ASCENDING',
|
||||
DESC: 'DESCENDING',
|
||||
desc: 'DESCENDING',
|
||||
};
|
||||
|
||||
const OPERATORS: { [FirestoreQueryOperator]: string } = {
|
||||
const OPERATORS: { [QueryOperator]: string } = {
|
||||
'=': 'EQUAL',
|
||||
'==': 'EQUAL',
|
||||
'>': 'GREATER_THAN',
|
||||
|
@ -58,11 +59,6 @@ type QueryOptions = {
|
|||
startAt?: any[],
|
||||
};
|
||||
|
||||
export type QueryListenOptions = {|
|
||||
includeDocumentMetadataChanges: boolean,
|
||||
includeQueryMetadataChanges: boolean,
|
||||
|};
|
||||
|
||||
export type ObserverOnError = Object => void;
|
||||
export type ObserverOnNext = QuerySnapshot => void;
|
||||
|
||||
|
@ -320,7 +316,7 @@ export default class Query {
|
|||
|
||||
orderBy(
|
||||
fieldPath: string | FieldPath,
|
||||
directionStr?: FirestoreQueryDirection = 'asc'
|
||||
directionStr?: QueryDirection = 'asc'
|
||||
): Query {
|
||||
// TODO: Validation
|
||||
// validate.isFieldPath('fieldPath', fieldPath);
|
||||
|
@ -379,7 +375,7 @@ export default class Query {
|
|||
|
||||
where(
|
||||
fieldPath: string | FieldPath,
|
||||
opStr: FirestoreQueryOperator,
|
||||
opStr: QueryOperator,
|
||||
value: any
|
||||
): Query {
|
||||
// TODO: Validation
|
||||
|
|
|
@ -7,16 +7,16 @@ import DocumentSnapshot from './DocumentSnapshot';
|
|||
|
||||
import type Firestore from './';
|
||||
import type {
|
||||
FirestoreNativeDocumentChange,
|
||||
FirestoreNativeDocumentSnapshot,
|
||||
FirestoreSnapshotMetadata,
|
||||
} from '../../types';
|
||||
NativeDocumentChange,
|
||||
NativeDocumentSnapshot,
|
||||
SnapshotMetadata,
|
||||
} from './types';
|
||||
import type Query from './Query';
|
||||
|
||||
type QuerySnapshotNativeData = {
|
||||
changes: FirestoreNativeDocumentChange[],
|
||||
documents: FirestoreNativeDocumentSnapshot[],
|
||||
metadata: FirestoreSnapshotMetadata,
|
||||
type NativeQuerySnapshot = {
|
||||
changes: NativeDocumentChange[],
|
||||
documents: NativeDocumentSnapshot[],
|
||||
metadata: SnapshotMetadata,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -25,13 +25,13 @@ type QuerySnapshotNativeData = {
|
|||
export default class QuerySnapshot {
|
||||
_changes: DocumentChange[];
|
||||
_docs: DocumentSnapshot[];
|
||||
_metadata: FirestoreSnapshotMetadata;
|
||||
_metadata: SnapshotMetadata;
|
||||
_query: Query;
|
||||
|
||||
constructor(
|
||||
firestore: Firestore,
|
||||
query: Query,
|
||||
nativeData: QuerySnapshotNativeData
|
||||
nativeData: NativeQuerySnapshot
|
||||
) {
|
||||
this._changes = nativeData.changes.map(
|
||||
change => new DocumentChange(firestore, change)
|
||||
|
@ -55,7 +55,7 @@ export default class QuerySnapshot {
|
|||
return this._docs.length === 0;
|
||||
}
|
||||
|
||||
get metadata(): FirestoreSnapshotMetadata {
|
||||
get metadata(): SnapshotMetadata {
|
||||
return this._metadata;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import { getNativeModule } from '../../utils/native';
|
|||
|
||||
import type DocumentReference from './DocumentReference';
|
||||
import type Firestore from './';
|
||||
import type { FirestoreWriteOptions } from '../../types';
|
||||
import type { SetOptions } from './types';
|
||||
|
||||
type DocumentWrite = {
|
||||
data?: Object,
|
||||
|
@ -47,19 +47,15 @@ export default class WriteBatch {
|
|||
return this;
|
||||
}
|
||||
|
||||
set(
|
||||
docRef: DocumentReference,
|
||||
data: Object,
|
||||
writeOptions?: FirestoreWriteOptions
|
||||
) {
|
||||
set(docRef: DocumentReference, data: Object, options?: SetOptions) {
|
||||
// TODO: Validation
|
||||
// validate.isDocumentReference('docRef', docRef);
|
||||
// validate.isDocument('data', data);
|
||||
// validate.isOptionalPrecondition('writeOptions', writeOptions);
|
||||
// validate.isOptionalPrecondition('options', writeOptions);
|
||||
const nativeData = buildNativeMap(data);
|
||||
this._writes.push({
|
||||
data: nativeData,
|
||||
options: writeOptions,
|
||||
options,
|
||||
path: docRef.path,
|
||||
type: 'SET',
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ import WriteBatch from './WriteBatch';
|
|||
import INTERNALS from '../../utils/internals';
|
||||
|
||||
import type DocumentSnapshot from './DocumentSnapshot';
|
||||
import type App from '../core/firebase-app';
|
||||
import type App from '../core/app';
|
||||
import type QuerySnapshot from './QuerySnapshot';
|
||||
|
||||
type CollectionSyncEvent = {
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* @flow
|
||||
*/
|
||||
|
||||
export type DocumentListenOptions = {
|
||||
includeMetadataChanges: boolean,
|
||||
};
|
||||
|
||||
export type QueryDirection = 'DESC' | 'desc' | 'ASC' | 'asc';
|
||||
|
||||
export type QueryListenOptions = {|
|
||||
includeDocumentMetadataChanges: boolean,
|
||||
includeQueryMetadataChanges: boolean,
|
||||
|};
|
||||
|
||||
export type QueryOperator = '<' | '<=' | '=' | '==' | '>' | '>=';
|
||||
|
||||
export type SetOptions = {
|
||||
merge?: boolean,
|
||||
};
|
||||
|
||||
export type SnapshotMetadata = {
|
||||
fromCache: boolean,
|
||||
hasPendingWrites: boolean,
|
||||
};
|
||||
|
||||
export type NativeDocumentChange = {
|
||||
document: NativeDocumentSnapshot,
|
||||
newIndex: number,
|
||||
oldIndex: number,
|
||||
type: string,
|
||||
};
|
||||
|
||||
export type NativeDocumentSnapshot = {
|
||||
data: { [string]: NativeTypeMap },
|
||||
metadata: SnapshotMetadata,
|
||||
path: string,
|
||||
};
|
||||
|
||||
export type NativeTypeMap = {
|
||||
type:
|
||||
| 'array'
|
||||
| 'boolean'
|
||||
| 'date'
|
||||
| 'documentid'
|
||||
| 'fieldvalue'
|
||||
| 'geopoint'
|
||||
| 'null'
|
||||
| 'number'
|
||||
| 'object'
|
||||
| 'reference'
|
||||
| 'string',
|
||||
value: any,
|
||||
};
|
|
@ -13,7 +13,7 @@ import Path from '../Path';
|
|||
import { typeOf } from '../../../utils';
|
||||
|
||||
import type Firestore from '../';
|
||||
import type { FirestoreTypeMap } from '../../../types';
|
||||
import type { NativeTypeMap } from '../types';
|
||||
|
||||
/*
|
||||
* Functions that build up the data needed to represent
|
||||
|
@ -21,9 +21,7 @@ import type { FirestoreTypeMap } from '../../../types';
|
|||
* for transmission to the native side
|
||||
*/
|
||||
|
||||
export const buildNativeMap = (
|
||||
data: Object
|
||||
): { [string]: FirestoreTypeMap } => {
|
||||
export const buildNativeMap = (data: Object): { [string]: NativeTypeMap } => {
|
||||
const nativeData = {};
|
||||
if (data) {
|
||||
Object.keys(data).forEach(key => {
|
||||
|
@ -36,7 +34,7 @@ export const buildNativeMap = (
|
|||
return nativeData;
|
||||
};
|
||||
|
||||
export const buildNativeArray = (array: Object[]): FirestoreTypeMap[] => {
|
||||
export const buildNativeArray = (array: Object[]): NativeTypeMap[] => {
|
||||
const nativeArray = [];
|
||||
if (array) {
|
||||
array.forEach(value => {
|
||||
|
@ -49,7 +47,7 @@ export const buildNativeArray = (array: Object[]): FirestoreTypeMap[] => {
|
|||
return nativeArray;
|
||||
};
|
||||
|
||||
export const buildTypeMap = (value: any): FirestoreTypeMap | null => {
|
||||
export const buildTypeMap = (value: any): NativeTypeMap | null => {
|
||||
const type = typeOf(value);
|
||||
if (value === null || value === undefined) {
|
||||
return {
|
||||
|
@ -117,7 +115,7 @@ export const buildTypeMap = (value: any): FirestoreTypeMap | null => {
|
|||
|
||||
export const parseNativeMap = (
|
||||
firestore: Firestore,
|
||||
nativeData: { [string]: FirestoreTypeMap }
|
||||
nativeData: { [string]: NativeTypeMap }
|
||||
): Object | void => {
|
||||
let data;
|
||||
if (nativeData) {
|
||||
|
@ -131,7 +129,7 @@ export const parseNativeMap = (
|
|||
|
||||
const parseNativeArray = (
|
||||
firestore: Firestore,
|
||||
nativeArray: FirestoreTypeMap[]
|
||||
nativeArray: NativeTypeMap[]
|
||||
): any[] => {
|
||||
const array = [];
|
||||
if (nativeArray) {
|
||||
|
@ -142,7 +140,7 @@ const parseNativeArray = (
|
|||
return array;
|
||||
};
|
||||
|
||||
const parseTypeMap = (firestore: Firestore, typeMap: FirestoreTypeMap): any => {
|
||||
const parseTypeMap = (firestore: Firestore, typeMap: NativeTypeMap): any => {
|
||||
const { type, value } = typeMap;
|
||||
if (type === 'null') {
|
||||
return null;
|
||||
|
|
|
@ -7,7 +7,7 @@ import ModuleBase from '../../utils/ModuleBase';
|
|||
import { areObjectKeysContainedInOther, isObject, isString } from '../../utils';
|
||||
import { getNativeModule } from '../../utils/native';
|
||||
|
||||
import type App from '../core/firebase-app';
|
||||
import type App from '../core/app';
|
||||
|
||||
const EVENT_TYPE = {
|
||||
Link: 'dynamic_link_received',
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
RemoteNotificationResult,
|
||||
} from './types';
|
||||
|
||||
import type App from '../core/firebase-app';
|
||||
import type App from '../core/app';
|
||||
import type { NativeMessage } from './types';
|
||||
|
||||
type OnMessage = Message => any;
|
||||
|
|
|
@ -6,7 +6,7 @@ import Trace from './Trace';
|
|||
import ModuleBase from '../../utils/ModuleBase';
|
||||
import { getNativeModule } from '../../utils/native';
|
||||
|
||||
import type App from '../core/firebase-app';
|
||||
import type App from '../core/app';
|
||||
|
||||
export const MODULE_NAME = 'RNFirebasePerformance';
|
||||
export const NAMESPACE = 'perf';
|
||||
|
|
|
@ -10,7 +10,7 @@ import { getLogger } from '../../utils/log';
|
|||
import ModuleBase from '../../utils/ModuleBase';
|
||||
import { getNativeModule } from '../../utils/native';
|
||||
|
||||
import type App from '../core/firebase-app';
|
||||
import type App from '../core/app';
|
||||
|
||||
const FirebaseStorage = NativeModules.RNFirebaseStorage;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import { NativeModules } from 'react-native';
|
|||
import INTERNALS from '../../utils/internals';
|
||||
import { isIOS } from '../../utils';
|
||||
import ModuleBase from '../../utils/ModuleBase';
|
||||
import type App from '../core/firebase-app';
|
||||
import type App from '../core/app';
|
||||
|
||||
const FirebaseCoreModule = NativeModules.RNFirebase;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ export type FirebaseModuleConfig = {
|
|||
};
|
||||
|
||||
export type FirebaseModuleName =
|
||||
| 'RNFirebaseAdmob'
|
||||
| 'RNFirebaseAdMob'
|
||||
| 'RNFirebaseAnalytics'
|
||||
| 'RNFirebaseAuth'
|
||||
| 'RNFirebaseRemoteConfig'
|
||||
|
@ -170,47 +170,6 @@ export type FirestoreModule = {
|
|||
nativeModuleExists: boolean,
|
||||
} & FirestoreStatics;
|
||||
|
||||
export type FirestoreNativeDocumentChange = {
|
||||
document: FirestoreNativeDocumentSnapshot,
|
||||
newIndex: number,
|
||||
oldIndex: number,
|
||||
type: string,
|
||||
};
|
||||
|
||||
export type FirestoreNativeDocumentSnapshot = {
|
||||
data: { [string]: FirestoreTypeMap },
|
||||
metadata: FirestoreSnapshotMetadata,
|
||||
path: string,
|
||||
};
|
||||
|
||||
export type FirestoreSnapshotMetadata = {
|
||||
fromCache: boolean,
|
||||
hasPendingWrites: boolean,
|
||||
};
|
||||
|
||||
export type FirestoreQueryDirection = 'DESC' | 'desc' | 'ASC' | 'asc';
|
||||
export type FirestoreQueryOperator = '<' | '<=' | '=' | '==' | '>' | '>=';
|
||||
|
||||
export type FirestoreTypeMap = {
|
||||
type:
|
||||
| 'array'
|
||||
| 'boolean'
|
||||
| 'date'
|
||||
| 'documentid'
|
||||
| 'fieldvalue'
|
||||
| 'geopoint'
|
||||
| 'null'
|
||||
| 'number'
|
||||
| 'object'
|
||||
| 'reference'
|
||||
| 'string',
|
||||
value: any,
|
||||
};
|
||||
|
||||
export type FirestoreWriteOptions = {
|
||||
merge?: boolean,
|
||||
};
|
||||
|
||||
/* InstanceId types */
|
||||
|
||||
export type InstanceIdModule = {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
import { initialiseLogger } from './log';
|
||||
import { initialiseNativeModule } from './native';
|
||||
|
||||
import type App from '../modules/core/firebase-app';
|
||||
import type App from '../modules/core/app';
|
||||
import type { FirebaseModuleConfig, FirebaseNamespace } from '../types';
|
||||
|
||||
export default class ModuleBase {
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
import { NativeEventEmitter, NativeModules } from 'react-native';
|
||||
|
||||
import { SharedEventEmitter } from './events';
|
||||
import DatabaseSnapshot from '../modules/database/snapshot';
|
||||
import DatabaseReference from '../modules/database/reference';
|
||||
import DataSnapshot from '../modules/database/DataSnapshot';
|
||||
import DatabaseReference from '../modules/database/Reference';
|
||||
import { isString, nativeToJSError } from '../utils';
|
||||
|
||||
type Listener = DatabaseSnapshot => any;
|
||||
type Listener = DataSnapshot => any;
|
||||
|
||||
type Registration = {
|
||||
key: string,
|
||||
|
@ -83,7 +83,7 @@ class SyncTree {
|
|||
// forward on to users .on(successCallback <-- listener
|
||||
return SharedEventEmitter.emit(
|
||||
eventRegistrationKey,
|
||||
new DatabaseSnapshot(registration.ref, snapshot),
|
||||
new DataSnapshot(registration.ref, snapshot),
|
||||
previousChildName
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @flow
|
||||
*/
|
||||
import { NativeModules } from 'react-native';
|
||||
import App from '../modules/core/firebase-app';
|
||||
import App from '../modules/core/app';
|
||||
import INTERNALS from './internals';
|
||||
import { isAndroid, isObject, isString } from './';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "react-native-firebase",
|
||||
"version": "3.2.2",
|
||||
"version": "3.2.5",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -8086,6 +8086,12 @@
|
|||
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
|
||||
"dev": true
|
||||
},
|
||||
"typescript": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.6.2.tgz",
|
||||
"integrity": "sha1-PFtv1/beCRQmkCfwPAlGdY92c6Q=",
|
||||
"dev": true
|
||||
},
|
||||
"ua-parser-js": {
|
||||
"version": "0.7.17",
|
||||
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.17.tgz",
|
||||
|
|
18
package.json
18
package.json
|
@ -1,17 +1,18 @@
|
|||
{
|
||||
"name": "react-native-firebase",
|
||||
"version": "3.2.2",
|
||||
"version": "3.2.5",
|
||||
"author": "Invertase <contact@invertase.io> (http://invertase.io)",
|
||||
"description": "A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Messaging (FCM), Remote Config, Storage and Performance.",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "genversion lib/version.js && npm run build-lib && npm run build-flow",
|
||||
"build": "genversion lib/version.js && npm run validate-ts-declarations && npm run build-lib && npm run build-flow",
|
||||
"build-flow": "flow-copy-source -i */__tests__* lib dist",
|
||||
"build-lib": "BABEL_ENV=publish babel lib -d dist --ignore __tests__ --copy-files",
|
||||
"clean": "rimraf dist/",
|
||||
"flow": "flow",
|
||||
"format": "eslint --fix ./lib ./tests/src ./tests/lib",
|
||||
"format:assets": "prettier --ignore-path .gitignore --write \"**/*.{json,md}\"",
|
||||
"format": "npm run format:assets && npm run lint -- --fix",
|
||||
"lint": "eslint ./lib ./tests/src ./tests/lib",
|
||||
"precommit": "lint-staged",
|
||||
"prepublish": "npm run clean && npm run build",
|
||||
|
@ -21,7 +22,8 @@
|
|||
"tests-npm-install": "cd tests && npm install",
|
||||
"tests-pod-install": "cd tests && npm run ios:pod:install",
|
||||
"tests-watch-start": "npm run test-cli watch init start",
|
||||
"tests-watch-stop": "npm run test-cli watch stop"
|
||||
"tests-watch-stop": "npm run test-cli watch stop",
|
||||
"validate-ts-declarations": "tsc --project ./"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -44,6 +46,7 @@
|
|||
"auth",
|
||||
"config",
|
||||
"digits",
|
||||
"fabric",
|
||||
"phone-auth",
|
||||
"sms",
|
||||
"firestore",
|
||||
|
@ -101,6 +104,7 @@
|
|||
"react-native": "^0.52.0",
|
||||
"rimraf": "^2.6.2",
|
||||
"shelljs": "^0.7.8",
|
||||
"typescript": "^2.6.2",
|
||||
"wml": "0.0.82"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -129,12 +133,12 @@
|
|||
"eslint --fix",
|
||||
"git add"
|
||||
],
|
||||
"tests/src/**/*.js": [
|
||||
"tests/{src|lib}/**/*.js": [
|
||||
"eslint --fix",
|
||||
"git add"
|
||||
],
|
||||
"tests/lib/**/*.js": [
|
||||
"eslint --fix",
|
||||
"*.{json,md,scss}": [
|
||||
"prettier --write",
|
||||
"git add"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,4 +1,12 @@
|
|||
module.exports = {
|
||||
trailingComma: 'es5',
|
||||
singleQuote: true,
|
||||
overrides: [
|
||||
{
|
||||
files: '*.json',
|
||||
options: {
|
||||
printWidth: 400,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
|
@ -143,11 +143,10 @@ android {
|
|||
project.ext.firebaseVersion = '11.8.0'
|
||||
|
||||
dependencies {
|
||||
// compile(project(':react-native-firebase')) {
|
||||
// transitive = false
|
||||
// }
|
||||
compile project(':react-native-vector-icons')
|
||||
compile project(':react-native-firebase')
|
||||
compile(project(':react-native-firebase')) {
|
||||
transitive = false
|
||||
}
|
||||
compile fileTree(dir: "libs", include: ["*.jar"])
|
||||
compile "com.google.android.gms:play-services-base:$firebaseVersion"
|
||||
compile "com.google.firebase:firebase-ads:$firebaseVersion"
|
||||
|
|
|
@ -164,7 +164,7 @@ PODS:
|
|||
- React/Core
|
||||
- React/fishhook
|
||||
- React/RCTBlob
|
||||
- RNFirebase (3.2.2):
|
||||
- RNFirebase (3.2.4):
|
||||
- React
|
||||
- yoga (0.52.0.React)
|
||||
|
||||
|
@ -228,7 +228,7 @@ SPEC CHECKSUMS:
|
|||
nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
|
||||
Protobuf: 8a9838fba8dae3389230e1b7f8c104aa32389c03
|
||||
React: 61a6bdf17a9ff16875c230e6ff278d9de274e16c
|
||||
RNFirebase: 5cf5405d1b67c9720ce63a2da3d6d5346415d0f7
|
||||
RNFirebase: 011e47909cf54070f72d50b8d61eb7b347774d29
|
||||
yoga: 646606bf554d54a16711f35596178522fbc00480
|
||||
|
||||
PODFILE CHECKSUM: 67c98bcb203cb992da590bcab6f690f727653ca5
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"jsx": "react",
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"moduleResolution": "node",
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"lib": ["es2015", "es2016", "esnext", "dom"]
|
||||
},
|
||||
"files": ["./lib/index.d.ts"]
|
||||
}
|
Loading…
Reference in New Issue