{"id":1464,"date":"2021-09-13T16:28:23","date_gmt":"2021-09-13T08:28:23","guid":{"rendered":"https:\/\/badgameshow.com\/fly\/?p=1464"},"modified":"2021-09-14T10:42:25","modified_gmt":"2021-09-14T02:42:25","slug":"android-firebase-remote-config","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/fly\/android-firebase-remote-config\/","title":{"rendered":"Android Firebase Remote Config"},"content":{"rendered":"<h1>Firebase Remote Config \u9060\u7aef\u914d\u7f6e<\/h1>\n<h5>Firebase\u9060\u7aef\u914d\u7f6e\u5c31\u662f\u5728Firebase\u5f8c\u81fa\u5132\u5b58\u4e00\u4e9b\u9375\u503c\u5c0d\uff0c\u7136\u5f8c\u5728app\u5167\u5411Firebase\u8acb\u6c42\u4e26\u4f7f\u7528\u9019\u4e9b\u9375\u503c\u5c0d\u3002\u7576\u6211\u5011\u9700\u8981\u66f4\u6539\u9019\u4e9b\u9375\u503c\u5c0d\u6642\uff0c\u5c31\u5728Firebase\u5f8c\u81fa\u66f4\u6539\uff0c\u7576app\u4e0b\u4e00\u6b21\u5411Firebase\u8acb\u6c42\u6642\uff0c\u7372\u53d6\u5230\u7684\u5c31\u662f\u6211\u5011\u66f4\u6539\u5f8c\u7684\u503c\u3002\u9019\u6a23\u5c31\u5be6\u73fe\u4e86\u52d5\u614b\u66f4\u65b0app\u914d\u7f6e<\/h5>\n<hr \/>\n<h4>\u6587\u7ae0\u76ee\u9304<\/h4>\n<ol>\n<li><a href=\"#a\">Firebase\u8207\u5c08\u6848\u9023\u7d50<\/a><\/li>\n<li><a href=\"#b\">\u9ede\u64caCloud Firestore\u5c07library\u8207google-services.json\u5c0e\u5165\u9032\u5c08\u6848<\/a><\/li>\n<li><a href=\"#c\">Firebase console\u5efa\u7acb\u8a2d\u5b9a\u4f60\u8981\u7684key&#038;value<\/a><\/li>\n<li><a href=\"#d\">\u4f7f\u7528\u61c9\u7528\u7a0b\u5f0f\u5167\u9810\u8a2d\u503c \u9700\u8981\u900f\u904exml\u53bb\u6dfb\u52a0<\/a><\/li>\n<li><a href=\"#e\">RemoteConfig\u8abf\u7528<\/a><\/li>\n<li><a href=\"#f\">\u4f7f\u7528\u9810\u8a2d\u8cc7\u6599<\/a><\/li>\n<li><a href=\"#g\">\u4f7f\u7528\u5f8c\u53f0\u66f4\u65b0\u7684\u8cc7\u6599<\/a><\/li>\n<li><a href=\"#h\">\u6548\u679c\u5c55\u793a<\/a><\/li>\n<\/ol>\n<hr \/>\n<p><a id=\"a\"><\/a><\/p>\n<h4>1.Firebase\u8207\u5c08\u6848\u9023\u7d50<\/h4>\n<p><a href=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2020\/03\/FCM1.png\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2020\/03\/FCM1.png\" width=\"30%\"\/><\/a><\/p>\n<p><a id=\"b\"><\/a><\/p>\n<h4>2.\u9ede\u64caCloud Firestore\u5c07library\u8207google-services.json\u5c0e\u5165\u9032\u5c08\u6848<\/h4>\n<p><a href=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/09\/1.png\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/09\/1.png\" width=\"60%\"\/><\/a><\/p>\n<p><a id=\"c\"><\/a><\/p>\n<h4>3.Firebase console\u5efa\u7acb\u8a2d\u5b9a\u4f60\u8981\u7684key&amp;value<\/h4>\n<h4>\u5efa\u7acb\u8a2d\u5b9a<\/h4>\n<p><a href=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/09\/2.png\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/09\/2.png\" width=\"70%\"\/><\/a><\/p>\n<h4>\u5132\u5b58<\/h4>\n<p><a href=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/09\/3.png\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/09\/3.png\" width=\"70%\"\/><\/a><\/p>\n<h4>\u767c\u5e03\u8b8a\u66f4<\/h4>\n<p><a href=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/09\/4.png\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/09\/4.png\" width=\"70%\"\/><\/a><\/p>\n<p><a id=\"d\"><\/a><\/p>\n<h4>4.\u4f7f\u7528\u61c9\u7528\u7a0b\u5f0f\u5167\u9810\u8a2d\u503c \u9700\u8981\u900f\u904exml\u53bb\u6dfb\u52a0<\/h4>\n<pre><code class=\"language-XML line-numbers\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n&lt;defaultsMap&gt;\n    &lt;entry&gt;\n        &lt;key&gt;title&lt;\/key&gt;\n        &lt;value&gt;Remote Config&lt;\/value&gt;\n    &lt;\/entry&gt;\n    &lt;entry&gt;\n        &lt;key&gt;message&lt;\/key&gt;\n        &lt;value&gt;Remote Config Message&lt;\/value&gt;\n    &lt;\/entry&gt;\n&lt;\/defaultsMap&gt;\n<\/code><\/pre>\n<p><a id=\"e\"><\/a><\/p>\n<h4>5.RemoteConfig\u8abf\u7528<\/h4>\n<pre><code class=\"language-Kotlin line-numbers\">val message = findViewById&lt;TextView&gt;(R.id.message)\n\n\/\/\u53d6\u5f97RemoteConfig KTX\u7248\u672c\nval remoteConfig = Firebase.remoteConfig\n\nval configSettings = remoteConfigSettings {\n    \/\/\u6700\u5c0f\u7372\u53d6\u6642\u9593(\u79d2) \u4e0d\u8a2d\u7f6e\u53ea\u8981\u5f8c\u53f0\u66f4\u65b0\u5c31\u540c\u6b65\u8cc7\u6599\n    minimumFetchIntervalInSeconds = 10\n}\nremoteConfig.setConfigSettingsAsync(configSettings)\nremoteConfig.setDefaultsAsync(R.xml.remote_config_defaults)\n\n\n\/\/\u53d6\u5f97\u6539\u8b8a\u8cc7\u6599\nremoteConfig.fetchAndActivate()\n    .addOnCompleteListener { task -&gt;\n        if (task.isSuccessful) {\n            title = remoteConfig.getString(\"title\")\n            message.text = remoteConfig.getString(\"message\")\n        }\n    }\n<\/code><\/pre>\n<p><a id=\"f\"><\/a><\/p>\n<h4>6.\u4f7f\u7528\u9810\u8a2d\u8cc7\u6599<\/h4>\n<p><a href=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/09\/6.png\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/09\/6.png\" width=\"100%\"\/><\/a><\/p>\n<p><a id=\"g\"><\/a><\/p>\n<h4>7.\u4f7f\u7528\u5f8c\u53f0\u66f4\u65b0\u7684\u8cc7\u6599<\/h4>\n<p><a href=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/09\/5.png\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/09\/5.png\" width=\"100%\"\/><\/a><\/p>\n<p><a id=\"h\"><\/a><\/p>\n<h4>8.\u6548\u679c\u5c55\u793a<\/h4>\n<p><a href=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/09\/video-1631520907.gif\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/09\/video-1631520907.gif\" width=\"40%\"\/><\/a><\/p>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>Firebase Remote Config \u9060\u7aef\u914d\u7f6e Firebase\u9060\u7aef\u914d\u7f6e\u5c31\u662f\u5728Firebase\u5f8c\u81fa\u5132\u5b58 &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[34],"tags":[13,40,199],"class_list":["post-1464","post","type-post","status-publish","format-standard","hentry","category-firebase","tag-android","tag-firebase","tag-remote-config"],"_links":{"self":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/1464","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/comments?post=1464"}],"version-history":[{"count":2,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/1464\/revisions"}],"predecessor-version":[{"id":1482,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/1464\/revisions\/1482"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/media?parent=1464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/categories?post=1464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/tags?post=1464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}