> For the complete documentation index, see [llms.txt](https://documentation.pushly.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.pushly.com/pushly-ja/integration/implementation-steps/react-native/sdk-react-native/sdkmesoddo.md).

# SDKメソッド

## 権限ダイアログを手動で起動する

プラットフォーム経由で権限ダイアログの自動起動を無効にすることもできます。この場合、独自の基準に基づいてダイアログを起動するようにします（例: 訪問者がモーダル / ソフトプロンプトとやり取りした後、特定の画面/ページを訪問した後など）。

以下のコードでダイアログを手動で起動できます:

{% tabs %}
{% tab title="React" %}

```tsx
const { granted } = await PushSDK.showNativeNotificationPermissionPrompt();
console.log(`ユーザーが権限を承認しました: ${granted}`);
```

{% endtab %}
{% endtabs %}

## 購読者のプロフィールに属性を追加する

購読者のプロフィールに属性を追加し、後でそれらの属性に基づいてセグメント分けを行うことができます。たとえば、特定の種類のニュース（例: 政治、スポーツ）に興味がある訪問者にタグを付け、それらを特定の通知の対象にしたい場合があります。

{% tabs %}
{% tab title="React" %}

```tsx
PushSDK.UserProfile.set("interests", ["politics", "news"]);
```

{% endtab %}
{% endtabs %}

一度に複数の属性を設定したい場合は、値のマップを送信することもできます。以下の例では、両方を設定します `is_paying_subscriber` および `interests` 購読者の属性。

{% tabs %}
{% tab title="React" %}

```tsx
PushSDK.UserProfile.set({
  is_paying_subscriber: true,
  interests: ["politics", "news"]
});
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
経由で設定されたプロパティ `PushSDK.UserProfile.append()` では、提供された最新の20個の値のみが保存されます。
{% endhint %}

## アクティビティの追跡（URL / 画面の訪問）

アプリケーション内での購読者の流れを追跡するには、アクティビティ追跡を使用できます。画面またはURL経由で追跡でき、必要に応じて関連するメタデータ/タグを渡せます。

この情報は、その後セグメンテーションで使用して、特定のURLまたはタグ付き画面を訪問した購読者のコホートを作成できます。訪問回数と最近の訪問に基づいてタグ付けされます。例えば: 「過去30日間に少なくとも4回、"Astrology" タグ付きのページ/画面を訪問した購読者」.

{% tabs %}
{% tab title="React" %}
キーワード/タグのメタデータとともに、訪問したURLまたは画面を追跡するには:

```tsx
PushSDK.UserProfile.trackActivity("myapp://dashboard", ["my-tag"]);
```

また、提供するタグがない場合は `tags` パラメータを省略します:

```tsx
PushSDK.UserProfile.trackActivity("https://www.pushly.com/article-1");
```

{% endtab %}
{% endtabs %}

## 匿名の Push ID を取得する

PushSDK は、イベント追跡とデバッグの目的で匿名の Push ID を自動的に割り当てます。

Push ID を返すには、以下のコードを実行してください:

{% tabs %}
{% tab title="React" %}

```tsx
const pushId = await PushSDK.UserProfile.getAnonymousId();
```

{% endtab %}
{% endtabs %}

## 購読者の外部IDを設定する

購読者に一意のユーザーIDを提供すると、後で API を通じてその購読者とやり取りできるようになります。

購読者の外部IDが設定されたら、当社チームと連携して双方向の自動データ同期を構築できます。以下のユースケースは、パブリッシャーがサーバー間リクエストを通じて外部IDを使用する一般的な方法です。

* 個々の購読者にプログラムで通知を送信する
* 購読解除リクエストを処理する
* 購読者のプロフィール属性とイベントを追加および削除する

{% tabs %}
{% tab title="React" %}

```tsx
PushSDK.UserProfile.setExternalId("external-id");
```

{% endtab %}
{% endtabs %}

購読者にすでに External ID がタグ付けされているかどうかも確認できます:

{% tabs %}
{% tab title="React" %}

```tsx
const currentExternalId = await PushSDK.UserProfile.getExternalId();
```

{% endtab %}
{% endtabs %}

## 訪問者がすでに購読済みかどうかを判定する

ユーザーがすでに通知の購読者であるかどうかを知る必要がある場合は、次のスニペットを使用できます:

{% tabs %}
{% tab title="React" %}

```tsx
const subscribed = await PushSDK.UserProfile.getIsSubscribed();
```

{% endtab %}
{% endtabs %}

## 訪問者がプロンプト表示の対象かどうかを判定する

{% tabs %}
{% tab title="React" %}

```tsx
const isEligible = await PushSDK.UserProfile.getIsEligibleToPrompt();
```

{% endtab %}
{% endtabs %}

## ユーザーを完全に削除する

ユーザーをすべての通知と追跡の対象から除外する必要がある場合は、次のメソッドを実行してください:

{% tabs %}
{% tab title="React" %}

```tsx
PushSDK.UserProfile.requestUserDeletion();
```

{% endtab %}
{% endtabs %}

## SDK のログレベルを設定する

PushSDK のログレベルは `なし` がデフォルトに設定されています。サポートされるログレベルは次のとおりです: `詳細`, `デバッグ`, `情報`, `警告`, `エラー`, `重大`、および `なし`.

より詳細なログを有効にするには、次のコードをアプリケーションの `index.tsx` または `app.tsx` ファイル:

{% tabs %}
{% tab title="React" %}

```tsx
PushSDK.setLogLevel(LogLevel.INFO);
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.pushly.com/pushly-ja/integration/implementation-steps/react-native/sdk-react-native/sdkmesoddo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
