android - Firebase:如何确保与各种版本的 Google Play 服务兼容?

标签 android firebase firebase-cloud-messaging

我想在我的 Android 应用程序中加入消息传递/推送通知,并且由于 FCM 是推荐的最新版本,我刚刚检查了 Firebase 先决条件,它说,

Prerequisites

  • A device running Android 4.0 (Ice Cream Sandwich) or newer, and Google Play services 10.2.0 or higher

  • The Google Play services SDK from the Google Repository, available in the Android SDK Manager

  • The latest version of Android Studio, version 1.5 or higher

但是,并非所有运行 ICS 的设备都具有 >= 10.2.0 的 Google Play 服务。事实上,这是它的最新版本。因此,如果我决定使用 FCM,所有播放服务 <= 10.2.0 的设备都将超出我的范围。如果那时我决定降低版本,Firebase 似乎不支持任何版本。

我想使用 Firebase 和 Google Play 服务的最新功能,并扩展我对运行 Google Play 服务 >= 9.0.0 的设备的支持。

这似乎是任何图书馆的基本问题。 Android 提供支持库来缓解这种情况。

支持所有这些 Play 服务版本的推荐方法是什么?

最佳答案

只需放置跳棋,让用户更新到最新的 Google Play 服务。来自docs :

Apps that rely on the Play Services SDK should always check the device for a compatible Google Play services APK before accessing Google Play services features. It is recommended to do this in two places: in the main activity's onCreate() method, and in its onResume() method. The check in onCreate() ensures that the app can't be used without a successful check. The check in onResume() ensures that if the user returns to the running app through some other means, such as through the back button, the check is still performed.

If the device doesn't have a compatible version of Google Play services, your app can call GoogleApiAvailability.makeGooglePlayServicesAvailable() to allow users to download Google Play services from the Play Store.

关于android - Firebase:如何确保与各种版本的 Google Play 服务兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42848522/

相关文章:

firebase - Chrome 扩展程序如何在用户无需登录两次的情况下从 Firebase 网络应用程序获取用户凭据?

android - FirebaseInstanceIdService 不会被调用

ios - firebase_messaging 版本 3.0.0 无法使用 IOS 构建

android - 无法在 Google 日历中插入多个事件

java - 计算子弹速度

android - 如何访问内置的自动拒绝列表

android - LauncherActivity的使用

firebase - 使用 Firebase OpenID Connect 提供程序作为 Azure Function App 身份提供程序

ios - 我需要在收到通知后使用 Firebase 调用 API(应用程序处于打开状态、后台状态、事件状态)

android - 防止第三方库获取我的推送通知