Merge commit '637cd81424b9a18cdec9735492a21f06be4e7ccf'
This commit is contained in:
commit
cb28c458a8
|
@ -9,6 +9,7 @@ npm-debug.log
|
|||
*.perspectivev3
|
||||
*.xcuserstate
|
||||
project.xcworkspace/
|
||||
atlassian-ide-plugin
|
||||
xcuserdata/
|
||||
|
||||
# Example
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at oss@invertase.io. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
|
@ -6,6 +6,7 @@ import android.util.Log;
|
|||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -1123,6 +1124,7 @@ class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
|||
/**
|
||||
* fetchProvidersForEmail
|
||||
*
|
||||
* @param appName
|
||||
* @param promise
|
||||
*/
|
||||
@ReactMethod
|
||||
|
@ -1157,6 +1159,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
|
||||
* ---------------- */
|
||||
|
@ -1431,4 +1458,29 @@ class RNFirebaseAuth extends ReactContextBaseJavaModule {
|
|||
eventMap.putMap("state", state);
|
||||
Utils.sendEvent(mReactContext, "phone_auth_state_changed", eventMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constants bootstrapped on react native app boot
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getConstants() {
|
||||
Map<String, Object> constants = new HashMap<>();
|
||||
|
||||
List<FirebaseApp> firebaseAppList = FirebaseApp.getApps(getReactApplicationContext());
|
||||
final Map<String, Object> appLanguage = new HashMap<>();
|
||||
|
||||
for (FirebaseApp app : firebaseAppList) {
|
||||
String appName = app.getName();
|
||||
|
||||
FirebaseApp instance = FirebaseApp.getInstance(appName);
|
||||
FirebaseAuth firebaseAuth = FirebaseAuth.getInstance(instance);
|
||||
|
||||
appLanguage.put(appName, firebaseAuth.getLanguageCode());
|
||||
}
|
||||
|
||||
constants.put("APP_LANGUAGE", appLanguage);
|
||||
return constants;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -6,10 +6,12 @@
|
|||
|
||||
|
||||
static void sendDynamicLink(NSURL *url, id sender) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:LINKS_DYNAMIC_LINK_RECEIVED
|
||||
object:sender
|
||||
userInfo:@{@"url": url.absoluteString}];
|
||||
NSLog(@"sendDynamicLink Success: %@", url.absoluteString);
|
||||
if (url) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:LINKS_DYNAMIC_LINK_RECEIVED
|
||||
object:sender
|
||||
userInfo:@{@"url": url.absoluteString}];
|
||||
NSLog(@"sendDynamicLink Success: %@", url.absoluteString);
|
||||
}
|
||||
}
|
||||
|
||||
@implementation RNFirebaseLinks
|
||||
|
|
|
@ -45,6 +45,12 @@ RCT_ENUM_CONVERTER(NSCalendarUnit,
|
|||
content.userInfo = details;
|
||||
content.badge = [RCTConvert NSNumber:details[@"badge"]];
|
||||
|
||||
if([details objectForKey:@"show_in_foreground"] != nil) {
|
||||
if([(NSNumber *)details[@"show_in_foreground"] boolValue] == YES) {
|
||||
[content setValue:@YES forKeyPath:@"shouldAlwaysAlertWhileAppIsForeground"];
|
||||
}
|
||||
}
|
||||
|
||||
NSDate *fireDate = [RCTConvert NSDate:details[@"fire_date"]];
|
||||
|
||||
if(fireDate == nil){
|
||||
|
|
|
@ -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',
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"flow": "flow",
|
||||
"lint": "eslint ./src",
|
||||
"prepublish": "npm run clean && npm run build",
|
||||
"postinstall": "postinstall-build dist && opencollective postinstall",
|
||||
"postinstall": "postinstall-build dist && opencollective postinstall || exit 0",
|
||||
"test-cli": "node ./bin/test.js",
|
||||
"tests-packager": "cd tests && npm run start",
|
||||
"tests-npm-install": "cd tests && npm install",
|
||||
|
|
|
@ -356,6 +356,18 @@ function authTests({ tryCatch, describe, it, firebase }) {
|
|||
return firebase.native.auth().signOut().then(successCb).catch(failureCb);
|
||||
});
|
||||
});
|
||||
|
||||
it('it should change the language code', () => {
|
||||
firebase.native.auth().languageCode = 'en';
|
||||
if (firebase.native.auth().languageCode !== 'en') {
|
||||
throw new Error('Expected language code to be "en".');
|
||||
}
|
||||
firebase.native.auth().languageCode = 'fr';
|
||||
if (firebase.native.auth().languageCode !== 'fr') {
|
||||
throw new Error('Expected language code to be "fr".');
|
||||
}
|
||||
firebase.native.auth().languageCode = 'en';
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue