Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Firebase Remote Configでアプリのアップデート促進を実装する

Firebase Remote Configでアプリのアップデート促進を実装する

operandoOS

June 23, 2017
Tweet

More Decks by operandoOS

Other Decks in Technology

Transcript

  1. Firebase Remote Config? Change the behavior and appearance of your

    app without publishing an app update. https://firebase.google.com/docs/remote-config/
  2. Remote Configͷ஋ʹ͸
 ͲΕ͘Β͍ͷจࣈྻ͕ೖΔͷʁ The total length of parameter value strings

    within a project cannot exceed 500,000 characters. https://firebase.google.com/docs/remote-config/ parameters#limits_on_parameters_and_conditions
  3. ࣮૷͸ΘΓͱ؆୯ • Remote ConfigΛॳظԽ • Remote Config Serverͷ஋ΛfetchͰऔಘͯ͠ߋ৽ • Ξοϓσʔτଅਐͷ஋Λࢦఆͨ͠Key໊Ͱ಺༰Λऔಘ

    • Remote Config͔Βऔಘͨ͠஋ͷνΣοΫ • ஋ΛνΣοΫͯ͠ɺΞοϓσʔτଅਐΛग़͢ඞཁ͕͋Δͱ ൑அͨ͠Βग़͢
  4. public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle

    savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RemoteConfig.init(this); RemoteConfig.updateConfig(this, task -> { RemoteConfig.getUpdateNoticeConfig(this) .filter(value -> !TextUtils.isEmpty(value)) .flatMap(UpdateNotice::parseJson) .filter(value -> getSharedPreferences("update_notice", Context.MODE_PRIVATE).getInt("showed_update_notice_version", 0) < value.updateApplicationVersion) .filter(value -> BuildConfig.VERSION_CODE < value.updateApplicationVersion) .ifPresent(this::showUpdateDialog); }); } private void showUpdateDialog(UpdateNotice updateNotice) { new AlertDialog.Builder(this) .setTitle(updateNotice.updateTitle) .setMessage(updateNotice.updateMessage) .setPositiveButton("Ξοϓσʔτ͢Δ", (dialogInterface, i) -> { IntentUtil.openGooglePlayAppDetails(this, getPackageName()); }) .setNegativeButton("ด͡Δ", (dialogInterface, i) -> { }) .show(); getSharedPreferences("update_notice", Context.MODE_PRIVATE) .edit() .putInt("showed_update_notice_version", updateNotice.updateApplicationVersion) .apply(); } }
  5. Remote Config͔Βऔಘͨ͠
 ஋ͷνΣοΫ RemoteConfig.updateConfig(this, task -> { RemoteConfig.getUpdateNoticeConfig(this) .filter(value ->

    !TextUtils.isEmpty(value)) .flatMap(UpdateNotice::parseJson) .filter(v -> BuildConfig.VERSION_CODE < v.updateApplicationVersion); });
  6. ஋ΛνΣοΫͯ͠ɺΞοϓσʔτଅਐ Λग़͢ඞཁ͕͋Δͱ൑அͨ͠Βग़͢ RemoteConfig.updateConfig(this, task -> { RemoteConfig.getUpdateNoticeConfig(this) .filter(value -> !TextUtils.isEmpty(value))

    .flatMap(UpdateNotice::parseJson) .filter(v -> BuildConfig.VERSION_CODE < v.updateApplicationVersion) .ifPresent(this::showUpdateDialog); });
  7. ΞοϓσʔτଅਐͷμΠΞϩάදࣔ private void showUpdateDialog(UpdateNotice updateNotice) { new AlertDialog.Builder(this) .setTitle(updateNotice.updateTitle) .setMessage(updateNotice.updateMessage)

    .setPositiveButton("Ξοϓσʔτ͢Δ", (dialogInterface, i) -> { IntentUtil.openGooglePlayAppDetails(this, getPackageName()); }) .setNegativeButton("ด͡Δ", (dialogInterface, i) -> { }) .show(); }