2018-05-12 23:48:57 +00:00
|
|
|
// Type definitions for React Native Firebase v4.2.0
|
2017-03-22 22:43:20 +00:00
|
|
|
// Project: https://github.com/invertase/react-native-firebase
|
2018-05-07 18:49:34 +00:00
|
|
|
// Definitions by: React Native Firebase Contributors
|
2017-03-23 10:06:07 +00:00
|
|
|
// TypeScript Version: 2.1
|
2017-03-22 22:43:20 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
declare module 'react-native-firebase' {
|
2018-01-26 16:39:52 +00:00
|
|
|
/** 3rd party provider Credentials */
|
|
|
|
type AuthCredential = {
|
2018-05-04 15:30:32 +00:00
|
|
|
providerId: string;
|
|
|
|
token: string;
|
|
|
|
secret: string;
|
|
|
|
};
|
2018-01-26 16:39:52 +00:00
|
|
|
|
2018-01-29 05:14:06 +00:00
|
|
|
type FirebaseModuleAndStatics<M, S = {}> = {
|
|
|
|
(): M;
|
|
|
|
nativeModuleExists: boolean;
|
2018-05-04 15:30:32 +00:00
|
|
|
} & S;
|
2018-01-29 05:14:06 +00:00
|
|
|
|
|
|
|
// Modules commented-out do not currently have type definitions
|
|
|
|
export class Firebase {
|
|
|
|
private constructor();
|
|
|
|
// admob: FirebaseModuleAndStatics<RNFirebase.admob.AdMob>;
|
|
|
|
analytics: FirebaseModuleAndStatics<RNFirebase.Analytics>;
|
2018-05-04 15:30:32 +00:00
|
|
|
auth: FirebaseModuleAndStatics<
|
|
|
|
RNFirebase.auth.Auth,
|
|
|
|
RNFirebase.auth.AuthStatics
|
|
|
|
>;
|
2018-01-29 05:14:06 +00:00
|
|
|
// config: FirebaseModule<RNFirebase.config.Config>;
|
|
|
|
crash: FirebaseModuleAndStatics<RNFirebase.crash.Crash>;
|
2018-04-03 15:51:05 +00:00
|
|
|
crashlytics: FirebaseModuleAndStatics<RNFirebase.crashlytics.Crashlytics>;
|
2018-05-04 15:30:32 +00:00
|
|
|
database: FirebaseModuleAndStatics<
|
|
|
|
RNFirebase.database.Database,
|
|
|
|
RNFirebase.database.DatabaseStatics
|
|
|
|
>;
|
|
|
|
firestore: FirebaseModuleAndStatics<
|
|
|
|
RNFirebase.firestore.Firestore,
|
|
|
|
RNFirebase.firestore.FirestoreStatics
|
|
|
|
>;
|
2018-05-07 18:49:34 +00:00
|
|
|
functions: FirebaseModuleAndStatics<
|
|
|
|
RNFirebase.functions.Functions,
|
|
|
|
RNFirebase.functions.FunctionsStatics
|
|
|
|
>;
|
2018-05-04 15:30:32 +00:00
|
|
|
iid: FirebaseModuleAndStatics<RNFirebase.iid.InstanceId>;
|
2018-03-23 17:31:25 +00:00
|
|
|
// invites: FirebaseModuleAndStatics<RNFirebase.invites.Invites>
|
2018-05-04 15:30:32 +00:00
|
|
|
links: FirebaseModuleAndStatics<
|
|
|
|
RNFirebase.links.Links,
|
|
|
|
RNFirebase.links.LinksStatics
|
|
|
|
>;
|
|
|
|
messaging: FirebaseModuleAndStatics<
|
|
|
|
RNFirebase.messaging.Messaging,
|
|
|
|
RNFirebase.messaging.MessagingStatics
|
|
|
|
>;
|
|
|
|
notifications: FirebaseModuleAndStatics<
|
|
|
|
RNFirebase.notifications.Notifications,
|
|
|
|
RNFirebase.notifications.NotificationsStatics
|
|
|
|
>;
|
2018-01-29 05:14:06 +00:00
|
|
|
// 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;
|
2018-01-31 09:09:12 +00:00
|
|
|
readonly apps: App[];
|
|
|
|
readonly SDK_VERSION: string;
|
2018-01-29 05:14:06 +00:00
|
|
|
}
|
|
|
|
namespace Firebase {
|
|
|
|
interface Options {
|
|
|
|
apiKey: string;
|
|
|
|
appId: string;
|
|
|
|
databaseURL: string;
|
|
|
|
messagingSenderId: string;
|
|
|
|
projectId: string;
|
|
|
|
storageBucket: string;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const firebase: Firebase;
|
|
|
|
export default firebase;
|
2017-07-05 13:56:18 +00:00
|
|
|
|
2018-01-29 05:14:06 +00:00
|
|
|
// Modules commented-out do not currently have type definitions
|
|
|
|
export class App {
|
|
|
|
private constructor();
|
|
|
|
// admob(): RNFirebase.admob.AdMob;
|
2017-03-23 12:58:03 +00:00
|
|
|
analytics(): RNFirebase.Analytics;
|
2018-01-29 05:14:06 +00:00
|
|
|
auth(): RNFirebase.auth.Auth;
|
|
|
|
// config(): RNFirebase.config.Config;
|
2017-03-30 14:09:48 +00:00
|
|
|
crash(): RNFirebase.crash.Crash;
|
2018-04-03 15:51:05 +00:00
|
|
|
crashlytics(): RNFirebase.crashlytics.Crashlytics;
|
2018-01-29 05:14:06 +00:00
|
|
|
database(): RNFirebase.database.Database;
|
2018-01-29 23:07:07 +00:00
|
|
|
firestore(): RNFirebase.firestore.Firestore;
|
2018-05-07 18:49:34 +00:00
|
|
|
functions(): RNFirebase.functions.Functions;
|
2018-03-23 17:31:25 +00:00
|
|
|
iid(): RNFirebase.iid.InstanceId;
|
|
|
|
// invites(): RNFirebase.invites.Invites;
|
2018-01-29 05:14:06 +00:00
|
|
|
links(): RNFirebase.links.Links;
|
|
|
|
messaging(): RNFirebase.messaging.Messaging;
|
2018-03-23 17:31:25 +00:00
|
|
|
notifications(): RNFirebase.notifications.Notifications;
|
2018-01-29 05:14:06 +00:00
|
|
|
// perf(): RNFirebase.perf.Performance;
|
|
|
|
storage(): RNFirebase.storage.Storage;
|
|
|
|
// utils(): RNFirebase.utils.Utils;
|
2018-01-31 09:09:12 +00:00
|
|
|
readonly name: string;
|
|
|
|
readonly options: Firebase.Options;
|
2018-04-08 09:46:41 +00:00
|
|
|
|
|
|
|
onReady: () => Promise<App>;
|
2017-03-22 22:43:20 +00:00
|
|
|
}
|
|
|
|
|
2018-01-29 05:14:06 +00:00
|
|
|
export namespace RNFirebase {
|
2017-03-28 21:49:12 +00:00
|
|
|
interface RnError extends Error {
|
|
|
|
code?: string;
|
|
|
|
}
|
2017-03-30 14:09:48 +00:00
|
|
|
|
|
|
|
type GoogleApiAvailabilityType = {
|
2018-05-04 15:30:32 +00:00
|
|
|
status: number;
|
|
|
|
isAvailable: boolean;
|
|
|
|
isUserResolvableError?: boolean;
|
|
|
|
error?: string;
|
2017-03-30 14:09:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2017-07-05 13:56:18 +00:00
|
|
|
* pass custom options by passing an object with configuration options.
|
|
|
|
* The configuration object will be generated first by the native configuration object, if set and then will be overridden if passed in JS.
|
|
|
|
* That is, all of the following key/value pairs are optional if the native configuration is set.
|
|
|
|
*/
|
2017-03-30 14:09:48 +00:00
|
|
|
interface configurationOptions {
|
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* default false
|
2017-03-30 14:09:48 +00:00
|
|
|
* When set to true, RNFirebase will log messages to the console and fire debug events we can listen to in js
|
2017-06-19 11:25:58 +00:00
|
|
|
* @usage
|
2017-03-30 14:09:48 +00:00
|
|
|
* firebase.on('debug', msg => console.log('Received debug message', msg))
|
|
|
|
*/
|
|
|
|
debug?: boolean;
|
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* default false
|
2017-03-30 14:09:48 +00:00
|
|
|
* When set to true, database persistence will be enabled.
|
|
|
|
*/
|
|
|
|
persistence?: boolean;
|
|
|
|
/**
|
2017-07-05 13:56:18 +00:00
|
|
|
* Default from app [NSBundle mainBundle] The bundle ID for the app to be bundled with
|
2017-03-30 14:09:48 +00:00
|
|
|
*/
|
|
|
|
bundleID?: string;
|
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* defualt ""
|
2017-03-30 14:09:48 +00:00
|
|
|
* The Google App ID that is used to uniquely identify an instance of an app.
|
|
|
|
*/
|
|
|
|
googleAppID?: string;
|
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* deufalt ""
|
2017-03-30 14:09:48 +00:00
|
|
|
* The database root (i.e. https://my-app.firebaseio.com)
|
|
|
|
*/
|
|
|
|
databaseURL?: string;
|
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* defualt ""
|
2017-03-30 14:09:48 +00:00
|
|
|
* URL scheme to set up durable deep link service
|
|
|
|
*/
|
|
|
|
deepLinkURLScheme?: string;
|
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* defualt ""
|
2017-03-30 14:09:48 +00:00
|
|
|
* The Google Cloud storage bucket name
|
|
|
|
*/
|
|
|
|
storageBucket?: string;
|
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* default ""
|
2017-03-30 14:09:48 +00:00
|
|
|
* The Android client ID used in Google AppInvite when an iOS app has it's android version
|
|
|
|
*/
|
|
|
|
androidClientID?: string;
|
|
|
|
/**
|
2017-07-05 13:56:18 +00:00
|
|
|
* default ""
|
2017-03-30 14:09:48 +00:00
|
|
|
* The Project number from the Google Developer's console used to configure Google Cloud Messaging
|
|
|
|
*/
|
|
|
|
GCMSenderID?: string;
|
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* default ""
|
2017-03-30 14:09:48 +00:00
|
|
|
* The tracking ID for Google Analytics
|
|
|
|
*/
|
|
|
|
trackingID?: string;
|
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* default ""
|
2017-03-30 14:09:48 +00:00
|
|
|
* The OAuth2 client ID for iOS application used to authenticate Google Users for signing in with Google
|
|
|
|
*/
|
|
|
|
clientID?: string;
|
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* defualt ""
|
2017-03-30 14:09:48 +00:00
|
|
|
* The secret iOS API key used for authenticating requests from our app
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
APIKey?: string;
|
2017-03-30 14:09:48 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
namespace storage {
|
|
|
|
interface StorageTask<T> extends Promise<T> {
|
2018-05-04 15:30:32 +00:00
|
|
|
on(
|
|
|
|
event: TaskEvent,
|
|
|
|
nextOrObserver: (snapshot: any) => any,
|
|
|
|
error: (error: RnError) => any,
|
|
|
|
complete: (complete: any) => any
|
|
|
|
): any;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
/**
|
|
|
|
* is not currently supported by react-native-firebase
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
pause(): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
/**
|
|
|
|
* is not currently supported by react-native-firebase
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
resume(): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
/**
|
|
|
|
* is not currently supported by react-native-firebase
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
cancel(): void;
|
2017-03-23 12:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface RNStorage extends Reference {
|
|
|
|
/**
|
|
|
|
* Downloads a reference to the device
|
|
|
|
* @param {String} filePath Where to store the file
|
|
|
|
* @return {Promise}
|
|
|
|
* */
|
2017-03-30 14:09:48 +00:00
|
|
|
downloadFile(filePath: string): StorageTask<any>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
/**
|
|
|
|
* Upload a file path
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
2017-03-30 14:09:48 +00:00
|
|
|
putFile(filePath: string, metadata?: any): StorageTask<any>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
setMaxDownloadRetryTime(time: number): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-04-26 19:12:59 +00:00
|
|
|
[key: string]: any;
|
2017-03-23 12:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface Storage {
|
|
|
|
maxOperationRetryTime: number;
|
|
|
|
maxUploadRetryTime: number;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
ref(path?: string): storage.RNStorage;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
refFromURL(url: string): storage.RNStorage;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
setMaxOperationRetryTime(time: number): any;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
setMaxUploadRetryTime(time: number): any;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Reference {
|
|
|
|
bucket: string;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
child(path: string): storage.Reference;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
delete(): Promise<any>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
fullPath: string;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
getDownloadURL(): Promise<any>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
getMetadata(): Promise<any>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
name: string;
|
|
|
|
parent: storage.Reference | null;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
put(
|
|
|
|
data: any | Uint8Array | ArrayBuffer,
|
|
|
|
metadata?: storage.UploadMetadata
|
|
|
|
): storage.UploadTask;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
putString(
|
|
|
|
data: string,
|
|
|
|
format?: storage.StringFormat,
|
|
|
|
metadata?: storage.UploadMetadata
|
|
|
|
): storage.UploadTask;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
root: storage.Reference;
|
|
|
|
storage: storage.Storage;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
toString(): string;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-07-05 13:56:18 +00:00
|
|
|
updateMetadata(metadata: storage.SettableMetadata): Promise<any>;
|
2017-03-23 12:58:03 +00:00
|
|
|
}
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
interface UploadMetadata extends storage.SettableMetadata {
|
|
|
|
md5Hash?: string | null;
|
|
|
|
}
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
interface SettableMetadata {
|
|
|
|
cacheControl?: string | null;
|
|
|
|
contentDisposition?: string | null;
|
|
|
|
contentEncoding?: string | null;
|
|
|
|
contentLanguage?: string | null;
|
|
|
|
contentType?: string | null;
|
2018-05-04 15:30:32 +00:00
|
|
|
customMetadata?: {
|
|
|
|
[/* warning: coerced from ? */ key: string]: string;
|
|
|
|
} | null;
|
2017-03-23 12:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type StringFormat = string;
|
|
|
|
var StringFormat: {
|
2018-05-04 15:30:32 +00:00
|
|
|
BASE64: StringFormat;
|
|
|
|
BASE64URL: StringFormat;
|
|
|
|
DATA_URL: StringFormat;
|
|
|
|
RAW: StringFormat;
|
|
|
|
};
|
2017-03-23 12:58:03 +00:00
|
|
|
|
|
|
|
interface UploadTask {
|
|
|
|
cancel(): boolean;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-28 21:49:12 +00:00
|
|
|
catch(onRejected: (a: RnError) => any): Promise<any>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
on(
|
|
|
|
event: storage.TaskEvent,
|
|
|
|
nextOrObserver?: null | Object,
|
|
|
|
error?: ((a: RnError) => any) | null,
|
|
|
|
complete?: (() => any) | null
|
|
|
|
): Function;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
pause(): boolean;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
resume(): boolean;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
snapshot: storage.UploadTaskSnapshot;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
then(
|
|
|
|
onFulfilled?: ((a: storage.UploadTaskSnapshot) => any) | null,
|
|
|
|
onRejected?: ((a: RnError) => any) | null
|
|
|
|
): Promise<any>;
|
2017-03-23 12:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface UploadTaskSnapshot {
|
|
|
|
bytesTransferred: number;
|
|
|
|
downloadURL: string | null;
|
|
|
|
metadata: storage.FullMetadata;
|
|
|
|
ref: storage.Reference;
|
|
|
|
state: storage.TaskState;
|
|
|
|
task: storage.UploadTask;
|
|
|
|
totalBytes: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface FullMetadata extends storage.UploadMetadata {
|
|
|
|
bucket: string;
|
|
|
|
downloadURLs: string[];
|
|
|
|
fullPath: string;
|
|
|
|
generation: string;
|
|
|
|
metageneration: string;
|
|
|
|
name: string;
|
|
|
|
size: number;
|
|
|
|
timeCreated: string;
|
|
|
|
updated: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
type TaskEvent = string;
|
|
|
|
var TaskEvent: {
|
2018-05-04 15:30:32 +00:00
|
|
|
STATE_CHANGED: TaskEvent;
|
2017-03-23 12:58:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
type TaskState = string;
|
|
|
|
var TaskState: {
|
2018-05-04 15:30:32 +00:00
|
|
|
CANCELED: TaskState;
|
|
|
|
ERROR: TaskState;
|
|
|
|
PAUSED: TaskState;
|
|
|
|
RUNNING: TaskState;
|
|
|
|
SUCCESS: TaskState;
|
2017-03-23 12:58:03 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace database {
|
|
|
|
interface Database {
|
|
|
|
/**
|
|
|
|
* Returns a new firebase reference instance
|
|
|
|
* */
|
2018-05-04 15:30:32 +00:00
|
|
|
ref(path?: string): RnReference;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* register listener
|
2017-03-23 12:58:03 +00:00
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
on(
|
|
|
|
path: string,
|
|
|
|
modifiersString: string,
|
|
|
|
modifiers: Array<string>,
|
|
|
|
eventName: string,
|
|
|
|
cb: () => void,
|
|
|
|
errorCb: () => void
|
|
|
|
): any;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* unregister listener
|
2017-03-23 12:58:03 +00:00
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
off(
|
|
|
|
path: string,
|
|
|
|
modifiersString: string,
|
|
|
|
eventName?: string,
|
|
|
|
origCB?: () => void
|
|
|
|
): any;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
/**
|
|
|
|
* Removes all event handlers and their native subscriptions
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
cleanup(): Promise<any>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
/**
|
|
|
|
* connect to firebase backend
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
goOnline(): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
/**
|
|
|
|
* disconnect to firebase backend
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
goOffline(): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-04-26 19:12:59 +00:00
|
|
|
[key: string]: any;
|
2017-03-23 12:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface RnReference extends Reference {
|
2018-05-04 15:30:32 +00:00
|
|
|
keepSynced(bool: boolean): any;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-04-26 19:12:59 +00:00
|
|
|
filter(name: string, value: any, key?: string): any;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-04-26 19:12:59 +00:00
|
|
|
[key: string]: any;
|
2017-03-23 12:58:03 +00:00
|
|
|
}
|
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
type QueryEventType =
|
|
|
|
| 'value'
|
|
|
|
| 'child_added'
|
|
|
|
| 'child_removed'
|
|
|
|
| 'child_changed'
|
|
|
|
| 'child_moved';
|
|
|
|
type QuerySuccessCallback = (
|
|
|
|
snapshot: DataSnapshot,
|
|
|
|
previousChildId?: string | null
|
|
|
|
) => void;
|
2017-09-18 07:23:34 +00:00
|
|
|
type QueryErrorCallback = (e: Error) => void;
|
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
interface Query {
|
2018-05-04 15:30:32 +00:00
|
|
|
endAt(
|
|
|
|
value: number | string | boolean | null,
|
|
|
|
key?: string
|
|
|
|
): database.Query;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
equalTo(
|
|
|
|
value: number | string | boolean | null,
|
|
|
|
key?: string
|
|
|
|
): database.Query;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
isEqual(other: database.Query | null): boolean;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
limitToFirst(limit: number): database.Query;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
limitToLast(limit: number): database.Query;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
off(
|
|
|
|
eventType?: QueryEventType,
|
|
|
|
callback?: QuerySuccessCallback,
|
|
|
|
context?: Object
|
|
|
|
): void;
|
|
|
|
|
|
|
|
on(
|
|
|
|
eventType: QueryEventType,
|
|
|
|
callback: QuerySuccessCallback,
|
|
|
|
cancelCallbackOrContext?: QueryErrorCallback,
|
|
|
|
context?: Object
|
|
|
|
): (
|
|
|
|
a: database.DataSnapshot | null,
|
|
|
|
b?: string
|
|
|
|
) => QuerySuccessCallback;
|
|
|
|
|
|
|
|
once(
|
|
|
|
eventType: QueryEventType,
|
|
|
|
successCallback?: QuerySuccessCallback,
|
|
|
|
failureCallbackOrContext?: QueryErrorCallback,
|
|
|
|
context?: Object
|
|
|
|
): Promise<DataSnapshot>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
orderByChild(path: string): database.Query;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
orderByKey(): database.Query;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
orderByPriority(): database.Query;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
orderByValue(): database.Query;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
ref: database.Reference;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
startAt(
|
|
|
|
value: number | string | boolean | null,
|
|
|
|
key?: string
|
|
|
|
): database.Query;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
toJSON(): Object;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
toString(): string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DataSnapshot {
|
|
|
|
child(path: string): database.DataSnapshot;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
exists(): boolean;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
exportVal(): any;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
forEach(action: (a: database.DataSnapshot) => boolean): boolean;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
getPriority(): string | number | null;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
hasChild(path: string): boolean;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
hasChildren(): boolean;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
key: string | null;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
numChildren(): number;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
ref: database.Reference;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
toJSON(): Object | null;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
val(): any;
|
|
|
|
}
|
2017-03-28 21:49:12 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
interface ThenableReference<T> extends Promise<T> {}
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
interface ThenableReference<T> extends Reference {}
|
2017-09-18 07:23:34 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
interface Reference extends database.Query {
|
|
|
|
child(path: string): database.Reference;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
key: string | null;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
onDisconnect(): any;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
parent: database.Reference | null;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
push(
|
|
|
|
value?: any,
|
|
|
|
onComplete?: (a: RnError | null) => any
|
|
|
|
): ThenableReference<any>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-28 21:49:12 +00:00
|
|
|
remove(onComplete?: (a: RnError | null) => any): Promise<any>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 12:58:03 +00:00
|
|
|
root: database.Reference;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-28 21:49:12 +00:00
|
|
|
set(value: any, onComplete?: (a: RnError | null) => any): Promise<any>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
setPriority(
|
|
|
|
priority: string | number | null,
|
|
|
|
onComplete: (a: RnError | null) => any
|
|
|
|
): Promise<any>;
|
|
|
|
|
|
|
|
setWithPriority(
|
|
|
|
newVal: any,
|
|
|
|
newPriority: string | number | null,
|
|
|
|
onComplete?: (a: RnError | null) => any
|
|
|
|
): Promise<any>;
|
|
|
|
|
|
|
|
transaction(
|
|
|
|
transactionUpdate: (a: any) => any,
|
|
|
|
onComplete?: (
|
|
|
|
a: RnError | null,
|
|
|
|
b: boolean,
|
|
|
|
c: database.DataSnapshot | null
|
|
|
|
) => any,
|
|
|
|
applyLocally?: boolean
|
|
|
|
): Promise<any>;
|
|
|
|
|
|
|
|
update(
|
|
|
|
values: Object,
|
|
|
|
onComplete?: (a: RnError | null) => any
|
|
|
|
): Promise<any>;
|
2017-03-23 12:58:03 +00:00
|
|
|
}
|
2018-01-29 05:14:06 +00:00
|
|
|
|
|
|
|
interface DatabaseStatics {
|
|
|
|
/** @see https://www.firebase.com/docs/java-api/javadoc/com/firebase/client/ServerValue.html#TIMESTAMP */
|
|
|
|
ServerValue: {
|
|
|
|
TIMESTAMP: {
|
2018-05-04 15:30:32 +00:00
|
|
|
[key: string]: string;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
2017-03-23 12:58:03 +00:00
|
|
|
}
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-23 10:06:07 +00:00
|
|
|
/**
|
|
|
|
* firebase Analytics
|
|
|
|
*/
|
|
|
|
interface Analytics {
|
2017-03-22 22:43:20 +00:00
|
|
|
/**Log a custom event with optional params. */
|
2018-05-04 15:30:32 +00:00
|
|
|
logEvent(event: string, params?: Object): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-22 22:43:20 +00:00
|
|
|
/** Sets whether analytics collection is enabled for this app on this device. */
|
2018-05-04 15:30:32 +00:00
|
|
|
setAnalyticsCollectionEnabled(enabled: boolean): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* Sets the current screen name, which specifies the current visual context in your app.
|
2017-06-19 11:25:58 +00:00
|
|
|
* Whilst screenClassOverride is optional,
|
|
|
|
* it is recommended it is always sent as your current class name,
|
2017-03-22 22:43:20 +00:00
|
|
|
* for example on Android it will always show as 'MainActivity' if not specified.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
setCurrentScreen(
|
|
|
|
screenName: string | null,
|
|
|
|
screenClassOverride?: string
|
|
|
|
): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* Sets the minimum engagement time required before starting a session.
|
2017-03-22 22:43:20 +00:00
|
|
|
* The default value is 10000 (10 seconds)
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
setMinimumSessionDuration(miliseconds: number): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* Sets the duration of inactivity that terminates the current session.
|
|
|
|
* The default value is 1800000 (30 minutes).
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
setSessionTimeoutDuration(miliseconds: number): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* Gives a user a uniqiue identificaition.
|
2017-06-19 11:25:58 +00:00
|
|
|
* @example
|
2017-03-22 22:43:20 +00:00
|
|
|
* const id = firebase.auth().currentUser.uid;
|
2017-06-19 11:25:58 +00:00
|
|
|
*
|
2017-03-22 22:43:20 +00:00
|
|
|
* firebase.analytics().setUserId(id);
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
setUserId(id: string | null): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* Sets a key/value pair of data on the current user.
|
|
|
|
*/
|
2017-10-24 10:41:19 +00:00
|
|
|
setUserProperty(name: string, value: string | null): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-04-26 19:12:59 +00:00
|
|
|
[key: string]: any;
|
2017-03-23 10:06:07 +00:00
|
|
|
}
|
2017-03-22 22:43:20 +00:00
|
|
|
|
2018-01-31 09:09:12 +00:00
|
|
|
type AdditionalUserInfo = {
|
2018-05-04 15:30:32 +00:00
|
|
|
isNewUser: boolean;
|
|
|
|
profile?: Object;
|
|
|
|
providerId: string;
|
|
|
|
username?: string;
|
|
|
|
};
|
2018-01-31 09:09:12 +00:00
|
|
|
|
|
|
|
type UserCredential = {
|
2018-05-04 15:30:32 +00:00
|
|
|
additionalUserInfo?: AdditionalUserInfo;
|
|
|
|
user: User;
|
|
|
|
};
|
2018-01-31 09:09:12 +00:00
|
|
|
|
2018-01-18 16:05:44 +00:00
|
|
|
type UserInfo = {
|
2018-05-04 15:30:32 +00:00
|
|
|
displayName?: string;
|
|
|
|
email?: string;
|
|
|
|
phoneNumber?: string;
|
|
|
|
photoURL?: string;
|
|
|
|
providerId: string;
|
|
|
|
uid: string;
|
|
|
|
};
|
2018-01-18 16:05:44 +00:00
|
|
|
|
|
|
|
type UpdateProfile = {
|
2018-05-04 15:30:32 +00:00
|
|
|
displayName?: string;
|
|
|
|
photoURL?: string;
|
|
|
|
};
|
2018-01-18 16:05:44 +00:00
|
|
|
|
2018-01-31 09:09:12 +00:00
|
|
|
type UserMetadata = {
|
2018-05-04 15:30:32 +00:00
|
|
|
creationTime?: string;
|
|
|
|
lastSignInTime?: string;
|
|
|
|
};
|
2018-01-31 09:09:12 +00:00
|
|
|
|
2017-03-23 10:06:07 +00:00
|
|
|
interface User {
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* The user's display name (if available).
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
displayName: string | null;
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* - The user's email address (if available).
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
email: string | null;
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* - True if the user's email address has been verified.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
emailVerified: boolean;
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
*
|
2017-03-22 22:43:20 +00:00
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
isAnonymous: boolean;
|
2018-01-18 16:05:44 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
metadata: UserMetadata;
|
2018-01-31 09:09:12 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
phoneNumber: string | null;
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* - The URL of the user's profile picture (if available).
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
photoURL: string | null;
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* - Additional provider-specific information about the user.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
providerData: Array<UserInfo>;
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* - The authentication provider ID for the current user.
|
|
|
|
* For example, 'facebook.com', or 'google.com'.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
providerId: string;
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* - The user's unique ID.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
uid: string;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* Delete the current user.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
delete(): Promise<void>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* Returns the users authentication token.
|
2018-01-18 16:05:44 +00:00
|
|
|
*
|
|
|
|
* @param forceRefresh: boolean - default to false
|
2017-03-22 22:43:20 +00:00
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
getIdToken(forceRefresh?: boolean): Promise<string>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
getToken(forceRefresh?: boolean): Promise<string>;
|
2018-01-31 09:09:12 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
linkAndRetrieveDataWithCredential(
|
|
|
|
credential: AuthCredential
|
|
|
|
): Promise<UserCredential>;
|
2018-01-31 09:09:12 +00:00
|
|
|
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
2018-01-18 16:05:44 +00:00
|
|
|
* Link the user with a 3rd party credential provider.
|
2017-03-22 22:43:20 +00:00
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
linkWithCredential(credential: AuthCredential): Promise<User>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
reauthenticateAndRetrieveDataWithCredential(
|
|
|
|
credential: AuthCredential
|
|
|
|
): Promise<UserCredential>;
|
2018-01-31 09:09:12 +00:00
|
|
|
|
2017-09-01 07:47:42 +00:00
|
|
|
/**
|
2018-01-18 16:05:44 +00:00
|
|
|
* Re-authenticate a user with a third-party authentication provider
|
2017-09-01 07:47:42 +00:00
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
reauthenticateWithCredential(credential: AuthCredential): Promise<void>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* Refreshes the current user.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
reload(): Promise<void>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* Sends a verification email to a user.
|
2017-03-22 22:43:20 +00:00
|
|
|
* This will Promise reject is the user is anonymous.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
sendEmailVerification(
|
|
|
|
actionCodeSettings?: ActionCodeSettings
|
|
|
|
): Promise<void>;
|
2018-01-18 16:05:44 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
toJSON(): object;
|
2018-01-18 16:05:44 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
unlink(providerId: string): Promise<User>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* Updates the user's email address.
|
2017-06-19 11:25:58 +00:00
|
|
|
* See Firebase docs for more information on security & email validation.
|
2017-03-22 22:43:20 +00:00
|
|
|
* This will Promise reject is the user is anonymous.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
updateEmail(email: string): Promise<void>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* Important: this is a security sensitive operation that requires the user to have recently signed in.
|
|
|
|
* If this requirement isn't met, ask the user to authenticate again and then call firebase.User#reauthenticate.
|
2017-03-22 22:43:20 +00:00
|
|
|
* This will Promise reject is the user is anonymous.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
updatePassword(password: string): Promise<void>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-22 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* Updates a user's profile data.
|
|
|
|
* Profile data should be an object of fields to update:
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
updateProfile(updates: UpdateProfile): Promise<void>;
|
2017-03-23 10:06:07 +00:00
|
|
|
}
|
2017-03-22 22:43:20 +00:00
|
|
|
|
2018-01-18 16:05:44 +00:00
|
|
|
type ActionCodeSettings = {
|
|
|
|
android: {
|
2018-05-04 15:30:32 +00:00
|
|
|
installApp?: boolean;
|
|
|
|
minimumVersion?: string;
|
|
|
|
packageName: string;
|
|
|
|
};
|
|
|
|
handleCodeInApp?: boolean;
|
|
|
|
iOS: {
|
|
|
|
bundleId?: string;
|
|
|
|
};
|
|
|
|
url: string;
|
|
|
|
};
|
2017-07-05 13:56:18 +00:00
|
|
|
|
|
|
|
interface ActionCodeInfo {
|
2018-01-31 09:09:12 +00:00
|
|
|
data: {
|
2018-05-04 15:30:32 +00:00
|
|
|
email?: string;
|
|
|
|
fromEmail?: string;
|
|
|
|
};
|
|
|
|
operation: 'PASSWORD_RESET' | 'VERIFY_EMAIL' | 'RECOVER_EMAIL';
|
2017-07-05 13:56:18 +00:00
|
|
|
}
|
|
|
|
|
2018-01-18 16:05:44 +00:00
|
|
|
interface ConfirmationResult {
|
|
|
|
confirm(verificationCode: string): Promise<User | null>;
|
|
|
|
|
|
|
|
verificationId: string | null;
|
|
|
|
}
|
|
|
|
|
|
|
|
type PhoneAuthSnapshot = {
|
2018-05-04 15:30:32 +00:00
|
|
|
state: 'sent' | 'timeout' | 'verified' | 'error';
|
|
|
|
verificationId: string;
|
|
|
|
code: string | null;
|
|
|
|
error: Error | null;
|
2018-01-18 16:05:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
type PhoneAuthError = {
|
2018-05-04 15:30:32 +00:00
|
|
|
code: string | null;
|
|
|
|
verificationId: string;
|
|
|
|
message: string | null;
|
|
|
|
stack: string | null;
|
2018-01-18 16:05:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
interface PhoneAuthListener {
|
2018-05-04 15:30:32 +00:00
|
|
|
on(
|
|
|
|
event: string,
|
|
|
|
observer: () => PhoneAuthSnapshot,
|
|
|
|
errorCb?: () => PhoneAuthError,
|
|
|
|
successCb?: () => PhoneAuthSnapshot
|
|
|
|
): PhoneAuthListener;
|
2018-01-18 16:05:44 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
then(fn: () => PhoneAuthSnapshot): Promise<any>;
|
2018-01-18 16:05:44 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
catch(fn: () => Error): Promise<any>;
|
2018-01-18 16:05:44 +00:00
|
|
|
}
|
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
namespace auth {
|
2018-01-18 16:05:44 +00:00
|
|
|
type AuthResult = {
|
2018-05-04 15:30:32 +00:00
|
|
|
authenticated: boolean;
|
|
|
|
user: object | null;
|
2018-01-18 16:05:44 +00:00
|
|
|
} | null;
|
|
|
|
|
2018-01-29 05:14:06 +00:00
|
|
|
type AuthProvider = {
|
2018-05-04 15:30:32 +00:00
|
|
|
PROVIDER_ID: string;
|
|
|
|
credential: (token: string, secret?: string) => AuthCredential;
|
2018-01-29 05:14:06 +00:00
|
|
|
};
|
|
|
|
|
2018-05-12 23:48:57 +00:00
|
|
|
type EmailAuthProvider = {
|
|
|
|
PROVIDER_ID: string;
|
|
|
|
EMAIL_LINK_SIGN_IN_METHOD: string;
|
|
|
|
EMAIL_PASSWORD_SIGN_IN_METHOD: string;
|
|
|
|
credential: (email: string, password: string) => AuthCredential;
|
|
|
|
credentialWithLink: (email: string, emailLink: string) => AuthCredential;
|
|
|
|
};
|
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
interface Auth {
|
2018-01-31 09:09:12 +00:00
|
|
|
readonly app: App;
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
|
|
|
* Returns the current Firebase authentication state.
|
|
|
|
*/
|
2018-01-18 16:05:44 +00:00
|
|
|
authResult: AuthResult | null;
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
|
|
|
* Returns the currently signed-in user (or null). See the User class documentation for further usage.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
currentUser: User | null;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-11-30 12:56:28 +00:00
|
|
|
/**
|
|
|
|
* Gets/Sets the language for the app instance
|
|
|
|
*/
|
|
|
|
languageCode: string | null;
|
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* Listen for changes in the users auth state (logging in and out).
|
|
|
|
* This method returns a unsubscribe function to stop listening to events.
|
2017-03-30 14:09:48 +00:00
|
|
|
* Always ensure you unsubscribe from the listener when no longer needed to prevent updates to components no longer in use.
|
|
|
|
*/
|
2018-01-18 16:05:44 +00:00
|
|
|
onAuthStateChanged(listener: Function): () => void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
2018-01-18 16:05:44 +00:00
|
|
|
* Listen for changes in id token.
|
|
|
|
* This method returns a unsubscribe function to stop listening to events.
|
|
|
|
* Always ensure you unsubscribe from the listener when no longer needed to prevent updates to components no longer in use.
|
2017-03-30 14:09:48 +00:00
|
|
|
*/
|
2018-01-18 16:05:44 +00:00
|
|
|
onIdTokenChanged(listener: Function): () => void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
2018-01-18 16:05:44 +00:00
|
|
|
* Listen for changes in the user.
|
|
|
|
* This method returns a unsubscribe function to stop listening to events.
|
|
|
|
* Always ensure you unsubscribe from the listener when no longer needed to prevent updates to components no longer in use.
|
2017-03-30 14:09:48 +00:00
|
|
|
*/
|
2018-01-18 16:05:44 +00:00
|
|
|
onUserChanged(listener: Function): () => void;
|
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
signOut(): Promise<void>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
signInAnonymouslyAndRetrieveData(): Promise<UserCredential>;
|
2018-01-31 09:09:12 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* Sign an anonymous user.
|
2017-03-30 14:09:48 +00:00
|
|
|
* If the user has already signed in, that user will be returned
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
signInAnonymously(): Promise<User>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
createUserAndRetrieveDataWithEmailAndPassword(
|
|
|
|
email: string,
|
|
|
|
password: string
|
|
|
|
): Promise<UserCredential>;
|
2018-01-18 16:05:44 +00:00
|
|
|
|
2018-05-12 23:48:57 +00:00
|
|
|
signInWithEmailLink(
|
|
|
|
email: string,
|
|
|
|
emailLink: string
|
|
|
|
): Promise<UserCredential>;
|
|
|
|
|
|
|
|
isSignInWithEmailLink(emailLink: string): boolean;
|
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
2018-01-18 16:05:44 +00:00
|
|
|
* We can create a user by calling the createUserWithEmailAndPassword() function.
|
|
|
|
* The method accepts two parameters, an email and a password.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
createUserWithEmailAndPassword(
|
|
|
|
email: string,
|
|
|
|
password: string
|
|
|
|
): Promise<User>;
|
2018-01-18 16:05:44 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
signInAndRetrieveDataWithEmailAndPassword(
|
|
|
|
email: string,
|
|
|
|
password: string
|
|
|
|
): Promise<UserCredential>;
|
2018-01-31 09:09:12 +00:00
|
|
|
|
2018-01-18 16:05:44 +00:00
|
|
|
/**
|
|
|
|
* To sign a user in with their email and password, use the signInWithEmailAndPassword() function.
|
|
|
|
* It accepts two parameters, the user's email and password:
|
2017-03-30 14:09:48 +00:00
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
signInWithEmailAndPassword(
|
|
|
|
email: string,
|
|
|
|
password: string
|
|
|
|
): Promise<User>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
signInAndRetrieveDataWithCustomToken(
|
|
|
|
token: string
|
|
|
|
): Promise<UserCredential>;
|
2018-01-31 09:09:12 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* Sign a user in with a self-signed JWT token.
|
|
|
|
* To sign a user using a self-signed custom token,
|
|
|
|
* use the signInWithCustomToken() function.
|
2017-03-30 14:09:48 +00:00
|
|
|
* It accepts one parameter, the custom token:
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
signInWithCustomToken(token: string): Promise<User>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
signInAndRetrieveDataWithCredential(
|
|
|
|
credential: AuthCredential
|
|
|
|
): Promise<UserCredential>;
|
2018-01-31 09:09:12 +00:00
|
|
|
|
2018-01-18 16:05:44 +00:00
|
|
|
/**
|
|
|
|
* Sign in the user with a 3rd party credential provider.
|
|
|
|
* credential requires the following properties:
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
signInWithCredential(credential: AuthCredential): Promise<User>;
|
2018-01-18 16:05:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Asynchronously signs in using a phone number.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
signInWithPhoneNumber(phoneNumber: string): Promise<ConfirmationResult>;
|
2018-01-18 16:05:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a PhoneAuthListener to listen to phone verification events,
|
|
|
|
* on the final completion event a PhoneAuthCredential can be generated for
|
|
|
|
* authentication purposes.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
verifyPhoneNumber(
|
|
|
|
phoneNumber: string,
|
|
|
|
autoVerifyTimeout?: number
|
|
|
|
): PhoneAuthListener;
|
2018-01-18 16:05:44 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* Sends a password reset email to the given email address.
|
|
|
|
* Unlike the web SDK,
|
2017-03-30 14:09:48 +00:00
|
|
|
* the email will contain a password reset link rather than a code.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
sendPasswordResetEmail(
|
|
|
|
email: string,
|
|
|
|
actionCodeSettings?: ActionCodeSettings
|
|
|
|
): Promise<void>;
|
2017-07-05 13:16:35 +00:00
|
|
|
|
2018-05-12 23:48:57 +00:00
|
|
|
sendSignInLinkToEmail(
|
|
|
|
email: string,
|
|
|
|
actionCodeSettings?: ActionCodeSettings
|
|
|
|
): Promise<void>;
|
|
|
|
|
2017-07-05 13:16:35 +00:00
|
|
|
/**
|
|
|
|
* Completes the password reset process, given a confirmation code and new password.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
confirmPasswordReset(code: string, newPassword: string): Promise<void>;
|
2017-07-05 13:16:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Applies a verification code sent to the user by email or other out-of-band mechanism.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
applyActionCode(code: string): Promise<void>;
|
2017-07-05 13:16:35 +00:00
|
|
|
|
2017-07-05 13:56:18 +00:00
|
|
|
/**
|
|
|
|
* Checks a verification code sent to the user by email or other out-of-band mechanism.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
checkActionCode(code: string): Promise<ActionCodeInfo>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-01-18 16:05:44 +00:00
|
|
|
/**
|
|
|
|
* Returns a list of authentication providers that can be used to sign in a given user (identified by its main email address).
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
fetchProvidersForEmail(email: string): Promise<Array<string>>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
verifyPasswordResetCode(code: string): Promise<string>;
|
2018-01-31 09:09:12 +00:00
|
|
|
|
2017-04-26 19:12:59 +00:00
|
|
|
[key: string]: any;
|
2017-03-30 14:09:48 +00:00
|
|
|
}
|
2018-01-29 05:14:06 +00:00
|
|
|
|
|
|
|
interface AuthStatics {
|
2018-05-12 23:48:57 +00:00
|
|
|
EmailAuthProvider: EmailAuthProvider;
|
2018-01-29 05:14:06 +00:00
|
|
|
PhoneAuthProvider: AuthProvider;
|
|
|
|
GoogleAuthProvider: AuthProvider;
|
|
|
|
GithubAuthProvider: AuthProvider;
|
2018-01-31 09:09:12 +00:00
|
|
|
OAuthProvider: AuthProvider;
|
2018-01-29 05:14:06 +00:00
|
|
|
TwitterAuthProvider: AuthProvider;
|
|
|
|
FacebookAuthProvider: AuthProvider;
|
|
|
|
PhoneAuthState: {
|
|
|
|
CODE_SENT: string;
|
|
|
|
AUTO_VERIFY_TIMEOUT: string;
|
|
|
|
AUTO_VERIFIED: string;
|
|
|
|
ERROR: string;
|
|
|
|
};
|
|
|
|
}
|
2017-03-23 10:06:07 +00:00
|
|
|
}
|
2017-04-26 19:12:59 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
namespace messaging {
|
|
|
|
interface Messaging {
|
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* Returns the devices FCM token.
|
2017-03-30 14:09:48 +00:00
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
getToken(): Promise<string>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-09-26 14:33:20 +00:00
|
|
|
/**
|
2018-03-23 17:31:25 +00:00
|
|
|
* On a new message,
|
|
|
|
* the payload object is passed to the listener callback.
|
|
|
|
* This method is only triggered when the app is running.
|
2017-09-26 14:33:20 +00:00
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
onMessage(listener: (message: any) => any): () => any;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
|
|
|
* On the event a devices FCM token is refreshed by Google,
|
|
|
|
* the new token is returned in a callback listener.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
onTokenRefresh(listener: (token: string) => any): () => any;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
2018-03-23 17:31:25 +00:00
|
|
|
* Requests app notification permissions in an Alert dialog.
|
2017-03-30 14:09:48 +00:00
|
|
|
*/
|
2018-03-23 17:31:25 +00:00
|
|
|
requestPermission(): Promise<boolean>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
2018-03-23 17:31:25 +00:00
|
|
|
* Checks if the app has notification permissions.
|
2017-03-30 14:09:48 +00:00
|
|
|
*/
|
2018-03-23 17:31:25 +00:00
|
|
|
hasPermission(): Promise<boolean>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
2018-03-23 17:31:25 +00:00
|
|
|
* Send an upstream message
|
2017-03-30 14:09:48 +00:00
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
sendMessage(remoteMessage: RemoteMessage): Promise<void>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
2018-03-23 17:31:25 +00:00
|
|
|
* Subscribes the device to a topic.
|
2017-03-30 14:09:48 +00:00
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
subscribeToTopic(topic: string): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
2018-03-23 17:31:25 +00:00
|
|
|
* Unsubscribes the device from a topic.
|
2017-03-30 14:09:48 +00:00
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
unsubscribeFromTopic(topic: string): void;
|
2018-03-23 17:31:25 +00:00
|
|
|
}
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2018-04-13 07:14:28 +00:00
|
|
|
class RemoteMessage {
|
2018-05-04 15:30:32 +00:00
|
|
|
collapseKey?: string;
|
|
|
|
data: Object;
|
|
|
|
from?: string;
|
|
|
|
messageId?: string;
|
|
|
|
messageType: string;
|
|
|
|
sentTime?: number;
|
|
|
|
to?: string;
|
|
|
|
ttl?: number;
|
2018-03-23 17:31:25 +00:00
|
|
|
|
2018-04-13 07:14:28 +00:00
|
|
|
constructor();
|
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
setCollapseKey(collapseKey: string): RemoteMessage;
|
|
|
|
setData(data: Object): RemoteMessage;
|
|
|
|
setMessageId(messageId: string): RemoteMessage;
|
|
|
|
setMessageType(messageType: string): RemoteMessage;
|
|
|
|
setTo(to: string): RemoteMessage;
|
|
|
|
setTtl(ttl: number): RemoteMessage;
|
2018-03-23 17:31:25 +00:00
|
|
|
}
|
2018-04-12 07:50:13 +00:00
|
|
|
|
|
|
|
interface MessagingStatics {
|
2018-04-16 07:14:30 +00:00
|
|
|
RemoteMessage: typeof RemoteMessage;
|
2018-04-12 07:50:13 +00:00
|
|
|
}
|
2018-03-23 17:31:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace iid {
|
|
|
|
interface InstanceId {
|
2018-05-04 15:30:32 +00:00
|
|
|
delete(): Promise<void>;
|
|
|
|
get(): Promise<string>;
|
2018-03-23 17:31:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace notifications {
|
|
|
|
interface AndroidNotifications {
|
2018-05-04 15:30:32 +00:00
|
|
|
createChannel(channel: Android.Channel): Promise<void>;
|
|
|
|
createChannelGroup(channelGroup: Android.ChannelGroup): Promise<void>;
|
|
|
|
createChannelGroups(
|
|
|
|
channelGroups: Android.ChannelGroup[]
|
|
|
|
): Promise<void>;
|
|
|
|
createChannels(channels: Android.Channel[]): Promise<void>;
|
2018-05-13 20:16:46 +00:00
|
|
|
deleteChannelGroup(groupId: string): Promise<void>;
|
|
|
|
deleteChannel(channelId: string): Promise<void>;
|
2018-03-23 17:31:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface Notifications {
|
2018-05-04 15:30:32 +00:00
|
|
|
android: AndroidNotifications;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
2018-03-23 17:31:25 +00:00
|
|
|
* Cancels all notifications
|
2017-03-30 14:09:48 +00:00
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
cancelAllNotifications(): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
2018-03-23 17:31:25 +00:00
|
|
|
* Cancels a notification by ID
|
2017-03-30 14:09:48 +00:00
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
cancelNotification(notificationId: string): void;
|
2018-03-23 17:31:25 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
displayNotification(notification: Notification): Promise<void>;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
|
|
|
* Returns the current badge number on the app icon.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
getBadge(): Promise<number>;
|
2018-03-23 17:31:25 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
getInitialNotification(): Promise<NotificationOpen>;
|
2018-03-23 17:31:25 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
getScheduledNotifications(): Promise<Notification[]>;
|
2018-03-23 17:31:25 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
onNotification(
|
|
|
|
listener: (notification: Notification) => any
|
|
|
|
): () => any;
|
2018-03-23 17:31:25 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
onNotificationDisplayed(
|
|
|
|
listener: (notification: Notification) => any
|
|
|
|
): () => any;
|
2018-03-23 17:31:25 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
onNotificationOpened(
|
|
|
|
listener: (notificationOpen: NotificationOpen) => any
|
|
|
|
): () => any;
|
2018-03-23 17:31:25 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
removeAllDeliveredNotifications(): void;
|
2018-03-23 17:31:25 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
removeDeliveredNotification(notificationId: string): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
2018-03-23 17:31:25 +00:00
|
|
|
* Schedule a local notification to be shown on the device.
|
2017-03-30 14:09:48 +00:00
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
scheduleNotification(notification: Notification, schedule: any): any;
|
2017-03-22 22:43:20 +00:00
|
|
|
|
2018-03-23 17:31:25 +00:00
|
|
|
/**
|
|
|
|
* Sets the badge number on the iOS app icon.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
setBadge(badge: number): void;
|
2017-03-30 14:09:48 +00:00
|
|
|
}
|
2018-04-08 09:46:41 +00:00
|
|
|
|
|
|
|
class Notification {
|
2018-05-04 15:30:32 +00:00
|
|
|
android: AndroidNotification;
|
|
|
|
ios: IOSNotification;
|
|
|
|
body: string;
|
|
|
|
data: any;
|
|
|
|
notificationId: string;
|
|
|
|
sound?: string;
|
|
|
|
subtitle?: string;
|
|
|
|
title: string;
|
2018-04-08 09:46:41 +00:00
|
|
|
|
2018-04-13 07:14:28 +00:00
|
|
|
constructor();
|
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
setBody(body: string): Notification;
|
|
|
|
setData(data: any): Notification;
|
|
|
|
setNotificationId(notificationId: string): Notification;
|
|
|
|
setSound(sound: string): Notification;
|
|
|
|
setSubtitle(subtitle: string): Notification;
|
|
|
|
setTitle(title: string): Notification;
|
2018-04-08 09:46:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class NotificationOpen {
|
2018-05-04 15:30:32 +00:00
|
|
|
action: string;
|
|
|
|
notification: Notification;
|
|
|
|
results?: any;
|
2018-04-08 09:46:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class AndroidNotification {
|
2018-05-04 15:30:32 +00:00
|
|
|
actions?: Android.Action[];
|
|
|
|
autoCancel?: boolean;
|
|
|
|
badgeIconType?: Android.BadgeIconType;
|
|
|
|
bigPicture?: any;
|
|
|
|
bigText?: any;
|
|
|
|
category?: Android.Category;
|
|
|
|
channelId?: string;
|
|
|
|
clickAction?: string;
|
|
|
|
color?: string;
|
|
|
|
colorized?: boolean;
|
|
|
|
contentInfo?: string;
|
|
|
|
defaults?: Android.Defaults[];
|
|
|
|
group?: string;
|
|
|
|
groupAlertBehaviour?: Android.GroupAlert;
|
|
|
|
groupSummary?: boolean;
|
|
|
|
largeIcon?: string;
|
|
|
|
lights?: Android.Lights;
|
|
|
|
localOnly?: boolean;
|
|
|
|
number?: number;
|
|
|
|
ongoing?: boolean;
|
|
|
|
onlyAlertOnce?: boolean;
|
|
|
|
people?: string[];
|
|
|
|
priority?: Android.Priority;
|
|
|
|
progress?: Android.Progress;
|
|
|
|
remoteInputHistory?: string[];
|
|
|
|
shortcutId?: string;
|
|
|
|
showWhen?: boolean;
|
|
|
|
smallIcon?: any;
|
|
|
|
sortKey?: string;
|
|
|
|
ticker?: string;
|
|
|
|
timeoutAfter?: number;
|
|
|
|
usesChronometer?: boolean;
|
|
|
|
vibrate?: number[];
|
|
|
|
visibility?: Android.Visibility;
|
|
|
|
when?: number;
|
|
|
|
|
|
|
|
addAction(action: Android.Action): Notification;
|
|
|
|
addPerson(person: string): Notification;
|
|
|
|
setAutoCancel(autoCancel: boolean): Notification;
|
|
|
|
setBadgeIconType(badgeIconType: Android.BadgeIconType): Notification;
|
|
|
|
setBigPicture(
|
|
|
|
picture: string,
|
|
|
|
largeIcon?: string,
|
|
|
|
contentTitle?: string,
|
|
|
|
summaryText?: string
|
|
|
|
): Notification;
|
|
|
|
setBigText(
|
|
|
|
text: string,
|
|
|
|
contentTitle?: string,
|
|
|
|
summaryText?: string
|
|
|
|
): Notification;
|
|
|
|
setCategory(category: Android.Category): Notification;
|
|
|
|
setChannelId(channelId: string): Notification;
|
|
|
|
setClickAction(clickAction: string): Notification;
|
|
|
|
setColor(color: string): Notification;
|
|
|
|
setColorized(colorized: boolean): Notification;
|
|
|
|
setContentInfo(contentInfo: string): Notification;
|
|
|
|
setDefaults(defaults: Android.Defaults[]): Notification;
|
|
|
|
setGroup(group: string): Notification;
|
|
|
|
setGroupAlertBehaviour(
|
|
|
|
groupAlertBehaviour: Android.GroupAlert
|
|
|
|
): Notification;
|
|
|
|
setGroupSummary(groupSummary: boolean): Notification;
|
|
|
|
setLargeIcon(largeIcon: string): Notification;
|
|
|
|
setLights(argb: number, onMs: number, offMs: number): Notification;
|
|
|
|
setLocalOnly(localOnly: boolean): Notification;
|
|
|
|
setNumber(number: number): Notification;
|
|
|
|
setOngoing(ongoing: boolean): Notification;
|
|
|
|
setOnlyAlertOnce(onlyAlertOnce: boolean): Notification;
|
|
|
|
setPriority(priority: Android.Priority): Notification;
|
|
|
|
setProgress(
|
|
|
|
max: number,
|
|
|
|
progress: number,
|
|
|
|
indeterminate: boolean
|
|
|
|
): Notification;
|
2018-04-12 07:50:13 +00:00
|
|
|
//setPublicVersion(publicVersion: Notification): Notification
|
2018-05-04 15:30:32 +00:00
|
|
|
setRemoteInputHistory(remoteInputHistory: string[]): Notification;
|
|
|
|
setShortcutId(shortcutId: string): Notification;
|
|
|
|
setShowWhen(showWhen: boolean): Notification;
|
|
|
|
setSmallIcon(icon: string, level?: number): Notification;
|
|
|
|
setSortKey(sortKey: string): Notification;
|
|
|
|
setTicker(ticker: string): Notification;
|
|
|
|
setTimeoutAfter(timeoutAfter: number): Notification;
|
|
|
|
setUsesChronometer(usesChronometer: boolean): Notification;
|
|
|
|
setVibrate(vibrate: number[]): Notification;
|
|
|
|
setVisibility(visibility: Android.Visibility): Notification;
|
|
|
|
setWhen(when: number): Notification;
|
2018-04-08 09:46:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace Android {
|
|
|
|
class Action {
|
2018-05-04 15:30:32 +00:00
|
|
|
action: string;
|
|
|
|
allowGeneratedReplies: boolean;
|
|
|
|
icon: string;
|
|
|
|
remoteInputs: RemoteInput[];
|
|
|
|
semanticAction?: SemanticAction;
|
|
|
|
showUserInterface?: boolean;
|
|
|
|
title: string;
|
Implement handling of Android actions in background
There are some cases when local notification action should be handled in
background eg. snoozing the reminder. In case of it launching app UI is
not necessary and would be confusing for the end user.
Therefore there should be a way to handle local notification action in
background.
For this reason new property 'runInBackground' was added to the
AndroidAction class and TypeScript type.
Also new broadcast receiver and service were implemented to handle
properly background actions.
In order to run particular action in background API consumer need to set its
'runInBackground' property to 'true', eg:
...
.android.addAction(new firebase.notifications.Android.Action("snooze",
"ic_snooze", "Snooze").setRunInBackground(true))
...
Then, there are two cases that API consumer needs to handle.
First when app is in the foreground, standard notification and
notification action code path will be executed. This mean, that:
* onNotification() listener will be called (which should call
displayNotification(), in order to show it to the user),
* onNotificationOpen() listener will be called after the action is
tapped by the user
Secondly, when application is in background or it is not running new
'RNFirebaseBackgroundNotificationAction' handler will be called. To
properly handle this case API consumer should create a background
asynchronous handler:
const handleAsyncTask = async (notificationOpen: NotifficationOpen) => {
if (notificationOpen && notificationOpen.notification) {
const action = notificationOpen.action;
const notificationId = notificationOpen.notification.notificationId;
if (action === "snooze") {
console.log("Reschedule notification for later time", notificationId);
} else {
console.log("unsupported action", action);
}
// hide the notification
firebase.notifications().removeDeliveredNotification(notificationId);
}
}
Next hander should be registered to headless handler:
AppRegistry.registerHeadlessTask('RNFirebaseBackgroundNotificationAction', () => handleAsyncTask);
Finally AndroidManifest.xml file must be modified, to include receiver
and service definition:
<receiver
android:name="io.invertase.firebase.notifications.RNFirebaseBackgroundNotificationActionReceiver"
android:exported="true">
<intent-filter>
<action android:name="io.invertase.firebase.notifications.BackgroundAction"/>
</intent-filter>
</receiver>
<service android:name="io.invertase.firebase.notifications.RNFirebaseBackgroundNotificationActionsService"/>
Now when ever 'Snooze' action is pressed it will launch
'handleAsyncTask' function in the background or onNotificationOpen()
when app is in foreground. And reschedule the notification
for the later time.
2018-05-11 21:09:32 +00:00
|
|
|
runInBackground?: boolean;
|
2018-04-08 09:46:41 +00:00
|
|
|
|
|
|
|
constructor(action: string, icon: string, title: string);
|
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
addRemoteInput(remoteInput: RemoteInput): Action;
|
|
|
|
setAllowGenerateReplies(allowGeneratedReplies: boolean): Action;
|
|
|
|
setSemanticAction(semanticAction: SemanticAction): Action;
|
|
|
|
setShowUserInterface(showUserInterface: boolean): Action;
|
Implement handling of Android actions in background
There are some cases when local notification action should be handled in
background eg. snoozing the reminder. In case of it launching app UI is
not necessary and would be confusing for the end user.
Therefore there should be a way to handle local notification action in
background.
For this reason new property 'runInBackground' was added to the
AndroidAction class and TypeScript type.
Also new broadcast receiver and service were implemented to handle
properly background actions.
In order to run particular action in background API consumer need to set its
'runInBackground' property to 'true', eg:
...
.android.addAction(new firebase.notifications.Android.Action("snooze",
"ic_snooze", "Snooze").setRunInBackground(true))
...
Then, there are two cases that API consumer needs to handle.
First when app is in the foreground, standard notification and
notification action code path will be executed. This mean, that:
* onNotification() listener will be called (which should call
displayNotification(), in order to show it to the user),
* onNotificationOpen() listener will be called after the action is
tapped by the user
Secondly, when application is in background or it is not running new
'RNFirebaseBackgroundNotificationAction' handler will be called. To
properly handle this case API consumer should create a background
asynchronous handler:
const handleAsyncTask = async (notificationOpen: NotifficationOpen) => {
if (notificationOpen && notificationOpen.notification) {
const action = notificationOpen.action;
const notificationId = notificationOpen.notification.notificationId;
if (action === "snooze") {
console.log("Reschedule notification for later time", notificationId);
} else {
console.log("unsupported action", action);
}
// hide the notification
firebase.notifications().removeDeliveredNotification(notificationId);
}
}
Next hander should be registered to headless handler:
AppRegistry.registerHeadlessTask('RNFirebaseBackgroundNotificationAction', () => handleAsyncTask);
Finally AndroidManifest.xml file must be modified, to include receiver
and service definition:
<receiver
android:name="io.invertase.firebase.notifications.RNFirebaseBackgroundNotificationActionReceiver"
android:exported="true">
<intent-filter>
<action android:name="io.invertase.firebase.notifications.BackgroundAction"/>
</intent-filter>
</receiver>
<service android:name="io.invertase.firebase.notifications.RNFirebaseBackgroundNotificationActionsService"/>
Now when ever 'Snooze' action is pressed it will launch
'handleAsyncTask' function in the background or onNotificationOpen()
when app is in foreground. And reschedule the notification
for the later time.
2018-05-11 21:09:32 +00:00
|
|
|
setRunInBackground(runInBackground: boolean): Action;
|
2018-04-08 09:46:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class RemoteInput {
|
2018-05-04 15:30:32 +00:00
|
|
|
allowedDataTypes: any[];
|
|
|
|
allowFreeFormInput?: boolean;
|
|
|
|
choices: string[];
|
|
|
|
label?: string;
|
|
|
|
resultKey: string;
|
2018-04-08 09:46:41 +00:00
|
|
|
|
|
|
|
constructor(resultKey: string);
|
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
setAllowDataType(mimeType: string, allow: boolean): RemoteInput;
|
|
|
|
setAllowFreeFormInput(allowFreeFormInput: boolean): RemoteInput;
|
2018-04-08 09:46:41 +00:00
|
|
|
setChoices(choices: string[]): RemoteInput;
|
|
|
|
setLabel(label: string): RemoteInput;
|
|
|
|
}
|
|
|
|
|
|
|
|
class Channel {
|
2018-05-04 15:30:32 +00:00
|
|
|
channelId: string;
|
|
|
|
name: string;
|
|
|
|
importance: Importance;
|
|
|
|
|
|
|
|
bypassDnd?: boolean;
|
|
|
|
description?: string;
|
|
|
|
group?: string;
|
|
|
|
lightColor?: string;
|
|
|
|
lightsEnabled?: boolean;
|
|
|
|
lockScreenVisibility?: Visibility;
|
|
|
|
showBadge?: boolean;
|
|
|
|
sound?: string;
|
|
|
|
vibrationEnabled?: boolean;
|
|
|
|
vibrationPattern?: number[];
|
|
|
|
|
|
|
|
constructor(channelId: string, name: string, importance: Importance);
|
|
|
|
|
|
|
|
enableLights(lightsEnabled: boolean): Channel;
|
|
|
|
enableVibration(vibrationEnabled: boolean): Channel;
|
|
|
|
setBypassDnd(bypassDnd: boolean): Channel;
|
|
|
|
setDescription(description: string): Channel;
|
|
|
|
setGroup(groupId: string): Channel;
|
|
|
|
setLightColor(lightColor: string): Channel;
|
|
|
|
setLockScreenVisibility(lockScreenVisibility: Visibility): Channel;
|
|
|
|
setShowBadge(showBadge: boolean): Channel;
|
|
|
|
setSound(sound: string): Channel;
|
|
|
|
setVibrationPattern(vibrationPattern: number[]): Channel;
|
2018-04-08 09:46:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class ChannelGroup {
|
2018-05-04 15:30:32 +00:00
|
|
|
groupId: string;
|
|
|
|
name: string;
|
2018-04-08 09:46:41 +00:00
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
constructor(groupId: string, name: string);
|
2018-04-08 09:46:41 +00:00
|
|
|
}
|
2018-04-12 07:50:13 +00:00
|
|
|
|
2018-04-08 09:46:41 +00:00
|
|
|
export enum BadgeIconType {
|
|
|
|
Large = 2,
|
|
|
|
None = 0,
|
2018-05-04 15:30:32 +00:00
|
|
|
Small = 1,
|
2018-04-08 09:46:41 +00:00
|
|
|
}
|
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
export type Category =
|
|
|
|
| 'alarm'
|
2018-04-08 09:46:41 +00:00
|
|
|
| 'call'
|
|
|
|
| 'email'
|
|
|
|
| 'err'
|
|
|
|
| 'event'
|
|
|
|
| 'msg'
|
|
|
|
| 'progress'
|
|
|
|
| 'promo'
|
|
|
|
| 'recommendation'
|
|
|
|
| 'reminder'
|
|
|
|
| 'service'
|
|
|
|
| 'social'
|
|
|
|
| 'status'
|
|
|
|
| 'system'
|
2018-05-04 15:30:32 +00:00
|
|
|
| 'transport';
|
2018-04-08 09:46:41 +00:00
|
|
|
|
|
|
|
export enum Defaults {
|
|
|
|
All = -1,
|
|
|
|
Lights = 4,
|
|
|
|
Sound = 1,
|
2018-05-04 15:30:32 +00:00
|
|
|
Vibrate = 2,
|
2018-04-08 09:46:41 +00:00
|
|
|
}
|
2018-04-12 07:50:13 +00:00
|
|
|
|
2018-04-08 09:46:41 +00:00
|
|
|
export enum GroupAlert {
|
|
|
|
All = 0,
|
|
|
|
Children = 2,
|
2018-05-04 15:30:32 +00:00
|
|
|
Summary = 1,
|
2018-04-08 09:46:41 +00:00
|
|
|
}
|
2018-04-12 07:50:13 +00:00
|
|
|
|
2018-04-08 09:46:41 +00:00
|
|
|
export enum Importance {
|
|
|
|
Default = 3,
|
|
|
|
High = 4,
|
|
|
|
Low = 2,
|
|
|
|
Max = 5,
|
|
|
|
Min = 1,
|
|
|
|
None = 3,
|
2018-05-04 15:30:32 +00:00
|
|
|
Unspecified = -1000,
|
2018-04-08 09:46:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export enum Priority {
|
|
|
|
Default = 0,
|
|
|
|
High = 1,
|
|
|
|
Low = -1,
|
|
|
|
Max = 2,
|
2018-05-04 15:30:32 +00:00
|
|
|
Min = -2,
|
2018-04-08 09:46:41 +00:00
|
|
|
}
|
2018-04-12 07:50:13 +00:00
|
|
|
|
2018-04-08 09:46:41 +00:00
|
|
|
export enum SemanticAction {
|
|
|
|
Archive = 5,
|
|
|
|
Call = 10,
|
|
|
|
Delete = 4,
|
|
|
|
MarkAsRead = 2,
|
|
|
|
MarkAsUnread = 3,
|
|
|
|
Mute = 6,
|
|
|
|
None = 0,
|
|
|
|
Reply = 1,
|
|
|
|
ThumbsDown = 9,
|
|
|
|
ThumbsUp = 8,
|
2018-05-04 15:30:32 +00:00
|
|
|
Unmute = 7,
|
2018-04-08 09:46:41 +00:00
|
|
|
}
|
2018-04-12 07:50:13 +00:00
|
|
|
|
2018-04-08 09:46:41 +00:00
|
|
|
export enum Visibility {
|
|
|
|
Private = 0,
|
|
|
|
Public = 1,
|
2018-05-04 15:30:32 +00:00
|
|
|
Secret = -1,
|
2018-04-08 09:46:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class Lights {
|
|
|
|
argb: number;
|
|
|
|
offMs: number;
|
|
|
|
onMs: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
class Progress {
|
|
|
|
indeterminate: boolean;
|
|
|
|
max: number;
|
|
|
|
progress: number;
|
|
|
|
}
|
|
|
|
}
|
2018-04-12 07:50:13 +00:00
|
|
|
|
2018-04-08 09:46:41 +00:00
|
|
|
class IOSNotification {
|
2018-05-04 15:30:32 +00:00
|
|
|
alertAction?: string;
|
|
|
|
attachments: IOSAttachment[];
|
|
|
|
badge?: string;
|
|
|
|
category?: string;
|
|
|
|
hasAction?: boolean;
|
|
|
|
launchImage?: string;
|
|
|
|
threadIdentifier?: string;
|
|
|
|
|
|
|
|
addAttachment(
|
|
|
|
identifier: string,
|
|
|
|
url: string,
|
|
|
|
options: IOSAttachmentOptions
|
|
|
|
): Notification;
|
|
|
|
setAlertAction(alertAction: string): Notification;
|
|
|
|
setBadge(badge: string): Notification;
|
|
|
|
setCategory(category: string): Notification;
|
|
|
|
setHasAction(hasAction: boolean): Notification;
|
|
|
|
setLaunchImage(launchImage: string): Notification;
|
|
|
|
setThreadIdentifier(threadIdentifier: string): Notification;
|
2018-04-08 09:46:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class IOSAttachment {
|
2018-05-04 15:30:32 +00:00
|
|
|
identifier: string;
|
|
|
|
options: IOSAttachmentOptions;
|
|
|
|
url: string;
|
2018-04-08 09:46:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class IOSAttachmentOptions {
|
2018-05-04 15:30:32 +00:00
|
|
|
typeHint: string;
|
|
|
|
thumbnailHidden: boolean;
|
|
|
|
thumbnailClippingRect: any;
|
|
|
|
thumbnailTime: string;
|
2018-04-08 09:46:41 +00:00
|
|
|
}
|
2018-04-12 07:50:13 +00:00
|
|
|
|
|
|
|
interface NotificationsStatics {
|
|
|
|
Android: {
|
2018-05-04 15:30:32 +00:00
|
|
|
Action: typeof Android.Action;
|
|
|
|
BadgeIconType: typeof Android.BadgeIconType;
|
|
|
|
Category: Android.Category;
|
|
|
|
Channel: typeof Android.Channel;
|
|
|
|
ChannelGroup: typeof Android.ChannelGroup;
|
|
|
|
Defaults: typeof Android.Defaults;
|
|
|
|
GroupAlert: typeof Android.GroupAlert;
|
|
|
|
Importance: typeof Android.Importance;
|
|
|
|
Priority: typeof Android.Priority;
|
|
|
|
RemoteInput: typeof Android.RemoteInput;
|
|
|
|
SemanticAction: typeof Android.SemanticAction;
|
|
|
|
Visibility: typeof Android.Visibility;
|
2018-04-12 07:50:13 +00:00
|
|
|
};
|
2018-04-16 07:14:30 +00:00
|
|
|
Notification: typeof Notification;
|
2018-04-12 07:50:13 +00:00
|
|
|
}
|
2017-03-23 10:06:07 +00:00
|
|
|
}
|
2018-03-23 17:31:25 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
namespace crash {
|
|
|
|
interface Crash {
|
|
|
|
/** Logs a message that will appear in a subsequent crash report. */
|
2018-05-04 15:30:32 +00:00
|
|
|
log(message: string): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
|
|
|
* Android: Logs a message that will appear in a subsequent crash report as well as in logcat.
|
|
|
|
* iOS: Logs the message in the subsequest crash report only (same as log).
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
logcat(level: number, tag: string, message: string): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-03-30 14:09:48 +00:00
|
|
|
/**
|
2017-06-19 11:25:58 +00:00
|
|
|
* Files a crash report, along with any previous logs to Firebase.
|
2017-03-30 14:09:48 +00:00
|
|
|
* An Error object must be passed into the report method.
|
|
|
|
*/
|
2018-05-04 15:30:32 +00:00
|
|
|
report(error: RnError, maxStackSize: Number): void;
|
2017-11-08 08:31:24 +00:00
|
|
|
|
2017-04-26 19:12:59 +00:00
|
|
|
[key: string]: any;
|
2017-03-30 14:09:48 +00:00
|
|
|
}
|
2017-03-23 10:06:07 +00:00
|
|
|
}
|
2018-01-04 02:39:10 +00:00
|
|
|
|
|
|
|
namespace crashlytics {
|
|
|
|
interface Crashlytics {
|
|
|
|
/**
|
|
|
|
* Forces a crash. Useful for testing your application is set up correctly.
|
|
|
|
*/
|
|
|
|
crash(): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Logs a message that will appear in any subsequent crash reports.
|
|
|
|
*/
|
|
|
|
log(message: string): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Logs a non fatal exception.
|
|
|
|
*/
|
|
|
|
recordError(code: number, message: string): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a boolean value to show alongside any subsequent crash reports.
|
|
|
|
*/
|
|
|
|
setBoolValue(key: string, value: boolean): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a float value to show alongside any subsequent crash reports.
|
|
|
|
*/
|
|
|
|
setFloatValue(key: string, value: number): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set an integer value to show alongside any subsequent crash reports.
|
|
|
|
*/
|
|
|
|
setIntValue(key: string, value: number): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a string value to show alongside any subsequent crash reports.
|
|
|
|
*/
|
|
|
|
setStringValue(key: string, value: string): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the user ID to show alongside any subsequent crash reports.
|
|
|
|
*/
|
|
|
|
setUserIdentifier(userId: string): void;
|
|
|
|
}
|
|
|
|
}
|
2018-01-16 11:34:26 +00:00
|
|
|
|
|
|
|
namespace links {
|
|
|
|
interface Links {
|
|
|
|
/** Creates a standard dynamic link. */
|
2018-03-23 17:31:25 +00:00
|
|
|
createDynamicLink(dynamicLink: DynamicLink): Promise<string>;
|
2018-01-16 11:34:26 +00:00
|
|
|
/** Creates a short dynamic link. */
|
2018-03-23 17:31:25 +00:00
|
|
|
createShortDynamicLink(type: 'SHORT' | 'UNGUESSABLE'): Promise<string>;
|
2018-01-16 11:34:26 +00:00
|
|
|
/**
|
|
|
|
* Returns the URL that the app has been launched from. If the app was
|
|
|
|
* not launched from a URL the return value will be null.
|
|
|
|
*/
|
|
|
|
getInitialLink(): Promise<string | null>;
|
|
|
|
/**
|
|
|
|
* Subscribe to URL open events while the app is still running.
|
|
|
|
* The listener is called from URL open events whilst the app is still
|
|
|
|
* running, use getInitialLink for URLs which cause the app to open
|
|
|
|
* from a previously closed / not running state.
|
|
|
|
* Returns an unsubscribe function, call the returned function to
|
|
|
|
* unsubscribe from all future events.
|
|
|
|
*/
|
2018-01-26 16:39:52 +00:00
|
|
|
onLink(listener: (url: string) => void): () => void;
|
2018-01-16 11:34:26 +00:00
|
|
|
}
|
2018-01-26 12:34:06 +00:00
|
|
|
|
2018-04-13 07:14:28 +00:00
|
|
|
class DynamicLink {
|
2018-05-04 15:30:32 +00:00
|
|
|
analytics: AnalyticsParameters;
|
|
|
|
android: AndroidParameters;
|
|
|
|
ios: IOSParameters;
|
|
|
|
itunes: ITunesParameters;
|
|
|
|
navigation: NavigationParameters;
|
|
|
|
social: SocialParameters;
|
2018-04-13 07:14:28 +00:00
|
|
|
|
|
|
|
constructor(link: string, dynamicLinkDomain: string);
|
2018-03-23 17:31:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface AnalyticsParameters {
|
2018-05-04 15:30:32 +00:00
|
|
|
setCampaign(campaign: string): DynamicLink;
|
|
|
|
setContent(content: string): DynamicLink;
|
|
|
|
setMedium(medium: string): DynamicLink;
|
|
|
|
setSource(source: string): DynamicLink;
|
|
|
|
setTerm(term: string): DynamicLink;
|
2018-03-23 17:31:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface AndroidParameters {
|
2018-05-04 15:30:32 +00:00
|
|
|
setFallbackUrl(fallbackUrl: string): DynamicLink;
|
|
|
|
setMinimumVersion(minimumVersion: number): DynamicLink;
|
|
|
|
setPackageName(packageName: string): DynamicLink;
|
2018-03-23 17:31:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface IOSParameters {
|
2018-05-04 15:30:32 +00:00
|
|
|
setAppStoreId(appStoreId: string): DynamicLink;
|
|
|
|
setBundleId(bundleId: string): DynamicLink;
|
|
|
|
setCustomScheme(customScheme: string): DynamicLink;
|
|
|
|
setFallbackUrl(fallbackUrl: string): DynamicLink;
|
|
|
|
setIPadBundleId(iPadBundleId: string): DynamicLink;
|
|
|
|
setIPadFallbackUrl(iPadFallbackUrl: string): DynamicLink;
|
|
|
|
setMinimumVersion(minimumVersion: string): DynamicLink;
|
2018-03-23 17:31:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface ITunesParameters {
|
2018-05-04 15:30:32 +00:00
|
|
|
setAffiliateToken(affiliateToken: string): DynamicLink;
|
|
|
|
setCampaignToken(campaignToken: string): DynamicLink;
|
|
|
|
setProviderToken(providerToken: string): DynamicLink;
|
2018-03-23 17:31:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface NavigationParameters {
|
2018-05-04 15:30:32 +00:00
|
|
|
setForcedRedirectEnabled(forcedRedirectEnabled: boolean): DynamicLink;
|
2018-03-23 17:31:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface SocialParameters {
|
2018-05-04 15:30:32 +00:00
|
|
|
setDescriptionText(descriptionText: string): DynamicLink;
|
|
|
|
setImageUrl(imageUrl: string): DynamicLink;
|
|
|
|
setTitle(title: string): DynamicLink;
|
2018-01-16 11:34:26 +00:00
|
|
|
}
|
2018-04-12 07:50:13 +00:00
|
|
|
|
|
|
|
interface LinksStatics {
|
2018-04-16 07:14:30 +00:00
|
|
|
DynamicLink: typeof DynamicLink;
|
2018-04-12 07:50:13 +00:00
|
|
|
}
|
2018-01-16 11:34:26 +00:00
|
|
|
}
|
2018-01-22 12:25:54 +00:00
|
|
|
|
2018-05-07 18:49:34 +00:00
|
|
|
// Source: https://github.com/firebase/firebase-js-sdk/blob/master/packages/functions-types/index.d.ts
|
|
|
|
namespace functions {
|
|
|
|
type HttpsErrorCode = { [name: string]: FunctionsErrorCode };
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The set of Firebase Functions status codes. The codes are the same at the
|
|
|
|
* ones exposed by gRPC here:
|
|
|
|
* https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
|
|
|
|
*
|
|
|
|
* Possible values:
|
|
|
|
* - 'cancelled': The operation was cancelled (typically by the caller).
|
|
|
|
* - 'unknown': Unknown error or an error from a different error domain.
|
|
|
|
* - 'invalid-argument': Client specified an invalid argument. Note that this
|
|
|
|
* differs from 'failed-precondition'. 'invalid-argument' indicates
|
|
|
|
* arguments that are problematic regardless of the state of the system
|
|
|
|
* (e.g. an invalid field name).
|
|
|
|
* - 'deadline-exceeded': Deadline expired before operation could complete.
|
|
|
|
* For operations that change the state of the system, this error may be
|
|
|
|
* returned even if the operation has completed successfully. For example,
|
|
|
|
* a successful response from a server could have been delayed long enough
|
|
|
|
* for the deadline to expire.
|
|
|
|
* - 'not-found': Some requested document was not found.
|
|
|
|
* - 'already-exists': Some document that we attempted to create already
|
|
|
|
* exists.
|
|
|
|
* - 'permission-denied': The caller does not have permission to execute the
|
|
|
|
* specified operation.
|
|
|
|
* - 'resource-exhausted': Some resource has been exhausted, perhaps a
|
|
|
|
* per-user quota, or perhaps the entire file system is out of space.
|
|
|
|
* - 'failed-precondition': Operation was rejected because the system is not
|
|
|
|
* in a state required for the operation's execution.
|
|
|
|
* - 'aborted': The operation was aborted, typically due to a concurrency
|
|
|
|
* issue like transaction aborts, etc.
|
|
|
|
* - 'out-of-range': Operation was attempted past the valid range.
|
|
|
|
* - 'unimplemented': Operation is not implemented or not supported/enabled.
|
|
|
|
* - 'internal': Internal errors. Means some invariants expected by
|
|
|
|
* underlying system has been broken. If you see one of these errors,
|
|
|
|
* something is very broken.
|
|
|
|
* - 'unavailable': The service is currently unavailable. This is most likely
|
|
|
|
* a transient condition and may be corrected by retrying with a backoff.
|
|
|
|
* - 'data-loss': Unrecoverable data loss or corruption.
|
|
|
|
* - 'unauthenticated': The request does not have valid authentication
|
|
|
|
* credentials for the operation.
|
|
|
|
*/
|
|
|
|
type FunctionsErrorCode =
|
|
|
|
| 'ok'
|
|
|
|
| 'cancelled'
|
|
|
|
| 'unknown'
|
|
|
|
| 'invalid-argument'
|
|
|
|
| 'deadline-exceeded'
|
|
|
|
| 'not-found'
|
|
|
|
| 'already-exists'
|
|
|
|
| 'permission-denied'
|
|
|
|
| 'resource-exhausted'
|
|
|
|
| 'failed-precondition'
|
|
|
|
| 'aborted'
|
|
|
|
| 'out-of-range'
|
|
|
|
| 'unimplemented'
|
|
|
|
| 'internal'
|
|
|
|
| 'unavailable'
|
|
|
|
| 'data-loss'
|
|
|
|
| 'unauthenticated';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An HttpsCallableResult wraps a single result from a function call.
|
|
|
|
*/
|
|
|
|
interface HttpsCallableResult {
|
|
|
|
readonly data: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An HttpsCallable is a reference to a "callable" http trigger in
|
|
|
|
* Google Cloud Functions.
|
|
|
|
*/
|
|
|
|
interface HttpsCallable {
|
|
|
|
(data?: any): Promise<HttpsCallableResult>;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* `FirebaseFunctions` represents a Functions app, and is the entry point for
|
|
|
|
* all Functions operations.
|
|
|
|
*/
|
|
|
|
interface Functions {
|
|
|
|
/**
|
|
|
|
* Gets an `HttpsCallable` instance that refers to the function with the given
|
|
|
|
* name.
|
|
|
|
*
|
|
|
|
* @param name The name of the https callable function.
|
|
|
|
* @return The `HttpsCallable` instance.
|
|
|
|
*/
|
|
|
|
httpsCallable(name: string): HttpsCallable;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* firebase.functions.X
|
|
|
|
*/
|
|
|
|
interface FunctionsStatics {
|
|
|
|
/**
|
|
|
|
* Uppercased + underscored variables of @FunctionsErrorCode
|
|
|
|
*/
|
|
|
|
HttpsErrorCode: HttpsErrorCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface HttpsError extends Error {
|
|
|
|
/**
|
|
|
|
* A standard error code that will be returned to the client. This also
|
|
|
|
* determines the HTTP status code of the response, as defined in code.proto.
|
|
|
|
*/
|
|
|
|
readonly code: FunctionsErrorCode;
|
|
|
|
/**
|
|
|
|
* Extra data to be converted to JSON and included in the error response.
|
|
|
|
*/
|
|
|
|
readonly details?: any;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-22 12:25:54 +00:00
|
|
|
namespace firestore {
|
|
|
|
interface Firestore {
|
2018-01-31 09:09:12 +00:00
|
|
|
readonly app: App;
|
2018-01-22 12:25:54 +00:00
|
|
|
batch(): WriteBatch;
|
|
|
|
collection(collectionPath: string): CollectionReference;
|
2018-05-04 15:30:32 +00:00
|
|
|
disableNetwork(): Promise<void>;
|
2018-01-22 12:25:54 +00:00
|
|
|
doc(documentPath: string): DocumentReference;
|
2018-04-13 08:58:53 +00:00
|
|
|
enableNetwork(): Promise<void>;
|
|
|
|
enablePersistence(enabled: boolean): Promise<void>;
|
2018-05-04 15:30:32 +00:00
|
|
|
runTransaction(
|
|
|
|
updateFunction: (transaction: Transaction) => Promise<any>
|
|
|
|
): Promise<any>;
|
2018-04-13 08:58:53 +00:00
|
|
|
settings(settings: Settings): Promise<void>;
|
2018-01-22 12:25:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface FirestoreStatics {
|
2018-05-04 15:30:32 +00:00
|
|
|
Blob: typeof Blob;
|
2018-01-22 12:25:54 +00:00
|
|
|
FieldPath: typeof FieldPath;
|
|
|
|
FieldValue: typeof FieldValue;
|
|
|
|
GeoPoint: typeof GeoPoint;
|
|
|
|
enableLogging(enabled: boolean): void;
|
2018-04-13 07:41:17 +00:00
|
|
|
setLogLevel(logLevel: 'debug' | 'error' | 'silent'): void;
|
2018-01-29 23:07:07 +00:00
|
|
|
}
|
2018-01-22 12:25:54 +00:00
|
|
|
|
2018-01-29 09:55:18 +00:00
|
|
|
interface CollectionReference {
|
|
|
|
readonly firestore: Firestore;
|
|
|
|
readonly id: string;
|
|
|
|
readonly parent: DocumentReference;
|
2018-01-22 12:25:54 +00:00
|
|
|
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;
|
2018-05-04 15:30:32 +00:00
|
|
|
onSnapshot(
|
|
|
|
onNext: Query.ObserverOnNext,
|
|
|
|
onError?: Query.ObserverOnError
|
|
|
|
): () => void;
|
2018-01-29 23:07:07 +00:00
|
|
|
onSnapshot(observer: Query.Observer): () => void;
|
2018-05-04 15:30:32 +00:00
|
|
|
onSnapshot(
|
2018-05-08 14:36:40 +00:00
|
|
|
metadataChanges: MetadataChanges,
|
2018-05-04 15:30:32 +00:00
|
|
|
onNext: Query.ObserverOnNext,
|
|
|
|
onError?: Query.ObserverOnError
|
|
|
|
): () => void;
|
|
|
|
onSnapshot(
|
2018-05-08 14:36:40 +00:00
|
|
|
metadataChanges: MetadataChanges,
|
2018-05-04 15:30:32 +00:00
|
|
|
observer: Query.Observer
|
|
|
|
): () => void;
|
|
|
|
orderBy(
|
|
|
|
fieldPath: string | FieldPath,
|
|
|
|
directionStr?: Types.QueryDirection
|
|
|
|
): Query;
|
2018-01-22 12:25:54 +00:00
|
|
|
startAfter(snapshot: DocumentSnapshot): Query;
|
|
|
|
startAfter(...varargs: any[]): Query;
|
|
|
|
startAt(snapshot: DocumentSnapshot): Query;
|
|
|
|
startAt(...varargs: any[]): Query;
|
2018-05-04 15:30:32 +00:00
|
|
|
where(
|
|
|
|
fieldPath: string | FieldPath,
|
|
|
|
op: Types.QueryOperator,
|
|
|
|
value: any
|
|
|
|
): Query;
|
2018-01-22 12:25:54 +00:00
|
|
|
}
|
|
|
|
|
2018-01-29 09:55:18 +00:00
|
|
|
interface DocumentChange {
|
|
|
|
readonly doc: DocumentSnapshot;
|
|
|
|
readonly newIndex: number;
|
|
|
|
readonly oldIndex: number;
|
|
|
|
readonly type: string;
|
2018-01-22 12:25:54 +00:00
|
|
|
}
|
|
|
|
|
2018-01-29 09:55:18 +00:00
|
|
|
interface DocumentReference {
|
|
|
|
readonly firestore: Firestore;
|
|
|
|
readonly id: string | null;
|
|
|
|
readonly parent: CollectionReference;
|
|
|
|
readonly path: string;
|
2018-01-22 12:25:54 +00:00
|
|
|
collection(collectionPath: string): CollectionReference;
|
|
|
|
delete(): Promise<void>;
|
|
|
|
get(): Promise<DocumentSnapshot>;
|
2018-05-04 15:30:32 +00:00
|
|
|
onSnapshot(
|
|
|
|
onNext: DocumentReference.ObserverOnNext,
|
|
|
|
onError?: DocumentReference.ObserverOnError
|
|
|
|
): () => void;
|
2018-01-22 12:25:54 +00:00
|
|
|
onSnapshot(observer: DocumentReference.Observer): () => void;
|
2018-05-04 15:30:32 +00:00
|
|
|
onSnapshot(
|
2018-05-08 14:36:40 +00:00
|
|
|
metadataChanges: MetadataChanges,
|
2018-05-04 15:30:32 +00:00
|
|
|
onNext: DocumentReference.ObserverOnNext,
|
|
|
|
onError?: DocumentReference.ObserverOnError
|
|
|
|
): () => void;
|
|
|
|
onSnapshot(
|
2018-05-08 14:36:40 +00:00
|
|
|
metadataChanges: MetadataChanges,
|
2018-05-04 15:30:32 +00:00
|
|
|
observer: DocumentReference.Observer
|
|
|
|
): () => void;
|
2018-01-22 12:25:54 +00:00
|
|
|
set(data: object, writeOptions?: Types.WriteOptions): Promise<void>;
|
|
|
|
update(obj: object): Promise<void>;
|
|
|
|
update(key1: Types.UpdateKey, val1: any): Promise<void>;
|
2018-05-04 15:30:32 +00:00
|
|
|
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>;
|
2018-01-22 12:25:54 +00:00
|
|
|
}
|
|
|
|
namespace DocumentReference {
|
|
|
|
type ObserverOnNext = (documentSnapshot: DocumentSnapshot) => void;
|
|
|
|
type ObserverOnError = (err: object) => void;
|
|
|
|
interface Observer {
|
|
|
|
next: ObserverOnNext;
|
|
|
|
error?: ObserverOnError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 09:55:18 +00:00
|
|
|
interface DocumentSnapshot {
|
|
|
|
readonly exists: boolean;
|
|
|
|
readonly id: string | null;
|
|
|
|
readonly metadata: Types.SnapshotMetadata;
|
|
|
|
readonly ref: DocumentReference;
|
2018-01-22 12:25:54 +00:00
|
|
|
data(): object | void;
|
|
|
|
get(fieldPath: string | FieldPath): any | undefined;
|
|
|
|
}
|
|
|
|
|
2018-05-04 15:30:32 +00:00
|
|
|
class Blob {
|
|
|
|
static fromBase64String(base64: string): Blob;
|
|
|
|
static fromUint8Array(array: Uint8Array): Blob;
|
|
|
|
isEqual(other: Blob): boolean;
|
|
|
|
toBase64(): string;
|
|
|
|
toUint8Array: Uint8Array;
|
|
|
|
}
|
|
|
|
|
2018-01-22 12:25:54 +00:00
|
|
|
class FieldPath {
|
|
|
|
static documentId(): FieldPath;
|
|
|
|
constructor(...segments: string[]);
|
|
|
|
}
|
|
|
|
|
|
|
|
class FieldValue {
|
|
|
|
static delete(): FieldValue;
|
|
|
|
static serverTimestamp(): FieldValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
class GeoPoint {
|
|
|
|
constructor(latitude: number, longitude: number);
|
2018-01-29 23:07:07 +00:00
|
|
|
readonly latitude: number;
|
|
|
|
readonly longitude: number;
|
2018-01-22 12:25:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class Path {
|
|
|
|
static fromName(name: string): Path;
|
|
|
|
constructor(pathComponents: string[]);
|
2018-01-29 23:07:07 +00:00
|
|
|
readonly id: string | null;
|
|
|
|
readonly isDocument: boolean;
|
|
|
|
readonly isCollection: boolean;
|
|
|
|
readonly relativeName: string;
|
2018-01-22 12:25:54 +00:00
|
|
|
child(relativePath: string): Path;
|
|
|
|
parent(): Path | null;
|
|
|
|
}
|
|
|
|
|
2018-05-08 14:36:40 +00:00
|
|
|
type MetadataChanges = {
|
|
|
|
includeMetadataChanges: boolean;
|
|
|
|
};
|
|
|
|
|
2018-01-29 09:55:18 +00:00
|
|
|
interface Query {
|
|
|
|
readonly firestore: Firestore;
|
2018-01-22 12:25:54 +00:00
|
|
|
endAt(snapshot: DocumentSnapshot): Query;
|
|
|
|
endAt(...varargs: any[]): Query;
|
|
|
|
endBefore(snapshot: DocumentSnapshot): Query;
|
|
|
|
endBefore(...varargs: any[]): Query;
|
|
|
|
get(): Promise<QuerySnapshot>;
|
|
|
|
limit(limit: number): Query;
|
2018-05-04 15:30:32 +00:00
|
|
|
onSnapshot(
|
|
|
|
onNext: Query.ObserverOnNext,
|
|
|
|
onError?: Query.ObserverOnError
|
|
|
|
): () => void;
|
2018-01-29 09:55:18 +00:00
|
|
|
onSnapshot(observer: Query.Observer): () => void;
|
2018-05-04 15:30:32 +00:00
|
|
|
onSnapshot(
|
2018-05-08 14:36:40 +00:00
|
|
|
metadataChanges: MetadataChanges,
|
2018-05-04 15:30:32 +00:00
|
|
|
onNext: Query.ObserverOnNext,
|
|
|
|
onError?: Query.ObserverOnError
|
|
|
|
): () => void;
|
|
|
|
onSnapshot(
|
2018-05-08 14:36:40 +00:00
|
|
|
metadataChanges: MetadataChanges,
|
2018-05-04 15:30:32 +00:00
|
|
|
observer: Query.Observer
|
|
|
|
): () => void;
|
|
|
|
orderBy(
|
|
|
|
fieldPath: string | FieldPath,
|
|
|
|
directionStr?: Types.QueryDirection
|
|
|
|
): Query;
|
2018-01-22 12:25:54 +00:00
|
|
|
startAfter(snapshot: DocumentSnapshot): Query;
|
|
|
|
startAfter(...varargs: any[]): Query;
|
|
|
|
startAt(snapshot: DocumentSnapshot): Query;
|
|
|
|
startAt(...varargs: any[]): Query;
|
2018-05-04 15:30:32 +00:00
|
|
|
where(
|
|
|
|
fieldPath: string | FieldPath,
|
|
|
|
op: Types.QueryOperator,
|
|
|
|
value: any
|
|
|
|
): Query;
|
2018-01-22 12:25:54 +00:00
|
|
|
}
|
|
|
|
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[];
|
|
|
|
}
|
|
|
|
|
|
|
|
type ObserverOnNext = (querySnapshot: QuerySnapshot) => void;
|
|
|
|
type ObserverOnError = (err: object) => void;
|
|
|
|
interface Observer {
|
|
|
|
next: ObserverOnNext;
|
|
|
|
error?: ObserverOnError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 09:55:18 +00:00
|
|
|
interface QuerySnapshot {
|
|
|
|
readonly docChanges: DocumentChange[];
|
|
|
|
readonly docs: DocumentSnapshot[];
|
|
|
|
readonly empty: boolean;
|
|
|
|
readonly metadata: Types.SnapshotMetadata;
|
|
|
|
readonly query: Query;
|
|
|
|
readonly size: number;
|
2018-01-29 23:44:57 +00:00
|
|
|
forEach(callback: (snapshot: DocumentSnapshot) => any): void;
|
2018-01-22 12:25:54 +00:00
|
|
|
}
|
|
|
|
namespace QuerySnapshot {
|
|
|
|
interface NativeData {
|
|
|
|
changes: Types.NativeDocumentChange[];
|
|
|
|
documents: Types.NativeDocumentSnapshot[];
|
|
|
|
metadata: Types.SnapshotMetadata;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-13 08:58:53 +00:00
|
|
|
interface Settings {
|
|
|
|
host?: string;
|
|
|
|
persistence?: boolean;
|
|
|
|
ssl?: boolean;
|
|
|
|
timestampsInSnapshots?: boolean;
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:00:58 +00:00
|
|
|
interface Transaction {
|
|
|
|
delete(docRef: DocumentReference): WriteBatch;
|
|
|
|
get(documentRef: DocumentReference): Promise<DocumentSnapshot>;
|
2018-05-04 15:30:32 +00:00
|
|
|
set(
|
|
|
|
documentRef: DocumentReference,
|
|
|
|
data: Object,
|
|
|
|
options?: Types.WriteOptions
|
|
|
|
): Transaction;
|
2018-03-28 15:00:58 +00:00
|
|
|
// multiple overrides for update() to allow strong-typed var_args
|
|
|
|
update(docRef: DocumentReference, obj: object): WriteBatch;
|
2018-05-04 15:30:32 +00:00
|
|
|
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;
|
2018-03-28 15:00:58 +00:00
|
|
|
}
|
|
|
|
|
2018-01-29 09:55:18 +00:00
|
|
|
interface WriteBatch {
|
2018-01-22 12:25:54 +00:00
|
|
|
commit(): Promise<void>;
|
|
|
|
delete(docRef: DocumentReference): WriteBatch;
|
2018-05-04 15:30:32 +00:00
|
|
|
set(
|
|
|
|
docRef: DocumentReference,
|
|
|
|
data: object,
|
|
|
|
options?: Types.WriteOptions
|
|
|
|
): WriteBatch;
|
2018-01-22 12:25:54 +00:00
|
|
|
// multiple overrides for update() to allow strong-typed var_args
|
|
|
|
update(docRef: DocumentReference, obj: object): WriteBatch;
|
2018-05-04 15:30:32 +00:00
|
|
|
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;
|
2018-01-22 12:25:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
2018-05-04 15:30:32 +00:00
|
|
|
type:
|
|
|
|
| 'array'
|
|
|
|
| 'boolean'
|
|
|
|
| 'date'
|
|
|
|
| 'documentid'
|
|
|
|
| 'fieldvalue'
|
|
|
|
| 'geopoint'
|
|
|
|
| 'null'
|
|
|
|
| 'number'
|
|
|
|
| 'object'
|
|
|
|
| 'reference'
|
|
|
|
| 'string';
|
2018-01-22 12:25:54 +00:00
|
|
|
value: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** The key in update() function for DocumentReference and WriteBatch. */
|
2018-05-04 15:30:32 +00:00
|
|
|
type UpdateKey = string | FieldPath;
|
2018-01-22 12:25:54 +00:00
|
|
|
|
|
|
|
interface WriteOptions {
|
|
|
|
merge?: boolean;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-22 22:43:20 +00:00
|
|
|
}
|
2017-06-19 11:25:58 +00:00
|
|
|
}
|