Manage your application updates from remote source (API / Firebase).
UpdateCenter library notifies you when there are new updates for your app. It recognizes:
- necessary update
- unnecessary update
- notification about new version available
Library uses VersionDataSource
interface that provides necessary values for OnVersionCheckedListener
. You can implement your own VersionDataSource
which provides values from any API / XML / ...
UpdateCenter has implementation of FirebaseVersionDataSource
that provides values from Firebase Remote Config (How to setup).
Add the jitpack.io repository:
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
and:
dependencies {
implementation 'com.github.unitedclassifiedsapps:updatecenter.android:${updateCenterVersion}'
}
Setup your app with Firebase as shown here
Add Firebase remote config dependency:
implementation 'com.google.firebase:firebase-config'
Via Firebase console define following parameters:
key:update_center_must_update value:[true/false]
key:update_center_should_update value:[true/false]
key:update_center_latest_version value:[semantic version string ex.: 1.2.3]
By setting up Remote Config Conditions you can control which app version gets what value (e.g. version 1.0.0
gets update_center_must_update
as true
but version 2.0.0
gets its value as false
).
Show in sample app
Simply initialize UpdateCenter with provided FirebaseVersionDataSource:
val updateCenter = UpdateCenter(FirebaseVersionDataSource(context, FirebaseRemoteConfig.getInstance(), BuildConfig.VERSION_NAME), object : OnVersionCheckedListener {
override fun mustUpdate(currentVersion: String, latestVersion: String) {
//startMustUpdateActivity()
}
override fun shouldUpdate(currentVersion: String, latestVersion: String) {
//startShouldUpdateActivity()
}
override fun notLatestVersion(currentVersion: String, latestVersion: String) {
//showNewVersionSnack()
}
override fun onError(currentVersion: String, exception: Exception?) {
//log error
}
})
and call check() method
updateCenter.check()
Based on your Firebase remote config configuration the appropriate OnVersionCheckedListener callback will be invoked.
- Minimum Android SDK: UpdateCenter requires a minimum API level of 16.