diff --git a/README.md b/README.md index 8752eee..979a47c 100644 --- a/README.md +++ b/README.md @@ -1 +1,53 @@ -# version-check-kotlin \ No newline at end of file +# Version Check + +A library for doing checking of supported versions for a network service + +Example basic usage: + +``` +class App: Application() { + + override fun onCreate() { + super.onCreate() + setupVersionCheck() + } + + private fun setupVersionCheck() { + val versionChecker = VersionCheck( + VersionCheckConfig( + appVersionName = BuildConfig.VERSION_NAME, + appVersionCode = BuildConfig.VERSION_CODE, + url = "https://myservice.com/api/version" // <-- Change this URL + ) + ) + + // If you wish the VersionCheck to be automatically ran on the Application's OnStart + // lifecycle call, add the following line: + ProcessLifecycleOwner.get().lifecycle.addObserver(versionChecker) + + // If you wish to use the default alert dialog, add the following 2 lines: + val upgradeDialog = DefaultUpgradeDialog(versionChecker.displayStateFlow) + registerActivityLifecycleCallbacks(upgradeDialog) + } +} +``` +If you wish to handle the call and results manually, you will need to call `versionCheck.runVersionCheck()` and collect from the StateFlows `statusFlow` and `displayStateFlow`. + +Expected JSON format: +``` +{ + "ios" : { + "minimumVersion": "1.1", + "blockedVersions": ["1.2.0", "1.2.1", "@301"], + "latestTestVersion": "1.4.2@400" + }, + "android" : { + "minimumVersion": "1.1", + "blockedVersions": ["1.2.0", "1.2.1", "@301"], + "latestTestVersion": "1.4.2@400" + }, + "serverForceVersionFailure": false, + "serverMaintenance": false +} + +``` diff --git a/app/src/main/java/com/steamclock/versioncheckkotlinsample/App.kt b/app/src/main/java/com/steamclock/versioncheckkotlinsample/App.kt index d0ac7d7..8940c92 100644 --- a/app/src/main/java/com/steamclock/versioncheckkotlinsample/App.kt +++ b/app/src/main/java/com/steamclock/versioncheckkotlinsample/App.kt @@ -11,7 +11,7 @@ import kotlinx.coroutines.* import java.net.URL import kotlin.random.Random -class App: Application(), LifecycleObserver { +class App: Application() { override fun onCreate() { super.onCreate()