gpt4 book ai didi

android - 如何检查 firebase 服务是否可用?

转载 作者:太空宇宙 更新时间:2023-11-03 12:29:18 26 4
gpt4 key购买 nike

如果应用程序在防火墙后面运行或者出现网络中断或某种审查制度,我们如何使用代码检查应用程序是否可以访问 firebase 系统?

最佳答案

您应该像这样检查 Google 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

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

关于android - 如何检查 firebase 服务是否可用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38374185/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com