
語言 🇹🇼 繁體中文
文件
快速開始
使用
Add Comment Widgets to Your React Native App
這是 FastComments 的官方 React Native 函式庫。
在您的 React Native 應用程式中嵌入即時留言、聊天和評論小工具。
儲存庫
即時展示 
要在本地查看針對公開 demo 租戶運行的所有元件和流程,請複製此倉庫並執行:
yarn bootstrap
cd example
yarn ios # or: yarn android, yarn web
展示的進入點是 example/src/ShowcaseApp.tsx — 一個單一的應用程式,呈現所有元件、主題和流程。
yarn web 目標使用 react-native-web + react-native-web-webview(會將 WebView 呈現為 iframe)。這對於在瀏覽器中快速進行視覺性冒煙測試很有用;僅限原生的 WebView API(例如 injectJavaScript 和 onShouldStartLoadWithRequest)在網頁上不會完全如預期運作。
考慮使用原生 SDK 
此函式庫使用一個 webview 來包裹 VanillaJS 函式庫。
FastComments 現在支援作為 fastcomments-react-native-sdk 一部分的完全原生實作。 如果您想要完全原生的實作,您可以考慮查看那裡。
使用 - 即時評論小工具 
與 fastcomments-react 相比,這個 API 有些不同。在原生(native)中,我們傳入一個遵循 此結構 的 config 物件。
import { FastCommentsCommentWidget } from 'fastcomments-react-native';
// ...
const myTenantId = 'demo'; // 您的 tenant id。可以從 https://fastcomments.com/auth/my-account/api-secret 取得
const myAppPageId = 'native-test'; // 您應用程式中討論串的 ID 或 URL。
const myAppPageUrl = 'https://example.com/external-page'; // 您可以選擇設定一個外部頁面的 URL
const myAppPageTitle = 'Example Title'; // ... 並且您可能想為此內容設定一個標題
const [config, setConfig] = useState({
tenantId: myTenantId,
urlId: myAppPageId,
url: myAppPageUrl,
pageTitle: myAppPageTitle
});
// 透過呼叫 setConfig(),我們可以做像是更換當前頁面或目前登入的使用者之類的操作
// 參見 example/src/App.tsx
return (
<FastCommentsCommentWidget config={config}/>
);
使用 - 即時聊天小工具 
import { FastCommentsLiveChatWidget } from 'fastcomments-react-native';
// ...
const myTenantId = 'demo'; // 您的租戶 ID。可以從 https://fastcomments.com/auth/my-account/api-secret 取得
const myAppPageId = 'native-test'; // 您應用中留言串的 ID 或 URL。
const myAppPageUrl = 'https://example.com/external-page'; // 您可以選擇為外部頁面設定 url
const myAppPageTitle = 'Example Title'; // …並且您可能會想為此內容設定標題
const config = {
tenantId: myTenantId,
urlId: myAppPageId,
url: myAppPageUrl,
pageTitle: myAppPageTitle
};
return (
<FastCommentsLiveChatWidget config={config}/>
);
使用 - 單一登入 (SSO) 
FastComments 使用 HMAC 來進行安全的 SSO。要使用,請讓您的後端建立 SSO 物件(sso 設定屬性)並將其傳遞給
評論元件。
您可以在這裡找到針對各種後端的範例: https://github.com/FastComments/fastcomments-code-examples/tree/master/sso
相依套件 (peer dependencies) 
fastcomments-react-native 需要 react-native-webview。因此,您應遵循 react-native-webview 的安裝步驟。
帳戶區域(注意:歐盟客戶)
如果您的帳戶位於歐盟,請在 widget 設定中將 region = 'eu' 設定。
否則,您不需要定義 region。
維護狀態 
這些元件是我們核心 VanillaJS 元件的包裝器。我們可以自動更新這些元件(修復錯誤、加入功能)而無需發布此套件,因此即使它可能暫時不會發布,也不代表 FastComments 沒有在積極開發中!歡迎查看 我們的部落格 以取得最新消息。破壞性 API 變更或新功能,絕不會在未對此庫進行版本升級的情況下被推送到底層核心函式庫。
需要幫助?
如果您在使用 React Native 函式庫時遇到任何問題或有任何疑問,請:
貢獻
歡迎貢獻!請造訪 GitHub 儲存庫 以取得貢獻指南。