mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-05-12 08:53:16 +08:00
[js][android] Use GoogleApiAvailability to prompt the user to install Google Play Services if it is not installed
This commit is contained in:
@@ -54,7 +54,7 @@ export default class Firebase {
|
||||
constructor(options: Object = {}) {
|
||||
this.eventHandlers = {};
|
||||
this.debug = options.debug || false;
|
||||
this.options = Object.assign({ errorOnMissingPlayServices: true }, options);
|
||||
this.options = Object.assign({ errorOnMissingPlayServices: true, promptOnMissingPlayServices: true }, options);
|
||||
|
||||
if (this.debug) {
|
||||
Log.enable(this.debug);
|
||||
@@ -62,8 +62,17 @@ export default class Firebase {
|
||||
|
||||
this._log = new Log('firebase');
|
||||
|
||||
if (this.options.errorOnMissingPlayServices && !this.googleApiAvailability.isAvailable) {
|
||||
throw new Error(`Google Play Services is required to run this application but no valid installation was found (Code ${this.googleApiAvailability.status}).`);
|
||||
if (!this.googleApiAvailability.isAvailable) {
|
||||
if (this.options.promptOnMissingPlayServices && this.googleApiAvailability.isUserResolvableError) {
|
||||
FirebaseModule.promptPlayServices();
|
||||
} else {
|
||||
const error = `Google Play Services is required to run this application but no valid installation was found (Code ${this.googleApiAvailability.status}).`;
|
||||
if (this.options.errorOnMissingPlayServices) {
|
||||
throw new Error(error);
|
||||
} else {
|
||||
console.warn(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.auth = this._staticsOrInstance('auth', AuthStatics, Auth);
|
||||
|
||||
Reference in New Issue
Block a user