Play Install Referrer API
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
這份文件提供有關使用 Play Install Referrer API 的技術參考資料。Play Install Referrer API 是一種 AIDL 服務介面,主要供非 Java 程式設計師使用。
注意:Play Install Referrer 程式庫提供 Play Install Referrer API 的包裝函式,旨在協助 Java 程式設計師使用這個 API。
getInstallReferrer() 方法
這個方法傳回與透過 Bundle
(表 1 中對應的金鑰) 傳送的指定套件名稱相對應的應用程式安裝參照資訊。在 Google Play 傳送的 Bundle
回應中,參照資訊儲存在與表 2 所述的金鑰對應的欄位中。
表 1. getInstallReferrer()
bundle 資料要求。
參數
|
類型
|
說明
|
package_name
|
String
|
呼叫端的套件名稱,用於去除混淆。
|
表 2. 來自 getInstallReferrer()
要求的回應資料。
金鑰
|
類型 |
說明
|
install_referrer
|
String
|
已安裝套件的參照網址。
|
referrer_click_timestamp_seconds
|
long
|
參照網址點選事件發生時的用戶端時間戳記 (以秒為單位)。
|
install_begin_timestamp_seconds
|
long
|
應用程式安裝開始時的用戶端時間戳記 (以秒為單位)。
|
referrer_click_timestamp_server_seconds
|
long
|
參照網址點選事件發生時的伺服器端時間戳記 (以秒為單位)。
|
install_begin_timestamp_server_seconds
|
long
|
應用程式安裝開始時的伺服器端時間戳記 (以秒為單位)。
|
install_version
|
string
|
首次安裝應用程式時的應用程式版本。
|
google_play_instant
|
boolean
|
指出應用程式免安裝體驗是否在過去 7 天內推出。
|
注意:安裝參照資訊的有效期為 90 天,而且除非使用者重新安裝應用程式,否則不會發生變化。為避免應用程式中發出不必要的 API 呼叫,在安裝完成後首次執行期間,應僅叫用 API 一次。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Play Install Referrer API\n\nThis documentation provides technical reference for using the\nPlay Install Referrer API. The Play Install Referrer API is an\n[AIDL Service Interface](https://developer.android.com/guide/components/aidl.html)\nprimarily used by non-Java programmers.\n\n\n**Note:** The\n[Play Install Referrer Library](/google/play/installreferrer/library)\nprovides a wrapper around the Play Install Referrer API and is designed to help Java\nprogrammers use the API.\n\nThe getInstallReferrer() method\n-------------------------------\n\nThis method returns the app install referrer information corresponding to the\ngiven package name sent through a `Bundle` (key mapped in table 1). In the\nresponse `Bundle` sent by Google Play, the referral information is stored in\nfields mapped to the keys detailed in table 2.\n\n\n**Table 1.** `getInstallReferrer()` bundle data\nrequest.\n\n| Parameter | Type | Description |\n|----------------|----------|----------------------------------------------------------|\n| `package_name` | `String` | The package name of the caller, used for disambiguation. |\n\n\n**Table 2.** Response data from a `getInstallReferrer()`\nrequest.\n\n| Key | Type | Description |\n|-------------------------------------------|-----------|--------------------------------------------------------------------------------------|\n| `install_referrer` | `String` | The referrer URL of the installed package. |\n| `referrer_click_timestamp_seconds` | `long` | The client-side timestamp, in seconds, when the referrer click happened. |\n| `install_begin_timestamp_seconds` | `long` | The client-side timestamp, in seconds, when app installation began. |\n| `referrer_click_timestamp_server_seconds` | `long` | The server-side timestamp, in seconds, when the referrer click happened. |\n| `install_begin_timestamp_server_seconds` | `long` | The server-side timestamp, in seconds, when app installation began. |\n| `install_version` | `string` | The app's version at the time when the app was first installed. |\n| `google_play_instant` | `boolean` | Indicates whether your app's instant experience was launched within the past 7 days. |\n\n**Caution:** The install referrer information will be\navailable for 90 days and **won't change** unless the application is\nreinstalled. To avoid unnecessary API calls in your app, you should invoke the\nAPI **only once** during the first execution after install."]]