Last active
September 26, 2019 14:10
-
-
Save DaisukeNagata/974425a333e5592f344490585734cff7 to your computer and use it in GitHub Desktop.
Fire Base ABTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.firebase.remoteconfig.FirebaseRemoteConfig | |
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings | |
class MainActivity : AppCompatActivity() { | |
private lateinit var remoteConfig: FirebaseRemoteConfig | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
remoteConfig = FirebaseRemoteConfig.getInstance() | |
val configSettings = FirebaseRemoteConfigSettings.Builder() | |
remoteConfig.setConfigSettingsAsync( | |
configSettings.setMinimumFetchIntervalInSeconds(3600L) | |
.build()) | |
remoteConfig.setDefaultsAsync(R.xml.remote_config_defaults) | |
remoteConfig.fetchAndActivate() | |
.addOnCompleteListener(this) { task -> | |
if (task.isSuccessful) { | |
val updated = task.getResult() | |
print(updated) | |
} | |
displayWelcomeMessage() | |
} | |
} | |
private fun displayWelcomeMessage() { | |
val welcomeMessage = remoteConfig.getString(WELCOME_MESSAGE_KEY) | |
print(welcomeMessage) | |
myTextView.text = welcomeMessage | |
} | |
companion object { | |
// Remote Config keys | |
private const val WELCOME_MESSAGE_KEY = "my_custom_event" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
参考リンク
https://firebase.google.com/docs/remote-config/android?hl=ja
https://stackoverflow.com/questions/56233622/setconfigsettingsfirebaseremoteconfigsettings-unit-is-deprecated