2016-07-14 53 views
1

如果應用程序在防火牆後面運行或出現網絡中斷或某種審查情況,我們如何使用代碼檢查應用程序是否可以訪問Firebase系統?如何檢查是否提供Firebase服務?

+1

如果downvoter解釋了推理,將會有所幫助。 – Yohannes

+0

*不是downvoter *您特別想使用哪些Firebase功能,因爲其中許多人的答案可能不同。 –

+0

@FrankvanPuffelen,我使用了很多(auth,database,fcm,storage)。我的問題是代碼連續失敗,這可能是由於互聯網限制(即,它可以與不同的ISP一起工作)。這是我看到我需要處理的情況。 – Yohannes

回答

2

我猜測目前您無法從應用程序內的代碼中檢查Firebase是否可用。不過,您可以通過檢查Firebase狀態信息中心來檢查Firebase本身是否正常工作。

在此站點中,您還可以找到過去Firebase服務不可用或不穩定的日期。

希望它有助於某種方式。

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

0

你應該檢查,如果谷歌Play業務是提供這樣的:

/** 
* 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; 
} 

你需要下面的行添加到您的build.gradle也。

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

相關問題