My app uses Firebase auth and database. Whenever a phone with a lower Google Play Services version uses the app... the functionality doesn't work and it doesn't tell the user that the version is too low and that they should update, but it does log to the logcat. So my question is: Do I display the warning manually or is there a way firebase can do it for me? If I have to do it manually, how?
Asked
Active
Viewed 3,706 times
3

Onur A.
- 3,007
- 3
- 22
- 37

birukhimself
- 193
- 3
- 14
-
1Described in the [docs for FCM](https://firebase.google.com/docs/cloud-messaging/android/client#sample-play). – Bob Snyder Mar 10 '18 at 19:46
2 Answers
6
During app initialization, your code should call GoogleApiAvailability.makeGooglePlayServicesAvailable(). Example use in onCreate() of main Activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GoogleApiAvailability.getInstance().makeGooglePlayServicesAvailable(this)
.addOnCompleteListener(this, new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "onComplete: Play Services OKAY");
} else {
// Show the user some UI explaining that the needed version
// of Play Services could not be installed and the app can't run.
}
}
});
...
}

Martin De Simone
- 2,108
- 3
- 16
- 30
-
This is the correct answer. Turns out, it was on the documentation. – birukhimself Mar 10 '18 at 19:54
1
For manually checking Google Play Services version; you can use below;
int gpsVersion = getPackageManager().getPackageInfo(GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE, 0).versionCode;

Onur A.
- 3,007
- 3
- 22
- 37