mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-23 20:10:05 +08:00
Merge pull request #655 from invertase/auth-language
Set auth language #654
This commit is contained in:
@@ -902,6 +902,34 @@ RCT_EXPORT_METHOD(fetchProvidersForEmail:
|
||||
return credential;
|
||||
}
|
||||
|
||||
/**
|
||||
setLanguageCode
|
||||
|
||||
@param NSString code
|
||||
@return
|
||||
*/
|
||||
RCT_EXPORT_METHOD(setLanguageCode:
|
||||
(NSString *) appDisplayName
|
||||
code:
|
||||
(NSString *) code) {
|
||||
FIRApp *firApp = [RNFirebaseUtil getApp:appDisplayName];
|
||||
|
||||
[FIRAuth authWithApp:firApp].languageCode = code;
|
||||
}
|
||||
|
||||
/**
|
||||
useDeviceLanguage
|
||||
|
||||
@param NSString code
|
||||
@return
|
||||
*/
|
||||
RCT_EXPORT_METHOD(useDeviceLanguage:
|
||||
(NSString *) appDisplayName) {
|
||||
FIRApp *firApp = [RNFirebaseUtil getApp:appDisplayName];
|
||||
|
||||
[[FIRAuth authWithApp:firApp] useAppLanguage];
|
||||
}
|
||||
|
||||
// This is here to protect against bugs in the iOS SDK which don't
|
||||
// correctly refresh the user object when performing certain operations
|
||||
- (void)reloadAndReturnUser:(FIRUser *)user
|
||||
@@ -1128,6 +1156,25 @@ RCT_EXPORT_METHOD(fetchProvidersForEmail:
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* React native constant exports - exports native firebase apps mainly
|
||||
* @return NSDictionary
|
||||
*/
|
||||
- (NSDictionary *)constantsToExport {
|
||||
NSMutableDictionary *constants = [NSMutableDictionary new];
|
||||
NSDictionary *firApps = [FIRApp allApps];
|
||||
NSMutableDictionary *appLanguage = [NSMutableDictionary new];
|
||||
|
||||
for (id key in firApps) {
|
||||
FIRApp *firApp = firApps[key];
|
||||
|
||||
appLanguage[firApp.name] = [FIRAuth authWithApp:firApp].languageCode;
|
||||
}
|
||||
|
||||
constants[@"APP_LANGUAGE"] = appLanguage;
|
||||
return constants;
|
||||
}
|
||||
|
||||
/**
|
||||
Converts a FIRUser instance into a dictionary to send via RNBridge
|
||||
|
||||
|
||||
Reference in New Issue
Block a user