はじめに
Tapferry を初めてお使いですか?まずは以下の質問をご覧ください。より詳しい動作については、下記の REST API と SDK ガイドを参照してください。
Tapferryはどのようなサービスですか?
Tapferryは、アプリ・Web・広告キャンペーンからのすべてのクリックを1つの短縮リンクにまとめ、そのリンクがどこでクリックされ、どのユーザーがその後アプリをインストールしてアプリ内で決済したかを追跡するディープリンク/アトリビューション基盤です。
Android App LinksとiOS Universal Linksのドメイン検証ファイルの自動ホスティング、アプリ未インストールのユーザー向けのディファードディープリンク、そしてクリック → インストール → 決済の全フローにわたるアトリビューションを1か所で提供します。
既存の短縮URLサービス(bit.lyなど)と何が違いますか?
短縮URLはクリックを「どこへ送るか」だけを決めます。Tapferryはそれに加えて、次の処理を自動化します。
- OS / ブラウザによる分岐(iOS · Android · Web)
- アプリをインストール済みのユーザーはアプリへ、未インストールのユーザーはアプリストアへ振り分け
- インストール後の初回起動時に、本来意図した画面へユーザーを送るディファードディープリンク
- クリック · インストール · 決済を照合し、広告チャネル / キャンペーン別に集計するアトリビューション
どのプラットフォームに対応していますか?
6つの公式SDKを提供しています。すべての機能はREST APIだけでも利用できます。
- Android — Gradle座標
com.vialink:sdk - iOS — SPMプロダクト
ViaLinkCore - Web — npm
vialink-web-sdk - React Native — npm
vialink-react-native-sdk - Unity — UPM(GitHub URLでインストール)
- Flutter — pub.dev
vialink_flutter_plugin
新規登録と最初のアプリ登録はどうすればよいですか?
ダッシュボードで新規登録してアプリを追加すると、apiKey と apiSecret がすぐに発行されます。あとはSDKガイドの初期化コードにキーを入れるだけで、すぐに連携を始められます。
APIキー / 認証
APIキーはどこで発行できますか?
ダッシュボードの アプリ → SDK タブで確認できます。アプリを作成すると自動で発行されるため、別途申請する必要はありません。
APIキーとAPI Secretの違いは何ですか?
APIキー はSDKやクライアントで使う公開識別子で、API Secret はサーバー間(S2S)呼び出しにのみ使う秘密鍵です。Secretをクライアント側(アプリ/Web)のコードには絶対に含めないでください。
この違いは保存方法にも表れています。Keyは平文(UUID)で保存されますが、Secretはbcryptハッシュとして保存されるため、サーバーでさえ元の値を確認できません。
Secretが必要なエンドポイントはどれですか?
Secretが必要なのは、次の2つのS2Sエンドポイントだけです。
POST /v1/payments/succeededPOST /v1/payments/failed
その他のSDK呼び出し(/v1/resolve、/v1/deferred-match、/v1/events、/v1/payments/initiated など)は X-API-Key だけで動作します。
キーが漏えいしました。再発行はどうすればよいですか?
ダッシュボードのSDKタブにある API Secretを再発行 ボタンから、すぐに再発行できます。
注意: 猶予期間はありません。再発行した瞬間に既存のSecretは無効になるため、新しいSecretをサーバーに反映するまで、既存のSecretを使うリクエストは失敗します。本番稼働中のサーバーがある場合は、トラフィックの少ない時間帯に再発行し、発行された新しいSecretをすぐにサーバーへ反映してください。
APIキーはアカウント単位ですか、それともアプリ単位ですか?
アプリ(テナント)単位です。1つのアカウントで複数のアプリを作成でき、アプリごとに個別のKey / Secretが発行されます。
認証ヘッダー名の大文字・小文字は区別されますか?
HTTPヘッダーは大文字・小文字を区別しません。X-API-Key と x-api-key のどちらも正しく認識されます。
リンク / ドメイン
Short Codeを自分で指定できますか?
リンク作成時に customCode パラメータで指定できます。指定しない場合は、6文字のbase36コードが自動生成されます。
POST /api/links/check-short-code で事前に重複を確認できます。
作成済みのリンクは編集できますか?
はい、PUT /api/links/:id またはダッシュボードから編集できます。編集可能な項目は次のとおりです。
name,description,tagsdeeplinkPath,deeplinkDataiosUrl,androidUrl,webUrlogTitle,ogDescription,ogImageUrlcampaign,channel,featureexpiresAt
ただし、linkType 自体は変更できません。
リンクの有効期限切れ・無効化・削除はどのように処理されますか?
- 有効期限切れ —
expiresAtの時刻を過ぎるとリダイレクトがブロックされます - 無効化 —
suspendedAtでリンクを一時的に停止できます - 削除 —
DELETE /api/links/:idを呼び出すと、deletedAtを記録するソフトデリートが行われます。復旧が必要な場合は管理画面で対応できます
カスタムドメイン(例:go.mycompany.com)を接続できますか?
ダッシュボードの アプリ → ドメイン で登録します。CNAMEの向き先を edge.tapferry.com に設定すると、DNS検証とSSL発行が自動で進みます。
ドメインのステータスは次の段階で表示されます。
pending_dns— DNS検証待ちdns_verified— DNS検証完了ssl_provisioning— SSL証明書を発行中active— 利用可能
カスタムドメインは、customDomain 機能を含む料金プランで利用できます。
SDK連携
App Links / Universal Linksのドメイン検証ファイルは自分でホスティングする必要がありますか?
いいえ、自分でホスティングする必要はありません。Bridge Serverが両方のファイルを自動でホスティングします。
- Android —
GET /.well-known/assetlinks.json。登録済みのパッケージ名(Play Store · ONE Store)とSHA-256フィンガープリントから動的に生成されます - iOS —
GET /.well-known/apple-app-site-association。Bundle ID · Team ID · slugから動的に生成されます
ダッシュボードのアプリ設定でBundle ID / SHA-256を登録するだけで、自動的に反映されます。
/v1/resolveと/v1/deferred-matchの違いは何ですか?
POST /v1/resolve— App Links / Universal Linksでアプリが直接開かれたときに、short codeでリンクデータを即座に照会します(Redisキャッシュ優先)POST /v1/deferred-match— アプリの初回起動時に、サポートされているマッチング方式で過去のクリックコンテキストを紐付けます(ディファードディープリンク)。マッチングの可否は、利用可能なリンクコンテキスト(例:決定論的トークン、Appleが提供するアトリビューションフレームワーク)によって異なります。
SDK連携ガイドの標準フローに従えば、どちらの呼び出しも自動で処理されます。
イベントはどのように記録しますか?
POST /v1/events— 単一のイベントPOST /v1/events/batch— 一括イベント、1リクエストあたり最大100件(オフラインキューイングに便利)
サーバーはイベント名を固定の標準に照らして個別に検証しません。signup、purchase、app.open など、必要な名前を自由に定義できます。
決済 / アトリビューション
決済アトリビューションはどのような流れですか?
- SDKが
POST /v1/payments/initiated(X-API-Key)で決済の試行を送信します - バックエンドはPG(決済代行会社)のコールバックを受け取ると、
POST /v1/payments/succeededまたは/failed(X-API-Key + X-API-Secret)を呼び出します - マッチングは終端呼び出しの時点で同期的に行われ、結果は
payment_eventsテーブルのattributed_*カラムに即座に記録されます
非同期のバッチ処理ではないため、呼び出しのレスポンスでアトリビューション結果をすぐに確認できます。
どのアトリビューションモデルを使用していますか?
ラストクリック(last_click)モデルを使用しています。同一デバイスからの最も新しいクリックがアトリビューションの対象となります。
アトリビューションウィンドウのデフォルト値は?
- クリック → インストールのマッチング:7日(
attribution.click_to_install_days) - インストール → 決済のマッチング:30日(
attribution.install_to_purchase_days) - initiated → succeeded/failed のマッチング:24時間(
attribution.initiated_to_succeeded_hours)
3つの値はすべて、管理画面のシステム設定で調整できます。詳細な疑似コードは、下記の アトリビューションポリシー セクションを参照してください。
マッチングに失敗した場合はどうなりますか?
呼び出しは200で応答しますが、attributed.method には次のいずれかの値が記録されます。
no_initiated_or_no_device— initiated呼び出しがない、またはdevice_idがないno_install_in_window— ウィンドウ内に同一デバイスからのapp.installイベントがないorganic_install— インストールは捕捉されたが、link_idのないオーガニックインストールlast_click_install_only— インストールはマッチングされたが、クリックイベントがないerror— DB照会に失敗(Telegramアラートが送信されます)
各ケースの意味とマッチング手順については、アトリビューションポリシー セクションの疑似コードを参照してください。
料金プラン / 運用
どのような料金プランがありますか?
6つの料金プランがあります。
- Free
- Plus
- Premium
- Pro
- Ultra
- Enterprise
各プランの月間クレジット、API呼び出し回数、アプリ数、ディープリンク数の上限と、利用可能な機能(customDomain、customLanding、teamInvite、paymentTracking、customEvent)は、ダッシュボードの 料金プランページ で確認できます。
分析データはどこで確認できますか?
ダッシュボードの アプリ → 分析 ページで、クリック、インストール、プラットフォーム別、キャンペーン別の統計を確認できます。
ディープリンク
アプリ情報(Bundle IDなど)だけを入力し、まだSDKをインストールしていない状態でテストしていますが、なぜ特定のプラットフォームではリンクがアプリに届かないのですか?
単に「アプリを開く」こと自体はOSが担いますが、「このアプリが実際にこのリンクを受け取る準備ができているか」を確認するロジックはプラットフォームごとに異なります。
- 症状 — リンクからアプリが開いたとしても、SDKが組み込まれていないアプリは、ユーザーがクリックして持ってきたパラメータ(例:紹介コード、特定の商品番号)を解釈できないため、メイン画面で止まったりエラーが発生したりします。
- プラットフォームによる違い — 特にディファードディープリンク(アプリ未インストールのユーザーがインストール後に意図した画面へ到達する仕組み)を使う場合、アプリ内にSDKがないと、ストアのインストール情報とリンクのクリック情報を照合できず、フローが途切れてしまいます。
- 解決方法 — アプリ設定だけでは半分しか完了していません。システムからの呼び出しを受け取る「アンテナ」として、ディープリンクSDKをアプリ内に組み込む必要があります。そうして初めて、すべてのプラットフォームで意図したアプリ内ページに確実に到達できます。
Universal Linksの設定を済ませたのに、Instagram、Facebook、Threadsからアプリが起動しません。何が問題でしょうか?
Custom URL Schemeが抜けていませんか?(SNSアプリから抜け出すための鍵)
Instagram、Facebook、Threadsのようなクローズドなソーシャルプラットフォームは、Universal Linksをそのまま受け入れず、ユーザーを自社のアプリ内ブラウザに閉じ込めます。
- 症状 — Universal Linksだけを設定して Custom URL Scheme の設定を省略していると、アプリ内ブラウザで「アプリで開く」をタップしても何も起きません。アプリを呼び出すための「アドレス」がないためです。
- 解決方法 — アプリ設定(
Info.plist)にアプリ固有のURL Schemeを登録し、同じScheme値をディープリンクSDKの設定にも正しく入力する必要があります。そうして初めて、クローズドなプラットフォームの壁を突破してアプリを開くことができます。
Universal Linksの設定を変更したのに、なぜすぐに反映されないのですか?
設定ミスではなく、キャッシュが原因である可能性が非常に高いです。Universal Linksは、セキュリティとパフォーマンスのためにAppleが仲介役の「保証人」となる仕組みに依存しており、この情報の更新には実際に時間がかかります。
1. なぜすぐに反映されないのか?(3段階のキャッシュ構造)
Universal Linksが動作するまでに、情報は3つの段階を経由します。段階ごとに情報が保持される期間は異なります。
- 段階1 — AppleのCDNサーバー(最大48時間) — Appleは世界中のすべてのアプリの設定を常時確認しているわけではありません。情報を自社のCDN(データストア)に保存し、およそ24〜48時間の周期で更新します。
- 段階2 — ユーザーのiOSデバイス(最大1週間) — iOSは毎回サーバーに確認するのではなく、情報をデバイス内にローカル保存します。これは通常、週に1回程度更新されます。
- 段階3 — プラットフォームごとのアプリ内ブラウザキャッシュ — NaverやFacebookのようなアプリは独自のブラウザキャッシュを持っており、以前に失敗した接続をまだ記憶している場合があります。
2. すぐにテストしたい場合(開発/QA向け)
本番環境のキャッシュがクリアされるまで待てない場合は、次の方法を試してください。
- 方法1 — デベロッパモードを使う(最もおすすめ) — iPhoneで [設定 > デベロッパ > Associated Domains Development] を有効にします。リンクに
?mode=developerパラメータを付けると、Apple CDNを経由せずにサーバーから最新情報を直接取得します。 - 方法2 — アプリを再インストールする — アプリを削除して再インストールすると、デバイス内のキャッシュ情報の一部がリセットされ、新しい設定を読み込めるようになります。
- 方法3 — リンクにランダムなパラメータを追加する —
tapferry.com/abcdの代わりに、tapferry.com/abcd?refresh=1のように一度も使ったことのないアドレスにアクセスすると、キャッシュを回避できる場合があります。
認証
参照・リンク作成と決済試行の報告(/v1/payments/initiated、SDK が呼び出し)は X-API-Key ヘッダーのみで認証します。リンクの更新・削除と S2S 呼び出し(/v1/payments/succeeded、/v1/payments/failed、/v1/conversions)には X-API-Key と X-API-Secret の両方が必要です。Secret はバックエンドでのみ使用してください。ダッシュボードでアプリを登録すると API Key と Secret が発行されます。
リクエストヘッダー
X-API-Key: <your_api_key>
X-API-Secret: <your_api_secret> # update/delete/S2S only (backend)Base URL
すべての API リクエストのベース URL です。
https://tapferry.comリンクの作成
新しいディープリンクを作成します。
リクエストパラメータ
linkType モードの比較
- ·
static(デフォルト) — 固定の単一エントリポイントです。発行された URL にトークンを付けると 404 として扱われます(検索エンジンのインデックス登録を防止)。 - ·
dynamic— 発行された URL に/yourValueや?key=valueを付けると、その値がクリック履歴と SDK のレスポンスに自動で渡されます。
リクエスト例
POST /api/links
Content-Type: application/json
X-API-Key: <your_api_key>
{
"linkType": "static",
"deeplinkPath": "/product/12345",
"deeplinkData": { "product_id": "12345" },
"campaign": "summer_sale",
"channel": "email",
"feature": "product_share",
"ogTitle": "Summer Sale Special",
"ogDescription": "Check it out now!",
"ogImageUrl": "https://cdn.example.com/promo.jpg",
"iosUrl": "https://apps.apple.com/app/id123456",
"androidUrl": "https://play.google.com/store/apps/...",
"webUrl": "https://www.example.com/product/12345",
"tags": ["summer", "sale"],
"expiresAt": "2026-12-31T23:59:59Z",
"customCode": "summer-sale-2026",
"name": "2026 Spring IG ad",
"description": "Instagram story ad only. Expires end of June."
}レスポンス(201 Created)
{
"id": 1,
"shortCode": "summer-sale-2026",
"shortUrl": "https://tapferry.com/{your-slug}/summer-sale-2026",
"deeplinkPath": "/product/12345",
"linkType": "static",
"name": "2026 Spring IG ad",
"description": "Instagram story ad only. Expires end of June.",
"createdAt": "2026-04-06T12:00:00Z"
}エラー(400 Bad Request)
linkType に dynamic/static 以外の値を明示的に送った場合(フィールドを省略すると自動で static として保存されます):
{
"error": "linkType must be either 'dynamic' or 'static'."
}エラー(409 Conflict)
customCode が同じアプリ内ですでに使用されている場合(大文字・小文字を区別せずにチェック):
{
"error": "This short code is already in use."
}エラー(403 Forbidden)
アプリのリンク数がプランのリンク上限に達したとき (ダッシュボードと API で作成したリンクを合わせて数え、削除したリンクは数えません)。レスポンスの code は quota_exceeded で、作成済みリンクの取得・更新・リダイレクトはそのまま動作します:
{
"error": "...",
"code": "quota_exceeded",
"quotaKey": "deeplinkLimit",
"current": 5,
"limit": 5
}リンクの取得
特定のリンクの全情報を取得します。
パスパラメータ
レスポンス(200 OK)
{
"id": 1,
"shortCode": "aB3xK",
"shortUrl": "https://tapferry.com/{your-slug}/aB3xK",
"linkType": "static",
"deeplinkPath": "/product/12345",
"deeplinkData": { "product_id": "12345" },
"campaign": "summer_sale",
"channel": "email",
"feature": "product_share",
"ogTitle": "Summer Sale Special",
"ogDescription": "Check it out now!",
"ogImageUrl": "https://cdn.example.com/promo.jpg",
"iosUrl": "https://apps.apple.com/app/id123456",
"androidUrl": "https://play.google.com/store/apps/...",
"webUrl": "https://www.example.com/product/12345",
"expiresAt": "2026-12-31T23:59:59Z",
"name": "2026 Spring IG ad",
"description": "Instagram story ad only. Expires end of June.",
"createdAt": "2026-04-06T12:00:00Z",
"updatedAt": "2026-04-06T12:00:00Z"
}リンクの更新
既存のリンクを更新します。変更したいフィールドのみ送信してください。X-API-Key に加えて X-Api-Secret ヘッダーが必要なため、必ずバックエンドからのみ呼び出してください(シークレットをアプリやブラウザに含めないでください)。
リクエストパラメータ
linkType は変更できません
このエンドポイントのリクエストボディに linkType キーが含まれていると、400 で拒否されます。モードを変更するには、新しいリンクを作成してください。
パートナーに割り当てられたリンクは遷移先を変更できません
パートナーに割り当てられたトラッキングリンク(partnerId が設定済み)は、遷移先フィールド(deeplinkPath、deeplinkData、iosUrl、androidUrl、webUrl)を変更できず、変更しようとすると 400 を返します。campaign/channel などのメタデータフィールドとパートナーの再割り当て(partnerId)は編集できます。
リクエスト例
PUT /api/links/1
Content-Type: application/json
X-API-Key: <your_api_key>
X-Api-Secret: <your_api_secret>
{
"ogTitle": "Updated title",
"webUrl": "https://www.example.com/new-page",
"name": "2026 Summer ad",
"description": "Updated for the summer campaign."
}レスポンス(200 OK)
更新後のリンクオブジェクト全体(name と description を含む)が返されます。
エラー(400 Bad Request)
リクエストボディに linkType キーが含まれている場合:
{
"error": "Mode cannot be changed. Please create a new link."
}リンクの削除
リンクを削除します(ソフトデリート)。削除されたリンクの URL は機能しなくなります。更新と同様に X-Api-Secret ヘッダーが必要で、必ずバックエンドからのみ呼び出してください。
パスパラメータ
パートナーに割り当てられたリンクは削除できません
パートナーに割り当てられたトラッキングリンク(partnerId が設定済み)は、このエンドポイントでは削除できず 403 を返します(アトリビューションと過去のクリック/コンバージョンを保持するため)。関係を終了するには、パートナーのステータス(一時停止/削除)を使用してください。
レスポンス(200 OK)
{
"success": true
}リンク一覧
作成したリンクの一覧を取得します。
API Key で認証されたアプリのリンク一覧を返します。
レスポンス(200 OK)
{
"links": [
{
"id": 1,
"shortCode": "summer-sale-2026",
"shortUrl": "https://tapferry.com/{your-slug}/summer-sale-2026",
"linkType": "static",
"deeplinkPath": "/product/12345",
"name": "2026 Spring IG ad",
"description": "Instagram story ad only. Expires end of June.",
"createdAt": "2026-04-06T12:00:00Z"
}
],
"total": 50
}短縮コードの確認
リンクを作成する前に、customCode が使用可能かどうかをリアルタイムで確認します。認証: セッション Cookie と、そのテナントに対する ADMIN 以上のロールが必要です。
クエリパラメータ
リクエスト例
GET /api/links/check-short-code?tenantId=tenant_abc&code=summer-sale-2026レスポンス(200 OK — 使用可能)
{
"available": true
}レスポンス(200 OK — すでに使用中)
{
"available": false,
"reason": "This short code is already in use."
}短縮コードのポリシー
- · 自動生成: Base36 小文字(a〜z、0〜9)、6 文字。(以前の大文字・小文字混在の Base62 から変更されました。)
- · カスタム:
/^[a-z0-9_-]{3,24}$/— 英小文字・数字・ハイフン・アンダースコア、3〜24 文字。 - · 大文字・小文字を区別しないルーティング:
tapferry.com/\{slug\}/PTMLWTとtapferry.com/\{slug\}/ptmlwtは同じリンクにマッチします。
決済開始(SDK)
ユーザーが決済画面を開いたときに SDK が呼び出すエンドポイントです。同じ order_id で複数回呼び出しても、そのたびに新しい行が作成されます(カード情報の入力ミスなどによる再試行を追跡するため)。この段階ではマッチングは行われず、後で /v1/payments/succeeded が呼び出されたときに同期的に実行されます。
リクエストヘッダー
X-Api-Key: <your_api_key>
Content-Type: application/jsonリクエストパラメータ
リクエスト例
POST /v1/payments/initiated
X-Api-Key: <your_api_key>
Content-Type: application/json
{
"order_id": "ORD-2026-0001",
"amount": 19900,
"currency": "KRW",
"payment_method": "card",
"device_info": { "device_id": "abc-123", "country": "KR" },
"metadata": { "product_id": "prod-001" }
}レスポンス(200 OK)
{
"success": true,
"payment_event_id": "9876543210"
}エラーレスポンス
決済成功(S2S)
顧客のバックエンドが PG のコールバックを受け取った後に呼び出す Server-to-Server エンドポイントです。マッチングパイプラインが同期的に実行されるため、レスポンスに attributed オブジェクトが含まれます。SDK から直接呼び出さないでください(apiSecret が露出します)。
リクエストヘッダー
X-Api-Key: <your_api_key>
X-Api-Secret: <your_api_secret>
Content-Type: application/jsonapiSecret は DB に bcrypt ハッシュとして保存され、平文比較ではなく bcrypt.compare で検証されます。認証失敗は "Authentication failed." という単一のメッセージに統一され、どの段階(apiKey の存在 / apiSecret の一致 / テナントの有効状態)で失敗したかは明かされません。
リクエストパラメータ
リクエスト例
curl -X POST https://tapferry.com/v1/payments/succeeded \
-H "X-Api-Key: <your_api_key>" \
-H "X-Api-Secret: <your_api_secret>" \
-H "Content-Type: application/json" \
-d '{
"order_id": "ORD-2026-0001",
"amount": 19900,
"currency": "KRW",
"transaction_id": "PG-20260428-9988",
"payment_method": "card",
"metadata": { "channel": "checkout-v2" }
}'レスポンス(200 OK、正常)
{
"success": true,
"payment_event_id": "9876543220",
"attributed": {
"matched": true,
"method": "last_click",
"link_id": 12345,
"click_event_id": 678901,
"install_event_id": "5544332211"
}
}レスポンス(200 OK、冪等 — 同じステータスで再呼び出し)
{
"success": true,
"payment_event_id": "9876543220",
"idempotent": true,
"attributed": {
"matched": true,
"method": "last_click",
"link_id": 12345,
"click_event_id": 678901,
"install_event_id": "5544332211"
}
}レスポンス(409 Conflict — 異なる終了ステータス)
同じ order_id がすでに別の終了状態(例: failed、refunded、canceled)で存在する場合に発生します。
{
"error": "payment already in terminal state",
"existing_status": "failed"
}attribution_method の値
attributed.method が取りうる 7 つの値です。
エラーレスポンス
決済失敗(S2S)
顧客のバックエンドが PG の決済失敗 Webhook を受け取った後に呼び出します。ファネル分析のためにマッチングは同様に行われ DB に保存されますが、レスポンスでは attributed オブジェクトを公開しません(失敗時にクリック/インストールのマッチング結果をクライアントに渡す意味がないため)。
リクエストヘッダー
X-Api-Key: <your_api_key>
X-Api-Secret: <your_api_secret>
Content-Type: application/jsonリクエストパラメータ
リクエスト例
curl -X POST https://tapferry.com/v1/payments/failed \
-H "X-Api-Key: <your_api_key>" \
-H "X-Api-Secret: <your_api_secret>" \
-H "Content-Type: application/json" \
-d '{
"order_id": "ORD-2026-0001",
"amount": 19900,
"currency": "KRW",
"failure_reason": "card_declined",
"transaction_id": "PG-20260428-9988",
"payment_method": "card"
}'レスポンス(200 OK)
{
"success": true,
"payment_event_id": "9876543230"
}レスポンス(200 OK、冪等)
同じ order_id で failed を再度呼び出すと、冪等に処理されます(PG の Webhook の再送に対応するため)。
{
"success": true,
"payment_event_id": "9876543230",
"idempotent": true
}レスポンス(409 Conflict)
すでに succeeded/refunded/canceled となっている注文に対して failed を呼び出した場合に発生します。
{
"error": "payment already in terminal state",
"existing_status": "succeeded"
}エラーレスポンス
パートナーコンバージョンの記録 — 決済以外も含む(S2S)
新規登録、リード、購入などのコンバージョンを パートナーの成果(コンバージョン率・報酬) に帰属させます。バックエンドから Server-to-Server で呼び出してください(ブラウザからは呼び出さないでください — シークレットが露出します)。遷移先 URL に自動で付与される ?vlref= の値を referral_key として渡すと明示的にアトリビューションされ、モバイルアプリは device_id で自動的にアトリビューションされます。SDK の track() カスタムイベントはイベントタブにのみ反映され、パートナーのコンバージョン率には影響しません。
リクエストヘッダー
X-Api-Key: <your_api_key>
X-Api-Secret: <your_api_secret>
Content-Type: application/jsonリクエストパラメータ
リクエスト例
curl -X POST https://tapferry.com/v1/conversions \
-H "X-Api-Key: <your_api_key>" \
-H "X-Api-Secret: <your_api_secret>" \
-H "Content-Type: application/json" \
-d '{
"referral_key": "aB3xK9",
"type": "signup",
"order_id": "SIGNUP-20260702-001",
"amount": 0,
"currency": "KRW"
}'レスポンス(200 OK)
{
"ok": true,
"conversion_id": "412",
"partner_id": "cmr2yofyb0003...",
"attribution_method": "explicit_ref",
"commission_amount": 0,
"status": "confirmed"
}attribution_method は explicit_ref(referral_key がマッチ)| auto_device(インストールがマッチ)| unmatched(パートナーなし)のいずれかです。報酬はコンバージョン時点のパートナー/プログラム設定でスナップショットされます。キャンセル・返金の場合は、order_id を指定して POST /v1/conversions/reverse を呼び出してください。
エラーレスポンス
パートナーコンバージョンの取り消し(返金)— S2S
POST /v1/conversions で記録したコンバージョンを取り消し(返金)ます。バックエンドから Server-to-Server で呼び出してください。取り消されたコンバージョンは status: "reversed" に変わり、パートナーの成果集計(コンバージョン / 売上 / 報酬)から除外されます。
リクエストヘッダー
X-Api-Key: <your_api_key>
X-Api-Secret: <your_api_secret>
Content-Type: application/jsonリクエストパラメータ
リクエスト例
curl -X POST https://tapferry.com/v1/conversions/reverse \
-H "X-Api-Key: <your_api_key>" \
-H "X-Api-Secret: <your_api_secret>" \
-H "Content-Type: application/json" \
-d '{
"order_id": "ORDER-20260702-001"
}'レスポンス(200 OK)
{
"ok": true,
"conversion_id": "412",
"status": "reversed"
}冪等レスポンス — すでに取り消し済み
すでに取り消されたコンバージョンに対して再度呼び出すと、既存の状態をそのまま返します(idempotent: true)。
{
"ok": true,
"conversion_id": "412",
"status": "reversed",
"idempotent": true
}エラーレスポンス
アトリビューションポリシー
決済の成功/失敗をどのクリック/インストールに帰属させるかを決めるルールです。ラストクリック(last_click)モデルに従い、/v1/payments/succeeded または /v1/payments/failed が呼び出されたときに同期的(eager)にマッチングが行われます。マッチング結果は payment_events テーブルの attributed_* カラムに即座に記録されます。
期間の設定
アトリビューション期間はサービス運営ポリシーの値として SystemConfig に保存されており、以下のデフォルト値がすべてのアプリに適用されます。変更が必要な場合はサポートにお問い合わせください。
マッチングの手順(擬似コード)
function attributePayment(tenant_id, order_id, terminal_at):
cfg = loadAttributionConfig() // read SystemConfig
# 1) find the initiated row (within terminal_at - initiated_to_succeeded_hours)
# if the order_id has several initiated rows, prefer the most recent one with a device_id,
# otherwise fall back to the most recent row
init = paymentEvent.findFirst({
tenantId, orderId, status: "initiated", deviceId != null,
createdAt >= terminal_at - cfg.initiated_to_succeeded_hours
}) ?? paymentEvent.findFirst({ ...same conditions, without the deviceId condition })
if init == null or init.deviceId == null:
return method="no_initiated_or_no_device"
# 2) find the install event (by device_id, within terminal_at - install_to_purchase_days)
install = sdkEvent.findFirst({
tenantId, deviceId: init.deviceId,
eventName: "app.install",
createdAt >= terminal_at - cfg.install_to_purchase_days
})
if install == null:
return method="no_install_in_window"
if install.linkId == null:
return method="organic_install" (only install_event_id is filled)
# 3) find the click event (by link_id, within click_to_install_days before the install)
click = clickEvent.findFirst({
tenantId, linkId: install.linkId,
createdAt <= install.createdAt,
createdAt >= install.createdAt - cfg.click_to_install_days
})
return method = click ? "last_click" : "last_click_install_only"マッチングの失敗ケース
インストール
公開 Maven リポジトリ(認証不要)を登録し、Gradle に依存関係を追加します。
// settings.gradle.kts
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url = uri("https://aresjoydev.github.io/vialink-android-sdk") }
}
}
// build.gradle.kts (app)
dependencies {
implementation("com.vialink:sdk:3.2.25")
}初期化
Application.onCreate() で SDK を初期化します。
// Application.kt
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
ViaLinkSDK.init(this, "YOUR_API_KEY")
}
}ディープリンクの処理
ディープリンクのコールバックを登録し、Activity で起動 Intent を処理します。SDK 3.1+:通常起動(アプリアイコンのタップなど)でも data == null でコールバックが呼ばれます。
// Register a deep link callback (SDK 3.1+: (DeepLinkData?) -> Unit)
// Always called once on handleIntent:
// - data != null : App Link entry → route using data.path
// - data == null : normal launch (icon tap etc.) → keep the default screen
ViaLinkSDK.onDeepLink { data ->
if (data == null) {
Log.d("Tapferry", "Normal launch — keep the default screen")
return@onDeepLink
}
Log.d("Tapferry", "path: ${data.path}")
Log.d("Tapferry", "params: ${data.params}")
}
// Deferred deep link callback (SDK 3.2+: called once on every app launch)
// - First launch: called as soon as the match result is decided, within 5s (error on timeout/failure)
// - Non-first launch: called immediately with (null, null) — no /v1/open call (same meaning as organic)
ViaLinkSDK.onDeferredDeepLink { data, error ->
when {
error != null -> Log.w("Tapferry", "Deferred match failed: ${error.code}")
data == null -> Log.d("Tapferry", "Organic or non-first launch — normal entry")
else -> Log.d("Tapferry", "Deferred: ${data.path}")
}
}
// Handle the launch Intent in the Activity (SDK 3.1+: callback also fires on normal launches)
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ViaLinkSDK.handleIntent(intent) // Always called
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
ViaLinkSDK.handleIntent(intent)
}
}イベントトラッキング
カスタムイベントを記録します。SDK は 30 秒ごとにまとめて送信します。SDK はインストールイベント(app.install)を自動送信しません。パートナーのコンバージョンや決済アトリビューションを使う場合は、初回起動時に一度だけ自分で呼び出してください。
// Once on the first launch after install (the SDK does not send app.install)
// Required for partner conversion and payment attribution
// isFirstLaunch: first-launch flag your app keeps in its own storage
if (isFirstLaunch) {
ViaLinkSDK.track("app.install")
}
// Purchase completed
ViaLinkSDK.track("purchase", mapOf(
"product_id" to "12345",
"revenue" to 29900,
"currency" to "KRW"
))
// Sign up
ViaLinkSDK.track("signup")
// Add to cart
ViaLinkSDK.track("add_to_cart", mapOf("product_id" to "12345"))決済トラッキング
決済の試行を Tapferry サーバー(/v1/payments/initiated)に送信します。payment_method/metadata は任意で、device_info は SDK が自動で収集します。レスポンスの paymentEventId は同じ order_id の決済ライフサイクルを識別します。PG のコールバックを受け取った後、バックエンドから /v1/payments/succeeded または /failed を別途呼び出す必要があります(S2S 認証 + bcrypt 検証)。SDK 1.1.1+ から利用できます。
import com.vialink.sdk.ViaLinkSDK
import com.vialink.sdk.model.PaymentInitiatedArgs
import kotlinx.coroutines.launch
// Right before showing the payment screen (inside a coroutine scope)
lifecycleScope.launch {
try {
val result = ViaLinkSDK.payment.initiated(
PaymentInitiatedArgs(
orderId = "ORD-2026-0001",
amount = 19900.0,
currency = "KRW",
paymentMethod = "card",
metadata = mapOf("productId" to "prod-001"),
)
)
// result.success, result.paymentEventId
Log.d("Tapferry", "payment_event_id=${result.paymentEventId}")
} catch (e: IllegalArgumentException) {
// Input validation failed (orderId format, amount, currency)
} catch (e: Exception) {
// Network error
}
}リンクの作成
アプリ内でディープリンクを作成して共有します。フォールバック URL、OG メタタグ、チャネル・タグ・有効期限など、サーバーが受け付けるすべてのオプションを名前付き引数で渡せます。linkType の既定値は "static"(固定の単一エントリポイント、トラッキングなし)です。クリックのトラッキングが必要な場合は "dynamic" を指定してください。
lifecycleScope.launch {
val result = ViaLinkSDK.createLink(
path = "/product/12345",
data = mapOf("promo_code" to "FRIEND_SHARE"),
campaign = "referral",
linkType = "dynamic", // "dynamic" when you need click tracking (omit for "static")
iosUrl = "https://apps.apple.com/app/id123456",
androidUrl = "https://play.google.com/store/apps/details?id=com.example",
webUrl = "https://www.example.com/product/12345",
ogTitle = "Summer Sale",
ogDescription = "Check it out now!",
ogImageUrl = "https://cdn.example.com/promo.jpg",
channel = "email",
feature = "product_share",
tags = listOf("summer", "sale"),
expiresAt = "2026-12-31T23:59:59Z"
)
result.onSuccess { shortUrl ->
// shortUrl: "https://tapferry.com/{your-slug}/xYz12"
val sendIntent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, shortUrl)
type = "text/plain"
}
startActivity(Intent.createChooser(sendIntent, "Share"))
}
}リンクの作成(Java から呼び出す場合)
アプリのソースが Java の場合、suspend fun を直接呼び出すことはできません。SDK 1.4.0+ の Callback/CompletableFuture ラッパーを使い、1.5.0+ からは CreateLinkOptions Builder ですべてのオプションを渡します。
import com.vialink.sdk.ViaLinkSDK;
import com.vialink.sdk.model.CreateLinkOptions;
import java.util.Map;
import java.util.List;
// Full options — using the CreateLinkOptions Builder (Callback)
CreateLinkOptions opts = new CreateLinkOptions.Builder()
.data(Map.of("promo_code", "FRIEND_SHARE"))
.campaign("referral")
.linkType("dynamic")
.iosUrl("https://apps.apple.com/app/id123456")
.androidUrl("https://play.google.com/store/apps/details?id=com.example")
.webUrl("https://www.example.com/product/12345")
.ogTitle("Summer Sale")
.ogImageUrl("https://cdn.example.com/promo.jpg")
.channel("email")
.feature("product_share")
.tags(List.of("summer", "sale"))
.expiresAt("2026-12-31T23:59:59Z")
.build();
ViaLinkSDK.createLinkAsync(
"/product/12345",
opts,
shortUrl -> { /* success (main thread) */ },
err -> Log.e("Tapferry", "Failed to create link", err)
);
// CompletableFuture style (minSdk 24+)
ViaLinkSDK.createLinkFuture("/product/12345", opts)
.thenAccept(shortUrl -> { /* success */ })
.exceptionally(err -> { /* failure */ return null; });
// Simple call — when you don't need fallback/OG options
ViaLinkSDK.createLinkAsync(
"/product/12345",
Map.of("promo_code", "FRIEND_SHARE"),
"referral",
"dynamic",
shortUrl -> {},
err -> {}
);App Links の設定
AndroidManifest.xml に App Links の intent filter を追加します。
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="tapferry.com"
android:pathPrefix="/{your-slug}/" />
</intent-filter>
</activity>インストール
Xcode で Swift Package を追加します。
Xcode > File > Add Package Dependencies
URL: https://github.com/aresjoydev/vialink-ios-sdk初期化
AppDelegate または SwiftUI App の init で SDK を初期化します。
import ViaLinkCore
// AppDelegate
func application(_ application: UIApplication,
didFinishLaunchingWithOptions ...) -> Bool {
ViaLinkSDK.shared.configure(apiKey: "YOUR_API_KEY")
return true
}
// Or SwiftUI App
@main
struct MyApp: App {
init() {
ViaLinkSDK.shared.configure(apiKey: "YOUR_API_KEY")
}
var body: some Scene {
WindowGroup {
ContentView()
.onOpenURL { url in
ViaLinkSDK.shared.handleURL(url)
}
}
}
}ディープリンクの処理
ディープリンクのコールバックを登録し、SceneDelegate で Universal Links を処理します。SDK 3.1+:通常起動(アプリアイコンのタップなど)でも data == nil でコールバックが呼ばれます。
// Register a deep link callback (SDK 3.1+: (DeepLinkData?) -> Void)
// Always called once when notified of app entry:
// - data != nil : Universal Link entry → route using data.path
// - data == nil : normal launch (icon tap etc.) → keep the default screen
ViaLinkSDK.shared.onDeepLink { data in
guard let data = data else {
print("Normal launch — keep the default screen")
return
}
print("path: \(data.path)")
print("params: \(data.params)")
}
// Deferred deep link callback (SDK 3.2+: called once on every app launch)
// - First launch: called as soon as the match result is decided, within 5s (error on timeout/failure)
// - Non-first launch: called immediately with (nil, nil) — no /v1/open call (same meaning as organic)
ViaLinkSDK.shared.onDeferredDeepLink { data, error in
if let error = error {
print("Deferred match failed: \(error.code.rawValue)")
} else if let data = data {
print("Deferred: \(data.path)")
} else {
print("Organic or non-first launch — normal entry")
}
}
// Handle Universal Links + normal-launch notification in SceneDelegate (3.1+)
func scene(_ scene: UIScene,
willConnectTo session: UISceneSession,
options: UIScene.ConnectionOptions) {
if let activity = options.userActivities.first {
ViaLinkSDK.shared.handleUniversalLink(activity)
} else if let urlContext = options.urlContexts.first {
ViaLinkSDK.shared.handleURL(urlContext.url)
} else {
ViaLinkSDK.shared.notifyAppLaunch() // Normal launch
}
}
func scene(_ scene: UIScene,
continue userActivity: NSUserActivity) {
ViaLinkSDK.shared.handleUniversalLink(userActivity)
}イベントトラッキング
カスタムイベントを記録します。SDK はインストールイベント(app.install)を自動送信しません。パートナーのコンバージョンや決済アトリビューションを使う場合は、初回起動時に一度だけ自分で呼び出してください。
// Once on the first launch after install (the SDK does not send app.install)
// Required for partner conversion and payment attribution
// isFirstLaunch: first-launch flag your app keeps in its own storage
if isFirstLaunch {
ViaLinkSDK.shared.track("app.install")
}
// Purchase completed
ViaLinkSDK.shared.track("purchase", data: [
"product_id": "12345",
"revenue": "29900",
"currency": "KRW"
])
// Sign up
ViaLinkSDK.shared.track("signup")決済トラッキング
決済の試行を Tapferry サーバー(/v1/payments/initiated)に送信します。async/await ベースで、PaymentError により入力検証エラーとネットワークエラーを区別して処理できます。PG のコールバックを受け取った後、バックエンドから /v1/payments/succeeded または /failed を別途呼び出す必要があります(S2S 認証 + bcrypt 検証)。SDK 1.1.1+ から利用できます。
import ViaLinkCore
// Right before showing the payment screen (inside an async context)
Task {
do {
let result = try await ViaLinkSDK.shared.payment.initiated(
PaymentInitiatedArgs(
orderId: "ORD-2026-0001",
amount: 19900,
currency: "KRW",
paymentMethod: "card",
metadata: ["productId": "prod-001"]
)
)
print("payment_event_id=\(result.paymentEventId)")
} catch let error as PaymentError {
// .invalidOrderId / .invalidAmount / .invalidCurrency / .sdkNotInitialized / .networkFailure
} catch {
// Other errors
}
}リンクの作成
アプリ内でディープリンクを作成します。フォールバック URL、OG メタタグ、チャネル・タグ・有効期限など、サーバーが受け付けるすべてのオプションを名前付き引数で渡せます。
let shortUrl = try await ViaLinkSDK.shared.createLink(
path: "/product/12345",
data: ["promo_code": "FRIEND_SHARE"],
campaign: "referral",
linkType: "dynamic", // "dynamic" when you need click tracking (omit for "static")
iosUrl: "https://apps.apple.com/app/id123456",
androidUrl: "https://play.google.com/store/apps/details?id=com.example",
webUrl: "https://www.example.com/product/12345",
ogTitle: "Summer Sale",
ogDescription: "Check it out now!",
ogImageUrl: "https://cdn.example.com/promo.jpg",
channel: "email",
feature: "product_share",
tags: ["summer", "sale"],
expiresAt: "2026-12-31T23:59:59Z"
)
// shortUrl: "https://tapferry.com/{your-slug}/xYz12"
let activityVC = UIActivityViewController(
activityItems: [shortUrl],
applicationActivities: nil
)
present(activityVC, animated: true)Universal Links の設定
Xcode で Associated Domains を設定します。
1. Xcode > Target > Signing & Capabilities
2. + Capability > Associated Domains
3. Add domain: applinks:tapferry.comインストール
npm または CDN でインストールします。
npm install vialink-web-sdk初期化
SDK を初期化します。ユーザーがページを離れてもイベントは送信されます。
import { ViaLinkWebSDK } from 'vialink-web-sdk';
const sdk = ViaLinkWebSDK.init({
apiKey: 'YOUR_API_KEY'
});ディープリンクの処理
現在の URL の解析(同期)と短縮リンクの照会(resolveLink)を行います。Web SDK には onDeepLink がありません。getDeepLinkData() はパスセグメントが 2 つ以上ある URL をすべてディープリンクとして扱い(path は常に '/')、サーバーは Web の遷移先にディープリンクのパラメータを付加しないため、この結果をもとに画面遷移しないでください。リンク作成時に webUrl にページの完全なパスを設定してください。
// Warning: do not navigate (location.href / router) based on the result.
// Any URL with 2+ path segments is treated as a deep link
// (e.g. https://myshop.com/blog/hello-world → { path: '/', shortCode: 'hello-world' })
const data = sdk.getDeepLinkData();
if (data) {
console.log('shortCode:', data.shortCode);
}
// Parse an arbitrary URL using the static method (synchronous)
const parsed = ViaLinkWebSDK.parseDeepLinkFromURL(
'https://tapferry.com/{your-slug}/xYz12?ref=share'
);
// → { path: '/', params: { ref: 'share' }, shortCode: 'xYz12' }
// Look up the deep link behind a short link on the server (POST /v1/resolve)
const resolved = await sdk.resolveLink('https://tapferry.com/{your-slug}/xYz12');
if (resolved) {
console.log('path:', resolved.path);
console.log('params:', resolved.params);
}イベントトラッキング
決済以外のコンバージョン(会員登録、リードなど)を含むカスタムイベントを記録します。30 秒ごとにまとめて送信し、ページ離脱時には sendBeacon でも送信します。ダッシュボードの「イベント」タブで集計されます。コンバージョンをパートナーの成果(コンバージョン率・報酬)に帰属させるには、track ではなく POST /v1/conversions をサーバー間(S2S)で呼び出してください。遷移先 URL に自動付加される ?vlref= の値を referral_key として渡します(REST API ドキュメントを参照)。
// Purchase completed
sdk.track('purchase', {
product_id: '12345',
revenue: 29900,
currency: 'KRW'
});
// Signup completed (non-payment conversion — aggregated in the Events tab)
sdk.track('signup_completed');
// Flush immediately
await sdk.flush();決済以外のコンバージョントラッキング(パートナーへの帰属)
sdk.track() のイベントは「イベント」タブにのみ反映され、パートナーの成果(コンバージョン率・報酬)には影響しません。パートナーに帰属させるには、ユーザーがパートナーリンクから流入したときに遷移先 URL に自動付加される ?vlref= の値を保存し、コンバージョンが確定した時点で POST /v1/conversions をサーバー間で呼び出してください(type: signup | purchase | lead | custom、order_id で冪等。下の REST API セクションのパートナーコンバージョン記録を参照)。
// Recommended event names — for Events tab analytics
sdk.track('signup_completed'); // Signup completed
sdk.track('lead_submitted', { form: 'consult' }); // Consultation/inquiry submitted
sdk.track('trial_started'); // Free trial started
// For partner attribution — capture (store) vlref on landing, then
// call POST /v1/conversions from the backend once the conversion is confirmed (pass as referral_key)
const vlref = new URLSearchParams(location.search).get('vlref');
if (vlref) sessionStorage.setItem('vialink_ref', vlref);決済トラッキング
決済の試行を Tapferry サーバー(/v1/payments/initiated)に送信します。SDK 1.1.0+ から利用できます。PG のコールバックを受け取った後、バックエンドから /v1/payments/succeeded または /failed を別途呼び出す必要があります(S2S 認証 + bcrypt 検証)。
import { ViaLinkWebSDK } from 'vialink-web-sdk';
ViaLinkWebSDK.init({ apiKey: 'YOUR_API_KEY' });
// Right before showing the payment screen:
try {
const result = await ViaLinkWebSDK.payment.initiated({
orderId: 'ORD-2026-0001',
amount: 19900,
currency: 'KRW',
paymentMethod: 'card',
metadata: { productId: 'prod-001' },
});
console.log('payment_event_id=', result.paymentEventId);
} catch (e) {
// Input validation failed or network error
console.error(e);
}リンクの作成
Web でディープリンクを作成します。フォールバック URL、OG メタタグ、チャネル・タグ・有効期限などの追加オプションは 5 番目の引数(オブジェクト)で渡します。
const shortUrl = await sdk.createLink(
'/product/12345',
{ promo_code: 'FRIEND_SHARE' },
'referral',
'dynamic', // "dynamic" when you need click tracking (omit for 'static')
{
iosUrl: 'https://apps.apple.com/app/id123456',
androidUrl: 'https://play.google.com/store/apps/details?id=com.example',
webUrl: 'https://www.example.com/product/12345',
ogTitle: 'Summer Sale',
ogDescription: 'Check it out now!',
ogImageUrl: 'https://cdn.example.com/promo.jpg',
channel: 'email',
feature: 'product_share',
tags: ['summer', 'sale'],
expiresAt: '2026-12-31T23:59:59Z',
}
);
console.log(shortUrl); // "https://tapferry.com/{your-slug}/xYz12"インストール
npm または yarn でインストールします。
npm install vialink-react-native-sdk
# or
yarn add vialink-react-native-sdk初期化
App.tsx の最上位で SDK を初期化します。
import { useEffect } from 'react';
import { NavigationContainer, useNavigationContainerRef } from '@react-navigation/native';
import { ViaLinkSDK } from 'vialink-react-native-sdk';
// App.tsx
function App() {
const navigationRef = useNavigationContainerRef();
useEffect(() => {
ViaLinkSDK.shared.configure('YOUR_API_KEY');
return () => {
ViaLinkSDK.shared.destroy();
};
}, []);
return <NavigationContainer ref={navigationRef}>{/* screens */}</NavigationContainer>;
}ディープリンクの処理
ディープリンクのコールバックを登録します。リンク経由でアプリが開かれたときだけ呼ばれ、戻り値は void です(destroy() で解除)。React Navigation の navigate() はルート名を受け取るため、data.path をルートに対応付けてください。
import { ViaLinkSDK, type DeepLinkData } from 'vialink-react-native-sdk';
// navigate() takes a route name, not a path — map data.path to your app's route.
// navigationRef: NavigationContainer ref created with useNavigationContainerRef()
function navigateFromDeepLink(data: DeepLinkData) {
const m = data.path.match(/^\/product\/([^/?#]+)/);
if (m) navigationRef.navigate('Product', { id: m[1] });
}
// Deep link callback — called with data only when opened via a link (not on normal entry)
// Returns void (no unsubscribe function — release with destroy())
ViaLinkSDK.shared.onDeepLink((data) => {
console.log('path:', data.path);
console.log('params:', data.params);
navigateFromDeepLink(data);
});
// Deferred deep link callback (SDK 3.2+: called once on every app launch)
// - First launch: /v1/open match result delivered within 5s (error on timeout/failure)
// - Non-first launch: called immediately with (null, null) — no network call (same meaning as organic)
ViaLinkSDK.shared.onDeferredDeepLink((data, error) => {
if (error) {
console.warn('Deferred match failed:', error.code);
return;
}
if (!data) {
console.log('Organic or non-first launch — normal entry');
return;
}
navigateFromDeepLink(data);
});イベントトラッキング
カスタムイベントを記録します。SDK はインストールイベント(app.install)を自動送信しません。パートナーのコンバージョンや決済アトリビューションを使う場合は、初回起動時に一度だけ自分で呼び出してください。
// Once on the first launch after install (the SDK does not send app.install)
// Required for partner conversion and payment attribution
// isFirstLaunch: first-launch flag your app keeps in its own storage
if (isFirstLaunch) {
ViaLinkSDK.shared.track('app.install');
}
// Purchase completed
ViaLinkSDK.shared.track('purchase', {
product_id: '12345',
revenue: 29900,
currency: 'KRW'
});
// Sign up
ViaLinkSDK.shared.track('signup');決済トラッキング
決済の試行を Tapferry サーバー(/v1/payments/initiated)に送信します。ネイティブブリッジ経由で Android/iOS ネイティブ SDK の payment.initiated を呼び出します(SDK 2.1.0+)。PG のコールバックを受け取った後、バックエンドから /v1/payments/succeeded または /failed を別途呼び出す必要があります。
import { ViaLinkSDK } from 'vialink-react-native-sdk';
// Right before showing the payment screen:
try {
const result = await ViaLinkSDK.shared.payment.initiated({
orderId: 'ORD-2026-0001',
amount: 19900,
currency: 'KRW',
paymentMethod: 'card',
});
console.log('payment_event_id=', result.paymentEventId);
} catch (e) {
// Input validation failed or network error
}リンクの作成
アプリ内でディープリンクを作成して共有します。フォールバック URL、OG、チャネルなどの追加オプションは 5 番目の引数(オブジェクト)で渡します。
const shortUrl = await ViaLinkSDK.shared.createLink(
'/product/12345',
{ promo_code: 'FRIEND_SHARE' },
'referral',
'dynamic', // "dynamic" when you need click tracking (omit for 'static')
{
iosUrl: 'https://apps.apple.com/app/id123456',
androidUrl: 'https://play.google.com/store/apps/details?id=com.example',
webUrl: 'https://www.example.com/product/12345',
ogTitle: 'Summer Sale',
ogImageUrl: 'https://cdn.example.com/promo.jpg',
channel: 'sms',
feature: 'product_share',
tags: ['summer', 'sale'],
expiresAt: '2026-12-31T23:59:59Z',
}
);
await Share.share({ message: shortUrl });プラットフォームの設定
iOS と Android でそれぞれディープリンクの設定が必要です。
// app.json (Expo)
{
"expo": {
"ios": {
"associatedDomains": ["applinks:tapferry.com"]
},
"android": {
"intentFilters": [{
"action": "VIEW",
"autoVerify": true,
"data": [{
"scheme": "https",
"host": "tapferry.com",
"pathPrefix": "/{your-slug}/"
}],
"category": ["BROWSABLE", "DEFAULT"]
}]
}
}
}インストール
UPM でパッケージを追加します。
Window > Package Manager > + > Add package from git URL:
https://github.com/aresjoydev/vialink-unity-sdk.git初期化
最初のシーンに ViaLinkSDK プレハブを配置して初期化します。
using Tapferry;
public class GameManager : MonoBehaviour
{
void Start()
{
ViaLinkSDK.Instance.Initialize("YOUR_API_KEY");
}
}ディープリンクの処理
イベントを購読してディープリンクを処理します。SDK 3.1+:通常起動(アプリアイコンのタップなど)でも data == null でイベントが発生します。
// Deep link callback (SDK 3.1+: also fires on normal launches — data == null)
ViaLinkSDK.Instance.OnDeepLink += (data) =>
{
if (data == null)
{
Debug.Log("Normal launch — keep the default screen");
return;
}
Debug.Log($"path: {data.Path}");
Debug.Log($"params: {data.Params}");
SceneManager.LoadScene(data.Path);
};
// Deferred deep link callback (SDK 3.2+: fires once on every app launch)
// - First launch: /v1/open match result delivered within 5s (error on timeout/failure)
// - Non-first launch: called immediately with (null, null) — no network call (same meaning as organic)
ViaLinkSDK.Instance.OnDeferredDeepLink += (data, error) =>
{
if (error != null)
{
Debug.LogWarning($"Deferred match failed: {error.Code}");
return;
}
if (data == null)
{
Debug.Log("Organic or non-first launch — normal entry");
return;
}
Debug.Log($"Deferred deep link: {data.Path}");
SceneManager.LoadScene(data.Path);
};イベントトラッキング
カスタムイベントを記録します。SDK はインストールイベント(app.install)を自動送信しません。パートナーのコンバージョンや決済アトリビューションを使う場合は、初回起動時に一度だけ自分で呼び出してください。
// Once on the first launch after install (the SDK does not send app.install)
// Required for partner conversion and payment attribution
// isFirstLaunch: first-launch flag your app keeps in its own storage
if (isFirstLaunch)
{
ViaLinkSDK.Instance.TrackEvent("app.install");
}
// In-app purchase
ViaLinkSDK.Instance.TrackEvent("purchase",
new Dictionary<string, object>
{
{ "product_id", "gem_pack_100" },
{ "revenue", 4900 },
{ "currency", "KRW" }
});
// Level cleared
ViaLinkSDK.Instance.TrackEvent("level_clear",
new Dictionary<string, object>
{
{ "level", 10 }
});決済トラッキング
決済の試行を Tapferry サーバー(/v1/payments/initiated)に送信します。Unity SDK はコールバック方式(onSuccess/onError)を使います(SDK 1.1.0+)。PG のコールバックを受け取った後、バックエンドから /v1/payments/succeeded または /failed を別途呼び出す必要があります。
using Tapferry.SDK;
// Right before showing the payment screen (inside a MonoBehaviour)
ViaLinkSDK.Payment.Initiated(
new PaymentInitiatedArgs {
OrderId = "ORD-2026-0001",
Amount = 19900,
Currency = "KRW",
PaymentMethod = "card",
},
onSuccess: (result) => {
Debug.Log($"payment_event_id={result.PaymentEventId}");
},
onError: (error) => {
Debug.LogError($"Payment attempt failed: {error}");
}
);リンクの作成
ゲーム内で招待リンクを作成します。フォールバック URL、OG メタタグ、チャネル・タグ・有効期限など、サーバーが受け付けるすべてのオプションを名前付き引数で渡せます。
ViaLinkSDK.Instance.CreateLink(
path: "/invite",
data: new Dictionary<string, object>
{
{ "inviter_id", PlayerId },
{ "reward", "gem_50" }
},
campaign: "friend_invite",
linkType: "dynamic", // "dynamic" when you need click tracking (omit for "static")
iosUrl: "https://apps.apple.com/app/id123456",
androidUrl: "https://play.google.com/store/apps/details?id=com.example",
webUrl: "https://www.example.com/invite",
ogTitle: "Invite a Friend — Get a Reward",
ogImageUrl: "https://cdn.example.com/invite.jpg",
channel: "in_game",
feature: "friend_invite",
tags: new List<string> { "invite", "viral" },
expiresAt: "2026-12-31T23:59:59Z",
onSuccess: (shortUrl) =>
{
// shortUrl: "https://tapferry.com/{your-slug}/xYz12"
GUIUtility.systemCopyBuffer = shortUrl;
ShowToast("Invite link copied!");
},
onError: (error) =>
{
Debug.LogError($"Failed to create link: {error}");
}
);インストール
pubspec.yaml に依存関係を追加します。
flutter pub add vialink_flutter_plugin初期化
アプリの起動時に SDK を初期化します。
import 'package:vialink_flutter_plugin/vialink_flutter_plugin.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await ViaLinkSDK.instance.configure(apiKey: 'YOUR_API_KEY');
runApp(const MyApp());
}ディープリンクの処理
SDK がディープリンクを自動で受け取るため、コールバックを登録するだけで済みます。onDeepLink に渡される data は null になりません。コールバックはディープリンクで起動したときだけ呼ばれます(通常起動では呼ばれません)。
// Deep link callback — void Function(DeepLinkData data), data is non-null (called only on deep link entry)
ViaLinkSDK.instance.onDeepLink((data) {
print('path: ${data.path}');
print('params: ${data.params}');
Navigator.pushNamed(context, data.path,
arguments: data.params);
});
// Deferred deep link callback (SDK 3.2+: called once on every app launch)
// - First launch: /v1/open match result delivered within 5s (error on timeout/failure)
// - Non-first launch: called immediately with (null, null) — no network call (same meaning as organic)
ViaLinkSDK.instance.onDeferredDeepLink((data, error) {
if (error != null) {
debugPrint('Deferred match failed: $error'); // error is String?
return;
}
if (data == null) {
debugPrint('Organic or non-first launch — normal entry');
return;
}
Navigator.pushNamed(context, data.path, arguments: data.params);
});イベントトラッキング
カスタムイベントを記録します。SDK はインストールイベント(app.install)を自動送信しません。パートナーのコンバージョンや決済アトリビューションを使う場合は、初回起動時に一度だけ自分で呼び出してください。
// Once on the first launch after install (the SDK does not send app.install)
// Required for partner conversion and payment attribution
// isFirstLaunch: first-launch flag your app keeps in its own storage
if (isFirstLaunch) {
ViaLinkSDK.instance.track('app.install');
}
// Purchase completed
ViaLinkSDK.instance.track('purchase', data: {
'product_id': '12345',
'revenue': '29900',
'currency': 'KRW',
});
// Sign up
ViaLinkSDK.instance.track('signup');決済トラッキング
決済の試行を Tapferry サーバー(/v1/payments/initiated)に送信します。ViaLinkSDK.instance.trackPayment() は Pigeon チャネル経由でネイティブ SDK を呼び出します。PG のコールバックを受け取った後、バックエンドから /v1/payments/succeeded または /failed を別途呼び出す必要があります。
import 'package:vialink_flutter_plugin/vialink_flutter_plugin.dart';
// Right before showing the payment screen:
try {
final result = await ViaLinkSDK.instance.trackPayment(
orderId: 'ORD-2026-0001',
amount: 19900,
currency: 'KRW',
paymentMethod: 'card',
metadata: {'productId': 'prod-001'},
);
print('payment_event_id=${result.paymentEventId}');
} catch (e) {
// Native errors such as PlatformException
}リンクの作成
アプリ内でディープリンクを作成します。フォールバック URL、OG メタタグ、チャネル・タグ・有効期限など、サーバーが受け付けるすべてのオプションを名前付き引数で渡せます。
final shortUrl = await ViaLinkSDK.instance.createLink(
path: '/product/12345',
data: {'promo_code': 'FRIEND_SHARE'},
campaign: 'referral',
linkType: 'dynamic', // "dynamic" when you need click tracking (omit for 'static')
iosUrl: 'https://apps.apple.com/app/id123456',
androidUrl: 'https://play.google.com/store/apps/details?id=com.example',
webUrl: 'https://www.example.com/product/12345',
ogTitle: 'Summer Sale',
ogDescription: 'Check it out now!',
ogImageUrl: 'https://cdn.example.com/promo.jpg',
channel: 'email',
feature: 'product_share',
tags: ['summer', 'sale'],
expiresAt: '2026-12-31T23:59:59Z',
);
// shortUrl: "https://tapferry.com/{your-slug}/xYz12"
await Share.share(shortUrl);プラットフォームの設定
iOS と Android でそれぞれディープリンクの設定が必要です。
# iOS: ios/Runner/Runner.entitlements
# Add Associated Domains:
# applinks:tapferry.com
# Android: android/app/src/main/AndroidManifest.xml
# <intent-filter android:autoVerify="true">
# <action android:name="android.intent.action.VIEW" />
# <category android:name="android.intent.category.DEFAULT" />
# <category android:name="android.intent.category.BROWSABLE" />
# <data
# android:scheme="https"
# android:host="tapferry.com"
# android:pathPrefix="/{your-slug}/" />
# </intent-filter>