A Jetpack Compose implementation for managing in-app updates in Android applications. This library makes it easy to integrate Google Play's in-app update API with your Compose UI, providing both ready-to-use UI components and flexible state management.
- π Automatic update checking with Google Play
- π¨ Material Design UI components for update flows
- π§ Configurable update priorities and prompt intervals
- π Silent update option for minimal UI intervention
- ποΈ Custom UI state management support
- π₯ Multiple implementation approaches to fit your needs
- Android API level 21+ (Android 5.0 Lollipop and higher)
- Jetpack Compose
- App published on Google Play Store
The library is available via MavenCentral:
allprojects {
repositories {
// ...
mavenCentral()
}
}
Snapshots of the development version are available in Sonatype's snapshots repository.
allprojects {
repositories {
// ...
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
}This library consists of two main libraries:
Basic functionality without any default UI:
dependencies {
implementation("se.warting.in-app-update:in-app-update-compose:<latest_version>")
}
Implementation with Material Design components:
dependencies {
implementation("se.warting.in-app-update:in-app-update-compose-mui:<latest_version>")
}
The simplest way is to use the Material UI implementation with MaterialRequireLatestVersion. This component provides a complete Material Design UI for handling all update states:
@Composable
fun MainView() {
MaterialRequireLatestVersion {
// Your app content goes here
Welcome()
}
}When using MaterialRequireLatestVersion:
- A loading indicator appears when checking for updates
- Required updates show a mandatory update screen until the user updates
- Download progress is displayed for required updates being downloaded
- Downloaded required updates show an install prompt
- Optional updates allow continued app usage with normal content
- Update errors show a dedicated error screen
The Material UI components come with translations for the following languages:
- English (en) - Default
- Afrikaans (af-ZA)
- Arabic (ar-SA)
- Catalan (ca-ES)
- Czech (cs-CZ)
- Danish (da-DK)
- Dutch (nl-NL)
- Finnish (fi-FI)
- French (fr-FR)
- German (de)
- Greek (el-GR)
- Hebrew (iw-IL)
- Hungarian (hu-HU)
- Italian (it-IT)
- Japanese (ja-JP)
- Korean (ko-KR)
- Norwegian (no-NO)
- Polish (pl-PL)
- Portuguese (Brazil) (pt-BR)
- Portuguese (Portugal) (pt-PT)
- Romanian (ro-RO)
- Russian (ru)
- Serbian (sr-SP)
- Spanish (es-ES)
- Swedish (sv-SE)
- Turkish (tr-TR)
- Ukrainian (uk-UA)
- Vietnamese (vi-VN)
- Chinese (Simplified) (zh-CN)
- Chinese (Traditional) (zh-TW)
If you need support for additional languages, please:
- Open an issue on GitHub describing the language you need
- Or submit a Pull Request with your translation
Translations are managed through Crowdin. You can contribute directly there as well.
For a full implementation example, see: Material UI sample
For more granular control, you can use the core module and create your own UI:
@Composable
fun InAppUpdate() {
val updateState = rememberInAppUpdateState()
when (updateState) {
InAppUpdateState.Loading -> Loading()
InAppUpdateState.NotAvailable -> NotAvailable()
is InAppUpdateState.RequiredUpdate -> RequiredUpdate(updateState)
is InAppUpdateState.OptionalUpdate -> OptionalUpdate(updateState)
is InAppUpdateState.InProgressUpdate -> InProgress(updateState)
is InAppUpdateState.DownloadedUpdate -> Downloaded(updateState)
is InAppUpdateState.Error -> Error(updateState)
}
}For a more complex implementation with different update modes, see: Custom Implementation
The rememberInAppUpdateState function is the core of this library's update functionality. It handles checking for updates, determining their priority, and managing the update flow:
@Composable
fun YourCustomImplementation() {
val updateState = rememberInAppUpdateState(
highPrioritizeUpdates = 4,
mediumPrioritizeUpdates = 2,
promptIntervalHighPrioritizeUpdateInDays = 1,
autoTriggerRequiredUpdates = true
)
// Use updateState to build your own UI and behavior
}Key features of rememberInAppUpdateState:
- Returns an
InAppUpdateStatethat represents the current update status - Automatically checks for available updates from Google Play
- Categorizes updates by priority (high, medium, low)
- Can be configured to automatically trigger required or optional updates
- Controls how frequently users are prompted about updates
- Provides actions for starting, completing, or declining updates
Both MaterialRequireLatestVersion and SilentUpdateHandler use this function internally, but you can also use it directly when you need complete control over your update UI and behavior.
The library categorizes updates into different priority levels:
- High Priority Updates - Critical updates like security patches
- Medium Priority Updates - Important feature updates
- Low Priority Updates - Minor enhancements and improvements
You can configure how these updates are handled:
rememberInAppUpdateState(
highPrioritizeUpdates = 4, // How many updates to consider high priority
mediumPrioritizeUpdates = 2, // How many updates to consider medium priority
promptIntervalHighPrioritizeUpdateInDays = 1, // How often to prompt for high priority
promptIntervalMediumPrioritizeUpdateInDays = 3, // How often to prompt for medium priority
promptIntervalLowPrioritizeUpdateInDays = 7 // How often to prompt for low priority
)The library supports various configurations:
MaterialRequireLatestVersion(
// Custom settings
highPrioritizeUpdates = 4,
mediumPrioritizeUpdates = 2,
promptIntervalHighPrioritizeUpdateInDays = 1,
promptIntervalMediumPrioritizeUpdateInDays = 1,
promptIntervalLowPrioritizeUpdateInDays = 7,
) {
// Your app content
}For applications that want updates to happen silently in the background with minimal UI intervention, use the SilentUpdateHandler:
SilentUpdateHandler(
errorContent = {
// Your custom error UI
},
content = {
// Your normal app content
}
)When using SilentUpdateHandler:
- Updates are checked for and processed automatically in the background
- Your regular content is shown during normal operation and for optional updates
- Required updates that are declined will cause the app to close
- No UI is shown during update loading or download processes
- Your error content is only shown if update checking fails
Note: The previous
NoUicomponent is deprecated and has been replaced bySilentUpdateHandler
This project is licensed under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.
