自訂「歡迎回來」畫面
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
個人化內容既能滿足使用者需求,還能在
根據使用者的偏好設定、使用記錄
和語言代碼Firebase 可讓你根據
Google Analytics 個指標,並使用下列項目自訂應用程式:
Firebase Remote Config直接透過Firebase控制台使用。
同時使用這兩項功能,就能自訂應用程式的歡迎機制
根據使用者的偏好設定或在應用程式中活動,判斷他們是否使用適當螢幕。
本指南將逐步引導您建立
「歡迎回來」畫面上。
首先,您需要將 Android 應用程式連結至 Firebase 專案。如果
如果您沒有 Android 裝置,請參閱開始使用 Android
連結你的應用程式
導入程序總覽
應用程式的個人化歡迎畫麵包含以下 3 個主要步驟:
- 設定 Remote Config 來保留參數,
個人化。舉例來說,您可以將歡迎畫面訊息儲存為
參數。這樣一來,您不必重新發布應用程式就能更新訊息。
- 設定 Analytics 來定義目標對象和/或使用者屬性
Remote Config,指定您的使用者。這兩項功能都可用於
指定目標;不過兩者之間還是有重要的差異
本指南稍後將討論這兩種方法的相對優勢。
- 設定 Remote Config 條件,根據下列項目自訂參數自訂參數:
您設定的 Analytics 目標對像或使用者屬性。
在 Remote Config 中設定參數
找出要自訂的應用程式元素後,請使用
Remote Config 用於儲存參數。我們會探討打造個人化的歡迎體驗
畫面的其他部分
Firebase 控制台的功能
- 前往 Remote Config 參數
Firebase控制台中的「設定」頁面。如果
如果您從未在應用程式中設定 Remote Config,請按一下 [Add Your First]
參數。
填寫參數鍵和預設值。例如:welcome_message
和 Welcome to this sample app
。
遠端設定參數設定。">
按一下「發布變更」。
可在 Android 應用程式中執行的操作
新增程式碼,以讀取並顯示您剛才新增至應用程式的參數:
Firebase 控制台。例如:
final FirebaseRemoteConfig config = FirebaseRemoteConfig.getInstance();
config.getInstance.fetch(CACHE_EXPIRATION_MS)
.addOnCompleteListener(this, new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
config.activateFetched();
String welcomeMessage = config.getString("welcome_message");
}
}
});
或是按照
在 Android 上使用 Firebase Remote Config
讀取並顯示您在控制台中建立的參數。如果
請參閱 Android 逐步操作說明,
實際操作範例應用程式的實作方式。
開啟
開發人員模式
即可在測試期間立即查看設定變更。
測試是否能正常運作
- 開啟應用程式,確認應用程式會顯示參數目前的值
Remote Config UI。
- 在控制台中變更值,然後按一下「發布變更」
- 重新啟動應用程式。畫面上應該會顯示新的參數值。
設定 Analytics 個目標對像或使用者屬性
在這個步驟中,您將使用 Analytics 定義應該會看到哪些使用者
個人化內容在本逐步操作說明中,我們將透過使用者屬性來完成這項操作
但您也可以定義
觀眾:
這些做法類似,但請注意,新增使用者後
就無法退出或移除,如果您想使用的屬性
指定目標可能會變動,請改用使用者屬性。
Firebase 控制台的功能
- 前往 Analytics 使用者屬性
Firebase控制台中的「設定」頁面。按一下「新增使用者屬性」。
為使用者屬性提供名稱和說明。例如,假設您
根據使用者偏好狗還是貓
自訂應用程式
將其命名為 animal_preference
。
Analytics 使用者屬性設定。">
按一下「建立」。
可在 Android 應用程式中執行的操作
- 按照「設定使用者屬性」一節的步驟操作
,瞭解如何在應用程式中設定使用者屬性。舉例來說,
可能會詢問使用者偏好貓或狗,並設定字串值
。您可以略過在
您在上一節所述的步驟這麼做
- 按照偵錯事件中的步驟啟用
應用程式的偵錯模式
測試是否能正常運作
- 開啟應用程式,然後前往使用者屬性設定的位置。
- 開啟 Analytics DebugView 頁面
(在 Firebase 控制台中)。
- 檢查是否已設定任何使用者屬性 (可能有
可能要過幾分鐘才會顯示)。
您的應用程式現在已具備可設定的參數和使用者屬性
(或目標對象) 做為變數,您可以建立條件來提供個人化體驗
參數值
Firebase 控制台的功能
- 前往 Remote Config
(在 Firebase 控制台中)。
- 按一下參數即可編輯。
- 按一下「新增條件的值」。
- 選取「定義新條件」。
- 為條件命名。例如「Prefers cats」反映使用者
偏好設定。
在「套用條件」下方,選取「使用者屬性」 (若為「目標對像中的使用者」,
您在 Analytics中建立目標對象),然後選取參數,然後
定義條件關係與參數值。
遠端設定條件。">
按一下「建立條件」。
輸入反映新條件的值。舉例來說:歡迎訊息
代表「Prefers cats」主題可能是「喵!」
按一下 [Update] (更新),儲存您所做的變更。
按一下「發布變更」,即可為新的條件和值啟用
應用程式。
測試是否能正常運作
- 開啟應用程式,然後前往使用者屬性設定的位置。
- 開啟 Analytics DebugView 頁面
(在 Firebase 控制台中)。
- 檢查是否已設定任何使用者屬性 (可能有
可能要過幾分鐘才會顯示)。
- 重新啟動應用程式,並確認已設定個人化元素。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-09-06 (世界標準時間)。
[null,null,["上次更新時間:2025-09-06 (世界標準時間)。"],[],[],null,["Personalized content can delight your users and provide an experience from the\nvery first interaction with your app based on their preferences, usage history,\nand locale. Firebase allows you to define audiences based on\nGoogle Analytics metrics and customize your application with\nFirebase Remote Config directly from the Firebase console.\n\nUsing these two features together, you can customize your app's welcome back\nscreen for a repeat user based on their preferences or activity in your app.\n\nThis guide walks you through the process to create your own personalized\n\"welcome back\" screen on Android.\n\nTo get started, you'll need an Android app connected to a Firebase project. If\nyou don't already have one, see [Get started for Android](/docs/android/setup)\nto connect your app.\n\nImplementation overview\n\nImplementing your app's personalized welcome screen consists of 3 broad steps:\n\n1. **Set up Remote Config to hold parameters for the elements to be\n personalized.** For example, you might store the welcome screen message as a parameter. This way you can update the message without republishing your app.\n2. **Set up Analytics to define audiences and/or user properties for\n Remote Config to target your users.** Both features can be used for targeting; however, there are important differences between them. The relative advantages of each are discussed later in this guide.\n3. **Configure Remote Config conditions to customize your parameter based on\n the Analytics audiences or user properties you set up.**\n\nSet up parameters in Remote Config\n\nOnce you identify the elements of your app you want to customize, use\nRemote Config to store parameters. We'll explore personalizing the welcome\nscreen message in the rest of this guide.\n\nWhat to do in the Firebase console\n\n1. Go to the [Remote Config parameter](https://console.firebase.google.com/project/_/config) page in the Firebase console. If you've never configured Remote Config in your app, click **Add Your First\n Parameter**.\n2. Fill out a parameter key and default value. For example, `welcome_message`\n and `Welcome to this sample app`.\n\n Remote Config parameter configuration.\"\\\u003e\n3. Click **Publish Changes**.\n\nWhat to do in the Android app\n\n1. Add code to read and display the parameter you just added to your app in the\n Firebase console. For example:\n\n final FirebaseRemoteConfig config = FirebaseRemoteConfig.getInstance();\n config.getInstance.fetch(CACHE_EXPIRATION_MS)\n .addOnCompleteListener(this, new OnCompleteListener\u003cVoid\u003e() {\n @Override\n public void onComplete(@NonNull Task\u003cVoid\u003e task) {\n if (task.isSuccessful()) {\n config.activateFetched();\n\n String welcomeMessage = config.getString(\"welcome_message\");\n }\n }\n });\n\n You can also follow the steps in\n [Use Firebase Remote Config on Android](/docs/remote-config/get-started?platform=android)\n to read and display the parameter that you created in the console. If you get\n stuck, the [Android walkthrough](/docs/remote-config/android) guides you\n through the working sample app implementation.\n2. Turn on\n [developer mode](/docs/reference/android/com/google/firebase/remoteconfig/FirebaseRemoteConfigSettings.Builder#setDeveloperModeEnabled(boolean))\n to see config changes immediately while testing.\n\nTest that it works\n\n1. Open your app and make sure that it shows the current value of the parameter in the [Remote Config UI](https://console.firebase.google.com/project/_/config).\n2. Change the value in the console and click **Publish Changes**\n3. Restart your app. The new parameter value should be shown.\n\nSet up Analytics audiences or user properties\n\nIn this step you'll use Analytics to define the users who should see\npersonalized content. In this walkthrough, we'll use a user property to do this\nbut you could also define an\n[Audience](//support.google.com/firebase/answer/6317509?hl=en&ref_topic=6317489).\nThese approaches are similar, but you should be aware that once a user is added\nto an Audience, they cannot leave it or be removed. If the attribute you want to\nuse for targeting could change, use a user property instead.\n\nWhat to do in the Firebase console\n\n1. Go to the [Analytics user property](https://console.firebase.google.com/project/_/analytics/userproperty) page in the Firebase console. Click **New User Property**.\n2. Give the user property a name and description. For example, if you were\n customizing an app based on whether a user prefers dogs or cats, you might\n name it `animal_preference`.\n\n Analytics user property configuration.\"\\\u003e\n3. Click **Create**.\n\nWhat to do in the Android app\n\n1. Follow the steps in [Set User Properties](/docs/analytics/android/properties#set_user_properties) to learn to set your user property in your application. For example, you might ask a user if they prefer cats or dogs and set a string value accordingly. You can skip over the steps to register your property in the console as you've already done that in the previous section.\n2. Follow the steps in [Debugging Events](/docs/analytics/debugview) to enable debug mode for your app.\n\nTest that it works\n\n1. Open your app and navigate to where your user property is set.\n2. Open the [Analytics DebugView page](https://console.firebase.google.com/project/_/analytics/debugview) in the Firebase console.\n3. Look to see if any user properties have been set (there might be a few minutes of delay before anything shows up).\n\nConfigure Remote Config conditions\n\nNow that your app has parameters that can be configured, and user properties\n(or audiences) to use as variables, you can create conditions to personalize\nthe values of your parameters.\n\nWhat to do in the Firebase console\n\n1. Go to [Remote Config](https://console.firebase.google.com/project/_/config) in the Firebase console.\n2. Click your parameter to edit it.\n3. Click **Add value for condition**.\n4. Select **Define new condition**.\n5. Give your condition a name. For example, \"Prefers cats\" to reflect the user preference from earlier.\n6. Under **Applies if** , select **User property** (or **User in audience** if\n you created an Audience in Analytics), and select your parameter, and\n define a conditional relationship with your parameter values.\n\n Remote Config condition.\"\\\u003e\n7. Click **Create condition**.\n\n8. Enter a value to reflect the new condition. For example, the welcome message\n for \"Prefers cats\" could be \"Meow!\".\n\n9. Click **Update** to save your changes.\n\n10. Click **Publish Changes** to enable the new conditions and values in your\n app.\n\nTest that it works\n\n1. Open your app and navigate to where your user property is set.\n2. Open the [Analytics DebugView page](https://console.firebase.google.com/project/_/analytics/debugview) in the Firebase console.\n3. Look to see if any user properties have been set (there might be a few minutes of delay before anything shows up).\n4. Restart your app and verify that your personalized elements have been set."]]