From 8511705d8ee4b3795acb9c03720998d3afc80418 Mon Sep 17 00:00:00 2001 From: Elliot Hesp Date: Thu, 30 Nov 2017 10:02:01 +0000 Subject: [PATCH] [auth][android] Add methods to set the auth language via code or device language --- .../firebase/auth/RNFirebaseAuth.java | 26 +++++++++++++++++++ lib/modules/auth/index.js | 17 ++++++++++++ 2 files changed, 43 insertions(+) diff --git a/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java b/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java index 601f5cb5..36649088 100644 --- a/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java +++ b/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java @@ -1129,6 +1129,7 @@ class RNFirebaseAuth extends ReactContextBaseJavaModule { /** * fetchProvidersForEmail * + * @param appName * @param promise */ @ReactMethod @@ -1163,6 +1164,31 @@ class RNFirebaseAuth extends ReactContextBaseJavaModule { }); } + /** + * Set the language code for the auth module + * @param appName + * @param code + */ + @ReactMethod + public void setLanguageCode(String appName, String code) { + FirebaseApp firebaseApp = FirebaseApp.getInstance(appName); + FirebaseAuth firebaseAuth = FirebaseAuth.getInstance(firebaseApp); + + firebaseAuth.setLanguageCode(code); + } + + /** + * Use the device language + * @param appName + */ + @ReactMethod + public void useDeviceLanguage(String appName) { + FirebaseApp firebaseApp = FirebaseApp.getInstance(appName); + FirebaseAuth firebaseAuth = FirebaseAuth.getInstance(firebaseApp); + + firebaseAuth.useAppLanguage(); + } + /* ------------------ * INTERNAL HELPERS * ---------------- */ diff --git a/lib/modules/auth/index.js b/lib/modules/auth/index.js index 67abfe8a..accc5f8e 100644 --- a/lib/modules/auth/index.js +++ b/lib/modules/auth/index.js @@ -322,6 +322,23 @@ export default class Auth extends ModuleBase { return this._native.fetchProvidersForEmail(email); } + /** + * Sets the language for the auth module using the device language + * @returns {*} + */ + useDeviceLanguage() { + return this._native.useDeviceLanguage(); + } + + /** + * Sets the language for the auth module + * @param code + * @returns {*} + */ + set languageCode(code) { + return this._native.setLanguageCode(code); + } + /** * Get the currently signed in user * @return {Promise}