錢包(Apple 和 Google)
直接向Apple Wallet或Google Wallet發放品牌會員卡-在伺服器端簽名,無需應用程式。 Apple卡片會在會員積分或等級變更時自動更新。
簽發 兩個平台 以及全部 Apple PassKit 更新 Web 服務 今天就活在程式碼裡他們需要你的錢包憑證(Apple 通行證類型:ID + 簽署證書; Google 發行者 + 服務帳戶)已由 SocialHub 團隊配置。
您將獲得什麼
伺服器端發行即時
簽署的 .pkpass 在伺服器端產生並串流傳輸給會員 - 您的應用程式中沒有本機通行證簽署程式碼,也沒有應用程式版本來更改卡片設計。
自動卡更新即時
積分或等級變更 → 靜默推播 APNs 更新 → 裝置重新取得通行證。會員卡無需任何應用程式碼即可保持有效。
清潔生命週期即時
已移除成員的通行證序號返回 410 Gone,因此 Wallet 會優雅地刪除該過期卡。一個定時任務會監控您的簽名憑證的到期時間。
Apple + Google即時
兩個平台目前都從同一個端點發布:Apple 傳回已簽署的 .pkpass;Google 返回保存連結。 (Apple PassKit 提供靜默自動更新;Google 卡片在開啟時刷新。)
發行卡片 即時
從已登入成員的 WebView 中呼叫此函數-有關會話流程,請參閱《成員入口網站嵌入》指南。
// The signed-in member's app requests their card. teamId + memberId come from the
// consumer SESSION (never the body) — the body only selects the platform.
POST https://flash.socialhub.ai/api/consumer/wallet/issue
Content-Type: application/json
{ "platform": "apple" } // "apple" | "google"
// Apple → 200 Content-Type: application/vnd.apple.pkpass
// Content-Disposition: attachment; filename="loyalty-<serial>.pkpass"
// (the response body IS the signed .pkpass — hand it to "Add to Apple Wallet")
// Google → 200 { "saveUrl": "https://pay.google.com/gp/v/save/…" }
// (redirect the member to saveUrl → "Save to Google Wallet")
//
// Wallet not configured for that platform → DomainError WALLET_NOT_CONFIGURED.更新會自動進行。 即時
// You do NOT write update code. SocialHub hosts the standard Apple PassKit update
// web service, so the card stays current on its own:
//
// 1. The pass registers the device when added to Wallet
// POST /api/wallet/apple/v1/devices/{deviceId}/registrations/{passTypeId}/{serial}
// 2. A points / tier change enqueues a silent APNs push to the device
// 3. The device re-fetches the latest pass
// GET /api/wallet/apple/v1/passes/{passTypeId}/{serial}
//
// These endpoints are called by Apple's device, not by your app — listed here for
// transparency. A removed / unenrolled member's serial returns 410 Gone (not 500),
// so Wallet cleanly drops a stale card.上線前
Apple 通行證類型 ID
在您的 Apple 開發者帳戶中註冊通行證類型 ID(識別碼→通行證類型 ID)並與您的 SocialHub 團隊共用。
透過簽名證書
為該通行證類型 ID 產生通行證簽章憑證。每個 .pkpass 檔案都會在伺服器端使用該憑證進行簽章;定時任務會監控其過期時間,確保不會悄無聲息地失效。
APNs 授權金鑰 (.p8)
提供 APNs 授權金鑰(金鑰 ID + 團隊 ID),以便 SocialHub 可以推播靜默更新通知,保持 Apple 卡片的最新狀態。
Google Wallet發行人
對於 Google 卡,請提供您的 Google Wallet 發卡機構 ID 和服務帳戶金鑰。 SocialHub 在伺服器端產生簽名的保存連結。
注意:需要付費 Apple 開發者計畫中的 Apple 開發者帳戶才能建立通行證類型 ID 和通行證簽署憑證。
驗收清單
透過 POST /wallet/issue(平台:蘋果)發出的真實 .pkpass 檔案會安裝到裝置上,並顯示會員目前的積分/等級。
請求平台:Google 傳回一個 saveUrl,用於將卡片新增至 Google Wallet。
更改會員積分會在幾秒鐘內刷新已安裝的Apple卡片——無需任何應用程式互動。
向未配置憑證的平台發出請求會傳回 WALLET_NOT_CONFIGURED 錯誤,而不是檔案損壞。
被移除會員的 Apple 通行證序號返回 410 Gone,錢包會刪除該卡-絕不會返回 500。