Merge commit '637cd81424b9a18cdec9735492a21f06be4e7ccf'

This commit is contained in:
Chris Bianca
2018-01-18 09:49:27 +00:00
10 changed files with 259 additions and 5 deletions

68
lib/index.d.ts vendored
View File

@@ -64,6 +64,14 @@ declare module "react-native-firebase" {
*/
crash(): RNFirebase.crash.Crash;
/**
* Firebase Dynamic Links are links that work the way you want, on multiple
* platforms, and whether or not your app is already installed.
* See the official Firebase docs:
* https://firebase.google.com/docs/dynamic-links/
*/
links(): RNFirebase.links.Links;
static fabric: {
crashlytics(): RNFirebase.crashlytics.Crashlytics;
};
@@ -641,6 +649,11 @@ declare module "react-native-firebase" {
*/
currentUser: User | null
/**
* Gets/Sets the language for the app instance
*/
languageCode: string | null;
/**
* Listen for changes in the users auth state (logging in and out).
* This method returns a unsubscribe function to stop listening to events.
@@ -895,5 +908,60 @@ declare module "react-native-firebase" {
setUserIdentifier(userId: string): void;
}
}
namespace links {
interface Links {
/** Creates a standard dynamic link. */
createDynamicLink(parameters: LinkConfiguration): Promise<string>;
/** Creates a short dynamic link. */
createShortDynamicLink(parameters: LinkConfiguration): Promise<string>;
/**
* 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.
*/
onLink(listener: (url) => void): () => void;
}
/**
* Configuration when creating a Dynamic Link (standard or short). For
* more information about each parameter, see the official Firebase docs:
* https://firebase.google.com/docs/reference/dynamic-links/link-shortener
*/
interface LinkConfiguration {
link: string,
dynamicLinkDomain: string,
androidInfo?: {
androidLink?: string,
androidPackageName: string,
androidFallbackLink?: string,
androidMinPackageVersionCode?: string,
},
iosInfo?: {
iosBundleId: string,
iosAppStoreId?: string,
iosFallbackLink?: string,
iosCustomScheme?: string,
iosIpadBundleId?: string,
iosIpadFallbackLink?: string,
},
socialMetaTagInfo?: {
socialTitle: string,
socialImageLink: string,
socialDescription: string,
},
suffix?: {
option: 'SHORT' | 'UNGUESSABLE',
},
}
}
}
}

View File

@@ -57,6 +57,7 @@ export default class Auth extends ModuleBase {
});
this._user = null;
this._authResult = null;
this._languageCode = getNativeModule(this).APP_LANGUAGE[app._name] || getNativeModule(this).APP_LANGUAGE['[DEFAULT]'];
SharedEventEmitter.addListener(
// sub to internal native event - this fans out to
@@ -335,6 +336,16 @@ export default class Auth extends ModuleBase {
return getNativeModule(this).fetchProvidersForEmail(email);
}
/**
* Sets the language for the auth module
* @param code
* @returns {*}
*/
set languageCode(code: string) {
this._languageCode = code;
getNativeModule(this).setLanguageCode(code);
}
/**
* Get the currently signed in user
* @return {Promise}
@@ -343,6 +354,10 @@ export default class Auth extends ModuleBase {
return this._user;
}
get languageCode(): string {
return this._languageCode;
}
/**
* KNOWN UNSUPPORTED METHODS
*/
@@ -366,6 +381,11 @@ export default class Auth extends ModuleBase {
signInWithRedirect() {
throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_MODULE_METHOD('auth', 'signInWithRedirect'));
}
// firebase issue - https://github.com/invertase/react-native-firebase/pull/655#issuecomment-349904680
useDeviceLanguage() {
throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_MODULE_METHOD('auth', 'useDeviceLanguage'));
}
}
export const statics = {