[utils][js][android] add `firebase.utils().getPlayServicesStatus(): Promise<GoogleApiAvailabilityType | null>` to retrieve the latest play services status. Fixes #1257

This commit is contained in:
Salakar 2018-08-14 01:49:59 +01:00
parent d65d9e405c
commit f86163460d
2 changed files with 12 additions and 2 deletions

View File

@ -73,10 +73,15 @@ public class RNFirebaseModule extends ReactContextBaseJavaModule {
}
}
@ReactMethod
public void getPlayServicesStatus(Promise promise) {
promise.resolve(getPlayServicesStatusMap());
}
/**
* @return
*/
private WritableMap getPlayServicesStatus() {
private WritableMap getPlayServicesStatusMap() {
GoogleApiAvailability gapi = GoogleApiAvailability.getInstance();
final int status = gapi.isGooglePlayServicesAvailable(getReactApplicationContext());
WritableMap result = Arguments.createMap();
@ -176,7 +181,7 @@ public class RNFirebaseModule extends ReactContextBaseJavaModule {
}
constants.put("apps", appMapsList);
constants.put("playServicesAvailability", getPlayServicesStatus());
constants.put("playServicesAvailability", getPlayServicesStatusMap());
return constants;
}
}

View File

@ -55,6 +55,11 @@ export default class RNFirebaseUtils extends ModuleBase {
}
}
getPlayServicesStatus(): Promise<GoogleApiAvailabilityType | null> {
if (isIOS) return Promise.resolve(null);
return FirebaseCoreModule.getPlayServicesStatus();
}
promptForPlayServices() {
if (isIOS) return null;
return FirebaseCoreModule.promptForPlayServices();