從 Firebase 邀請遷移至採用自訂共用功能的 Dynamic Links
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Firebase Invites 提供在應用程式中接收Firebase Dynamic Links的機制,以及透過簡訊或電子郵件分享該連結的功能。我們開發 Firebase Invites,是為了協助您透過口碑行銷拓展應用程式使用者群,但隨著時間推移,我們發現您已找到更有效的方法,鼓勵使用者與朋友分享自己喜愛的應用程式,這已超出 Firebase Invites 目前的功能範圍。
我們也發現,雖然 Firebase Invites 的使用率下降,但許多人仍將 Firebase Dynamic Links 做為使用者對使用者分享解決方案的主要成分。因此,我們將加強投入資源,致力於讓 Firebase Dynamic Links 成為在應用程式中建構使用者對使用者分享功能的最佳方式。為配合這項轉變,我們已淘汰 Firebase Invites 功能,並將於 2020 年 1 月 24 日停止支援。
這是什麼意思?對我有哪些影響?
自 2020 年 1 月 24 日起,使用者將無法再傳送或接收 Firebase Invites,且在呼叫傳送及接收邀請連結時,邀請後端服務會開始傳回錯誤回應。目前的 SDK 包含錯誤處理機制,可確保這些伺服器回應的正常失敗案例,因此使用者可以繼續使用您的應用程式,不會發生當機情形,但我們建議您停止使用 Firebase Invites,改用 Firebase Dynamic Links 搭配自訂分享解決方案。
方法如下:
使用「Firebase Dynamic Links」建立邀請連結
首先,建立 Dynamic Link,讓使用者可以與好友分享。好消息是,您可能已熟悉這個步驟,因為這與設定 Firebase Invites 的方式類似。不過,您也可以在動態連結中加入特定參數,例如在連結中加入社群中繼資料,讓使用者透過社群網路分享應用程式時,自訂分享網址的外觀。
建構共用解決方案
接著,為使用者建構分享解決方案,讓他們能與好友分享該連結。您要在此建構的內容,取決於您想提供哪種分享功能來取代 Firebase Invites 中的舊功能,但對於大多數行動應用程式,您都可以善用平台內建的功能。
在 Android 裝置上,如要透過簡訊、電子郵件,以及其他熱門社群網路和訊息應用程式分享內容,只要使用動作設為 Intent.ACTION_SEND
的一般意圖,就能輕鬆達成。這項功能可讓您輕鬆將應用程式中的資料分享給使用者安裝的任何應用程式,只要該應用程式可以處理分享意圖即可。
類似下列範例的內容應該適用於此處 (建議您在自己的程式碼中使用常數字串資源):
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Here's a new lesson for" +
" learning more Miwok vocabulary:\n\n" + dynamicLink);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Let's Learn Miwok!");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent,
getResources().getText(R.string.send_to)));
如需完整範例和更多詳細資料,請參閱這份將簡單資料傳送至其他應用程式的指南。
上述程式碼片段會產生類似下方畫面所示的邀請流程:

如果是 iOS 開發人員,可以透過 UIActivityViewController
傳遞在資料中建立的連結,這個方法會提供類似下方畫面的分享流程:

