パシシトがアシャート
プラグインに戻る
@capgo/capacitor-install-referrer
チュートリアル
by github.com/Cap-go

インストールリファラー

CapacitorからGoogle Playのインストールリファラー データとApple AdServicesのAttributionを読み取ります。

ガイド

インストールリファラーのチュートリアル

@capgo/capacitor-install-referrer を使用

@capgo/capacitor-install-referrer インストールデータをCapacitorアプリから読み取ります。

APIを使用して、AndroidではGoogle Playインストールリファラーのデータ、iOSではApple AdServicesの属性トークンを取得します。

インストール

bun add @capgo/capacitor-install-referrer
bunx cap sync

このプラグインが公開するもの

  • getReferrer __CAPGO_KEEP_0__がAndroidまたはiOSのインストール属性詳細を返します。
  • GetReferrer __CAPGO_KEEP_0__は、__CAPGO_KEEP_1__から__CAPGO_KEEP_2__への移行のための非推奨の互換性の別名です。 cap-play-install-referrer.
  • AndroidではPlayリファラー文字列、クリックタイムスタンプ、インストールタイムスタンプ、および即時アプリフラグを返します。
  • iOSではオプションでAppleの属性ペイロードを取得することもできます。

使用例

import { InstallReferrer } from '@capgo/capacitor-install-referrer';

const result = await InstallReferrer.getReferrer();

if (result.platform === 'android') {
  console.log(result.referrer);
}

if (result.platform === 'ios') {
  console.log(result.attributionToken);
}

Apple属性ペイロード

const result = await InstallReferrer.getReferrer({
  fetchAppleAttribution: true,
  appleAttributionRetryCount: 3,
  appleAttributionRetryDelayMs: 5000,
});

console.log(result.appleAttribution);

プラットフォームに関する注記

AndroidではGoogle Playインストールリファラーサービスを使用し、リアルなリファラー データを取得するにはPlayストアのインストールが必要です。iOSではApple AdServicesを使用します。AppleはApp Storeのインストールリファラーの一般的な代替品を提供していないためです。

フルリファレンス