BazaarUpdater is an Android library that simplifies checking for updates and managing the update process for your application on Bazaar.
To get started with BazaarUpdater, you need to add the JitPack repository to your project and include the library dependency.
Kotlin DSL
repositories {
maven { url = uri("https://jitpack.io") }
}
groovy
repositories {
maven { url 'https://jitpack.io' }
}
Kotlin DSL
dependencies {
implementation("com.github.cafebazaar:bazaarUpdater:1.0.0-beta3")
}
groovy
dependencies {
implementation 'com.github.cafebazaar:bazaarUpdater:1.0.0-beta3'
}
To check if there are any updates available for your application on Bazaar, use the following code:
BazaarUpdater.getLastUpdateState(context = context) { result ->
when(result) {
UpdateResult.AlreadyUpdated -> {
// Handle the case where the app is already updated
}
is UpdateResult.Error -> {
// Handle the error case
val errorMessage = result.getError()?.message
}
is UpdateResult.NeedUpdate -> {
// Handle the case where an update is needed
val targetVersion = result.getTargetVersionCode()
}
}
}
Java Usage
BazaarUpdater.getLastUpdateState(context, result -> {
if (result.isAlreadyUpdated()) {
// Handle the case where the app is already updated
} else if (result.isUpdateNeeded()) {
// Handle the case where an update is needed
long targetVersion = result.getTargetVersionCode();
} else {
// Handle the error case
String errorMessage = result.getError().getMessage();
}
});
3. NeedUpdate: Indicates that a new update is available. Use result.getTargetVersionCode()
to get the version code of the update.
To update your application when a new version is available on Bazaar, simply call:
BazaarUpdater.updateApplication(context = context)
Contributions are welcome! If you have suggestions or improvements, please open an issue or submit a pull request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Made with 💚 in Bazaar Hackathon 1403