在應用程式中接收 Dynamic Link
最後,在服務終止後,如要為應用程式提供使用者對使用者分享功能,最後一個步驟是在應用程式中接收 Dynamic Link。
Android 的程序維持不變,因此您不必在此處進行太多變更。唯一的差異在於,如果沒有 Firebase Invites,就不會有邀請 ID,因此如果應用程式發出該呼叫,您就必須移除呼叫,透過 FirebaseAppInvite invite = FirebaseAppInvite.getInvitation(data)
擷取邀請 ID。如要進一步瞭解這項功能,請參閱「在 Android 應用程式中接收動態連結」指南。
如果是 iOS,則需要從 FIRReceivedInvite 物件變更為 FIRDynamicLink 物件,兩者都包含類似的資料。詳情請參閱「在 iOS 應用程式中接收動態連結」指南。
Unity 開發人員可以運用多個開放原始碼程式庫和上述等效解決方案,遷移使用者對使用者分享功能。如需提供合適解決方案方面的協助,請參閱下方連結的支援資源。
Firebase Invites 是我們引以為傲的工具。
展望未來,我們很期待能進一步提升 Firebase Dynamic Links 的效能,讓您更靈活地控管如何鼓勵使用者邀請他人加入應用程式。如對設定 Firebase Dynamic Links 和自訂分享解決方案有任何疑問,請前往 StackOverflow 或任何其他支援論壇提問。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[],[],null,["\u003cbr /\u003e\n\n| Firebase Invites is deprecated. On **January 24th, 2020** , we will discontinue support for Firebase Invites. You will be able to use [Firebase Dynamic Links](/docs/dynamic-links) with a custom sharing solution.\n\nFirebase Invites provided both a mechanism for receiving\n[Firebase Dynamic Links](/docs/dynamic-links) in your app, as well as a\nfeature to share that link via SMS or email. We developed\nFirebase Invites to help you grow your app users through word of mouth,\nbut over time, we learned that you found better ways to encourage users to share\ntheir favorite apps with their friends, beyond what Firebase Invites does\ntoday.\n\nWe also saw that while usage of Firebase Invites dropped, many of you\nwere still using Firebase Dynamic Links as the key ingredient of your user-to-user\nsharing solution. So, we're strengthening our focus and increasing our effort to\nmake Firebase Dynamic Links the best way to build user-to-user sharing capabilities\ninto your app. As part of this shift, we have deprecated the\nFirebase Invites feature, and will discontinue support starting on\n**January 24th, 2020**.\n\nWhat does this mean and how does it impact me?\n\nStarting on January 24th, 2020, your users will no longer be able to send\nor receive Firebase Invites, and the invites backend service will start\nreturning error responses when making calls to send and receive an invite link.\nThe current SDKs include error handling to help ensure graceful failure cases\nfor these server responses, so your users will be able to continue using your\napp without crashing, but we recommend that you no longer use\nFirebase Invites, and switch to an alternative solution using\nFirebase Dynamic Links with a custom sharing solution.\n\nHere is how to do that!\n\nCreate invitation links with Firebase Dynamic Links\n\nFirst, [Create a Dynamic Link](/docs/dynamic-links/create-links) that your\nusers can share with their friends. The good news is that you're likely familiar\nwith this step already because it's similar to how you set up Firebase Invites.\nBut you can also add specific parameters to your Dynamic Link, such as\n[adding social metadata to your links](/docs/dynamic-links/link-previews) if\nyour users share your app via a social network to customize the appearance of\nthe URL that gets shared.\n\nBuild a sharing solution\n\nNext, build your sharing solution for your users to be able to share that link\nwith their friends. What you will want to build here will vary depending on how\nyou want to provide the sharing feature that will replace the previous one in\nFirebase Invites, but for most mobile apps you can take advantage of\nfeatures already built into the platform.\n\nFor Android, one simple solution that covers both SMS and email sharing, as well\nas other popular social network and messaging apps, is to use a generic intent\nwith an action set as `Intent.ACTION_SEND`. This\nprovides a convenient way to share data from your app to any app the user has\ninstalled that can handle a share intent.\n\nSomething similar to the following example should work here (recommending that\nyou use constant string resources in your own code): \n\n```css+lasso\nIntent sendIntent = new Intent();\nsendIntent.setAction(Intent.ACTION_SEND);\nsendIntent.putExtra(Intent.EXTRA_TEXT, \"Here's a new lesson for\" +\n \" learning more Miwok vocabulary:\\n\\n\" + dynamicLink);\nsendIntent.putExtra(Intent.EXTRA_SUBJECT, \"Let's Learn Miwok!\");\nsendIntent.setType(\"text/plain\");\nstartActivity(Intent.createChooser(sendIntent,\n getResources().getText(R.string.send_to)));\n```\n\nFor a fuller example and more details, check out this guide for [sending simple\ndata to other apps](https://developer.android.com/training/sharing/send).\n\nThe code snippet above will generate something like invitation flow shown in the\nscreens below:\n\nFor iOS developers, you can use a\n`UIActivityViewController`, passing in the link\ncreated as part of the data to the custom VC. This method would provide a\nsharing flow similar to the screens below:\n\nReceive a Dynamic Link in your app\n\nFinally, the last step to provide user-to-user sharing for your app after the\nsunset is in receiving a Dynamic Link in your app.\n\nFor Android, this process remains the same so you won't need to change much\nhere. The only difference is that without Firebase Invites, there will no\nlonger be an invitation ID, and so you would need to remove the call to extract\nthe invite ID via `FirebaseAppInvite invite = FirebaseAppInvite.getInvitation(data)`,\nif your app is making that call. For more details on this piece, please see the\nguide on [Receiving Dynamic Links in your Android app](/docs/dynamic-links/android/receive).\n\nFor iOS, this would require changing from the [FIRReceivedInvite](/docs/reference/ios/firebaseinvites/api/reference/Classes/FIRReceivedInvite)\nobject to the [FIRDynamicLink](/docs/reference/ios/firebasedynamiclinks/api/reference/Classes/FIRDynamicLink)\nobject, which both contain similar data. Please see the guide on\n[Receiving Dynamic Links in your iOS app](/docs/dynamic-links/ios/receive) for\nmore details.\n\nFor Unity developers, there are a number of open-source libraries and equivalent\nsolutions as those described above to migrate your user-to-user sharing\nfunctionality. If you need any assistance on providing a suitable solution,\nplease reach out to the support resources linked further below.\n\nFirebase Invites has been a great tool that we're proud to have built.\nAs we look towards the future, we're excited to double down on making\nFirebase Dynamic Links even better so you have more flexibility and control over how\nyou encourage users to invite others to your app. If you have any questions\nabout setting up your Firebase Dynamic Links and custom sharing solutions, please\nreach out on [StackOverflow](https://stackoverflow.com/questions/tagged/firebase-dynamic-links), or any of\nour [additional support forums](https://firebase.google.com/support/)."]]