Firebase: How can I ensure compatibility with vari

2019-08-02 07:47发布

I want to incorporate messaging/Push notifications in my Android App and since FCM is the newest version recommended, I just checked the Firebase prerequisites and it says,

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

But, it isn't so that all the devices running ICS will have Google Play Services >= 10.2.0. Infact, this is the latest version of it. So, if I decide to go with FCM, all the devices having Play Services <= 10.2.0 will be out of my reach. If then I decide to bump the version down, Firebase doesn't seem to support any.

I want to use Firebase's and Google Play Services newest features and extend my support for devices running Google Play services >= 9.0.0.

This seems to be a fundamental problem with any library. Android provides Support library to mitigate this.

What is the recommended approach to support all these Play Services versions?

2条回答
干净又极端
2楼-- · 2019-08-02 08:44

Every device API 14 or higher (the new minimum SDK version as of 10.2.0) that has Google Play services is automatically upgraded to the latest version of Google Play services - in fact, a new version of the API only becomes available to developers when it is available on 100% of devices.

查看更多
放荡不羁爱自由
3楼-- · 2019-08-02 08:51

Just have the user update to the latest Google Play Services, by placing checkers. From the 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.

查看更多
登录 后发表回答