RemoteConfig

RemoteConfig is an Android library that lets you manage all your remote configuration without requiring developers to manually download each configuration and integrate them into the application.

License

License

Categories

Categories

config Application Layer Libs Configuration
GroupId

GroupId

me.giacoppo
ArtifactId

ArtifactId

remoteconfig
Last Version

Last Version

1.1.5
Release Date

Release Date

Type

Type

aar
Description

Description

RemoteConfig
RemoteConfig is an Android library that lets you manage all your remote configuration without requiring developers to manually download each configuration and integrate them into the application.
Project URL

Project URL

https://github.com/GiuseppeGiacoppo/RemoteConfig
Source Code Management

Source Code Management

https://github.com/GiuseppeGiacoppo/RemoteConfig

Download remoteconfig

How to add to project

<!-- https://jarcasting.com/artifacts/me.giacoppo/remoteconfig/ -->
<dependency>
    <groupId>me.giacoppo</groupId>
    <artifactId>remoteconfig</artifactId>
    <version>1.1.5</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/me.giacoppo/remoteconfig/
implementation 'me.giacoppo:remoteconfig:1.1.5'
// https://jarcasting.com/artifacts/me.giacoppo/remoteconfig/
implementation ("me.giacoppo:remoteconfig:1.1.5")
'me.giacoppo:remoteconfig:aar:1.1.5'
<dependency org="me.giacoppo" name="remoteconfig" rev="1.1.5">
  <artifact name="remoteconfig" type="aar" />
</dependency>
@Grapes(
@Grab(group='me.giacoppo', module='remoteconfig', version='1.1.5')
)
libraryDependencies += "me.giacoppo" % "remoteconfig" % "1.1.5"
[me.giacoppo/remoteconfig "1.1.5"]

Dependencies

runtime (5)

Group / Artifact Type Version
com.android.support » appcompat-v7 jar 27.1.1
com.google.code.gson : gson jar 2.8.4
com.squareup.okhttp3 : okhttp jar 3.10.0
io.reactivex.rxjava2 : rxjava jar 2.1.13
io.reactivex.rxjava2 : rxandroid jar 2.0.2

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Introduction

RemoteConfig is a Kotlin library that lets you manage all your remote configuration without requiring developers to manually download each configuration and integrate them into the Kotlin application.

Library Architecture

You can have many configurations (messages, flags, server) on remote files, the library will do all the work for you.

Multiple Configurations

Download

Grab via Gradle:

repositories {
    maven { url 'https://jitpack.io' }
}
dependencies {
    implementation 'com.github.GiuseppeGiacoppo:RemoteConfig:LATEST_VERSION'
}

Usage

Retrieve a specific instance of RemoteResource for every configuration class

fun welcome() {
    val remoteAppConfig = remoteConfig<AppConfig>()
    val appConfig = remoteAppConfig.get()
    println(appConfig.welcomeMessage)
}

You're done. remoteAppConfig will provide you the latest app configuration.

Setup library

You need to setup each remote configuration with minimum effort. For each configuration, specify a remote repository and a local repository. The library will know where to fetch the configuration and where to store it locally.

fun main(args: Array<String>) {
    initRemoteConfig {
        remoteResource<AppConfig>(
            storage("./configs"),
            network("https://www.your.server/latest/appconfig.json")
        )

        remoteResource<MessagesConfig>(
            // init other configs
        )
    }
}

Default configuration

Fetching is an async operation, this means it can take a while, and it can fail. It is possible to set a default configuration that will be marked as active if no more recent config is available.

val remoteAppConfig = remoteConfig<AppConfig>()
remoteAppConfig.setDefaultConfig(AppConfig("This is the default welcome message."))

Fetch from the server

Fetch the configuration every time you need, invoking fetch method. Fresh configuration will be saved locally and you can activate it.

remoteAppConfig.fetch({
    println("Fetch is successful")
    remoteAppConfig.activateFetched()
}, {
    println("Fetch is failed")
    it.printStackTrace()
})

Multiple configurations

The configuration will be named by the configuration class name. You can have multiple configurations that share the same class by specifying a custom resource name

fun main(args: Array<String>) {
    initRemoteConfig {
        remoteResource<MessagesConfig>(
            storage("./configs"),
            network("https://www.your.server/latest/homemessages.json")
        ) {
            resourceName = "home-messages"
        }

        remoteResource<MessagesConfig>(
            storage("./configs"),
            network("https://www.your.server/latest/detailmessages.json")
        ) {
            resourceName = "detail-messages"
        }
    }
    
    // you can then fetch, activate and use it
    val homeMessages = remoteConfig<MessagesConfig>("home-messages")
    val detailMessages = remoteConfig<MessagesConfig>("detail-messages")
}

Configuration Format

RemoteConfig expects that each configuration is in json format. It supports also text format, and you can even create your own ResourceMapper.

fun main(args: Array<String>) {
    initRemoteConfig {
        remoteResource<String>(
            storage("./configs"),
            network("https://www.your.server/latest/custom.txt")
        ) {
            format = TextResourceMapper
        }
    }
}

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Added some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :)

Credits and libraries

RemoteConfig is an open source library inspired by Firebase Remote Config

Versions

Version
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.3
1.0.2
1.0.1
1.0.0