Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if firebase service is available?

In cases when the app is running behind a firewall or there is a network outage or some sort of censorship, How can we check using code to see if the app can access the firebase systems?

like image 709
yohannist Avatar asked Jul 14 '16 12:07

yohannist


2 Answers

You should check if Google Play Service is available like this:

/**
* Check the device to make sure it has the Google Play Services APK. If it
* doesn't, display a dialog that allows users to download the APK from the
* Google Play Store or enable it in the device's system settings.
*/
public static boolean checkPlayServices(Context context) {
    int resultCode = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable
            (context);
    if (resultCode != ConnectionResult.SUCCESS) {
        Log.i(TAG, "This device does not support Google Play Services. " +
                "Push notifications are not supported");
        return false;
    }
    return true;
}

You need to add the following line to your build.gradle also.

compile 'com.google.android.gms:play-services-gcm:11.8.0'

like image 65
iStar Avatar answered Oct 02 '22 05:10

iStar


I am guessing currently there is no way you can check whether Firebase is available or not from codes inside the app. However you can check if Firebase itself is working fine by checking Firebase Status Dashboard.

In this site you can also find in what date Firebase service was not available or unstable in the past.

Hope it helps in some way.

https://status.firebase.google.com/

like image 22
shoheikawano Avatar answered Oct 02 '22 07:10

shoheikawano