> 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(`User accepted permissions: ${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 %}

プロパティの値を配列として保存している場合は、 `append` および `remove` メソッドを使用して値を追加または削除できます。どちらも非同期で、 `Promise<void>` を返し、更新が送信されると解決されます。

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

```tsx
// add 'sports' to the subscriber's existing interests
await PushSDK.UserProfile.append("interests", ["sports"]);

// remove 'fashion' and 'news' from the subscriber's interests
await PushSDK.UserProfile.remove("interests", ["fashion", "news"]);
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
次を介して更新されたプロパティは `PushSDK.UserProfile.append()` および `PushSDK.UserProfile.remove()` では、指定された最新の 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 を設定する

購読者に一意の User ID を設定すると、後で API 経由でその購読者とやり取りできるようになります。

購読者の external ID が設定されたら、当社チームと連携して双方向の自動データ同期を設定できます。以下は、発行者が server-to-server リクエストを通じて external 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 %}

## ユーザーの通知を一時停止/再開する（ソフト解除購読）

次のメソッドを呼び出すことで、ユーザーの通知を一時停止できます。これは非同期で、 `Promise<void>` 一時停止が SDK に送信されると解決されます:

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

```tsx
await PushSDK.PushNotifications.pause();
```

{% endtab %}
{% endtabs %}

ユーザーの通知を再開する場合は、次のメソッドを呼び出します。これも非同期で、 `Promise<void>`:

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

```tsx
await PushSDK.PushNotifications.resume();
```

{% endtab %}
{% endtabs %}

ユーザーの通知が現在一時停止されているか確認するには、 `getIsPaused()`:

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

```tsx
const isPaused = await PushSDK.PushNotifications.getIsPaused();
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
React Native SDK では、これを非同期メソッドとして公開しています `getIsPaused()`、返り値は `Promise<boolean | null>`です。Android および iOS SDK では、同じ状態を同期的に `isPaused` （プロパティ/メソッド）として公開しています。Android または iOS のドキュメントや例に従う場合は、 `await PushSDK.PushNotifications.getIsPaused()` を `isPaused`.
{% endhint %}

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

ユーザーをすべての通知とトラッキングから除外する必要がある場合は、次のメソッドを実行します:

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

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

{% endtab %}
{% endtabs %}

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

PushSDK のログレベルはデフォルトで `NONE` に設定されています。サポートされているログレベルは次のとおりです: `VERBOSE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `CRITICAL`、および `NONE`.

より詳細なログを有効にするには、アプリケーションの次の `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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
