> 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/apple-ios/p8kmatahap12no.md).

# P8キーまたはP12証明書の設定

## 前提条件

通知へのユーザー登録を開始するには、P8 キー（推奨）または P12 証明書のいずれかが必要です。これらはいずれも Apple Developers ポータルから生成できます。

* ある [Apple Developer アカウント](https://developer.apple.com/account/) 管理者権限を持つ
* あなたのアプリケーションの App Bundle ID（例： `com.pushly.example`)
* Push Notifications 機能が追加された iOS アプリケーションまたは XCode プロジェクト

{% hint style="info" %}
**どの作業をどこで行うか。** iOS 通知の設定は 2 つのシステムにまたがっており、その区別は混同しやすいです：

* **Apple Developer ポータル** — App ID を登録して機能を有効化し、テストに使用するデバイスを登録し、APNs 認証キー（`.p8`）または証明書（`.p12`).
* **Pushly ダッシュボード** — 次をアップロードします： `.p8` キーとその `Key ID` と `Team ID` （または `.p12` と `Bundle ID`）これにより、Pushly があなたに代わって APNs に送信できます。

送信資格情報はサーバー側の設定です。これらはアプリのコードに追加されることは決してありません、 `Info.plist`、またはエンタイトルメントに追加されることもありません — アプリ自体に必要なのは SDK Key のみです。
{% endhint %}

## App ID を登録する

通知を受信するすべてのアプリには、必要な機能が有効化された App ID が Apple Developer ポータルに必要です。キーや証明書を生成する前にこれを完了してください。

1. [ログイン](https://developer.apple.com/account/) あなたの会社の Apple Developer アカウントに。
2. 次をクリックします： `Identifiers` の下にあるリンクを `Certificates、Identifiers & Profiles`
3. 右上のドロップダウンで次が選択されていることを確認し、 `App IDs` が選択されていることを確認し、次の `+` の横にあるボタンをクリックします。 `Identifiers` 見出し。
4. 選択し、 `App IDs` オプション一覧から次を選び、 `続行` ボタンを押します。
5. 選択し、 `アプリ` を識別子タイプとして、次の `続行` ボタンを押します。
6. 説明を入力します。例： `YOUR_APP_NAME Push Notifications`
7. アプリの Bundle ID を Xcode プロジェクトと完全に一致するように入力します。例： `com.pushly.example`
8. 次の `Capabilities` タブで、次の両方にチェックを入れます：
   * `Push Notifications` — アプリが APNs に登録するために必須です。
   * `App Groups` — PushSDK がアプリと Notification Service Extension の間でデータを受け渡すために使用する共有コンテナーに必要です。参照： [<mark style="color:青い;">共有 App Group を構成する</mark>](/pushly-ja/integration/implementation-steps/apple-ios/sdk-swift-obj-c.md#step-4-configure-the-shared-app-group).
9. 次をクリックします： `続行` そして次に `登録` ボタンを押します。

{% hint style="warning" %}
App ID で機能を有効にするだけでは不十分です — 実際にビルドへエンタイトルメントが付与される前に、その後で provisioning profile を再生成する必要があります。Xcode は次の場合にこれを自動で行います `Automatically manage signing` が有効になっている場合です。プロファイルを手動で管理している場合は、いずれかの機能を変更した後にプロファイルを再生成してダウンロードしてください。
{% endhint %}

## テストデバイスを登録する

開発ビルドは、チームに登録されたデバイスにのみインストールされます。

* を有効にすると、 `Automatically manage signing` が有効になっていると、Xcode はそのデバイスに初めてビルドするときに接続されたデバイスを登録します。
* デバイスを手動で登録するには、次へ移動します： `Devices` Apple Developer ポータルで、次をクリックし、 `+`、デバイス名とその識別子（UDID）を入力します。

{% hint style="info" %}
シミュレーターは登録不要です。シミュレーターは、次の要件を満たしていれば APNs に登録し、実際のリモート通知を受信できます： [<mark style="color:青い;">シミュレーターでのテスト</mark>](/pushly-ja/integration/implementation-steps/apple-ios/sdk-swift-obj-c.md#testing-on-a-simulator); 要件を満たさない環境では、トークン登録は物理デバイスで実施する必要があります。
{% endhint %}

## P8 キーの設定（推奨）

### ステップ 1: キーを生成する

既存の P12 証明書を更新しない場合は、通知送信の認可には新しい P8 キーの使用をおすすめします。P8 キーはすべてのアプリケーションと環境で使用できます。開発用と本番用、またはアプリごとに別々の P8 ファイルは必要ありません。

新しい P8 キーを作成するには、次へ移動します： [Apple Developer アカウント](https://developer.apple.com/account/) そして次をクリックします： `Keys` リンク。

<figure><img src="https://810756845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lry9Z27iWOZyQEGAgY7%2Fuploads%2Fhr66nmrcH5k9oL8e59TU%2Fkeys.png?alt=media&#x26;token=4fff2cf6-6abd-44e0-88d5-18c8ed2976bd" alt=""><figcaption></figcaption></figure>

次のページで次をクリックします： `+` の横にあるボタンをクリックします。 `Keys` 見出し

P8 キーの名前を入力します。会社名、アプリケーション名、または後で識別しやすくなる任意のテキストを指定できます。

次にチェックを入れます： `Apple Push Notification service (APNs)` のボックスにチェックを入れ、次をクリックします： `続行` ボタンを押します。

<figure><img src="https://810756845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lry9Z27iWOZyQEGAgY7%2Fuploads%2F1MikHTSIx0icOiCAaWJx%2Fcreate.png?alt=media&#x26;token=d57ce1af-94e1-445b-bc1b-bbb0a32eef50" alt=""><figcaption></figcaption></figure>

次のページで、次に提供される値をコピーし、 `Key ID` そして次をクリックします： `ダウンロード` ボタンを押して P8 キーをダウンロードします。

<figure><img src="https://810756845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lry9Z27iWOZyQEGAgY7%2Fuploads%2FlZQkYbTrhXRRZERcCaec%2FScreenshot%202022-12-12%20at%204.10.09%20PM.png?alt=media&#x26;token=3ba39f9c-e7b6-473d-808a-b289075eb454" alt=""><figcaption></figcaption></figure>

必要な最後の情報は次です： `Team ID` あなたのメンバーシップに紐づいており、画面右上の名前の下にあります。

<figure><img src="https://810756845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lry9Z27iWOZyQEGAgY7%2Fuploads%2FXFo3595GgoygzfAbErcN%2FScreenshot%202022-12-12%20at%204.19.50%20PM.png?alt=media&#x26;token=24947664-83c3-4817-976e-33cbe23f9963" alt=""><figcaption></figcaption></figure>

### ステップ 2: Pushly で連携を有効化する

これで次を用意できました： `Team ID`, `Key ID` 、そして P8 キー。Pushly プラットフォームにログインし、次へ移動できます： `設定` ページで、次を見つけます： `送信連携` セクション。

ここでは次をクリックします： `編集` ボタンを `送信連携` 見出しで、次を有効にし、 `Native` の下にあるスイッチを `Apple` 見出しの下で、次を行います：

1. 選択し、 `P8 Cert` ピル型の選択肢から
2. 証明書エリアをクリックして P8 キーをアップロードします
3. 次を入力します： `Team ID`
4. 次を入力します： `Key ID`
5. 次をクリックします： `送信` ボタン

<figure><img src="https://810756845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lry9Z27iWOZyQEGAgY7%2Fuploads%2FzISEeeHVthIJ2AVhffo5%2FScreenshot%202023-02-01%20at%209.29.20%20AM.png?alt=media&#x26;token=2a1e22e1-3c51-435c-8f39-8e20a9a8a65e" alt=""><figcaption></figcaption></figure>

すべて正しく入力されていれば、今は次の下にセクションが表示されるはずです： `送信連携` アクティブな Apple Native 連携が表示されます。

<figure><img src="https://810756845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lry9Z27iWOZyQEGAgY7%2Fuploads%2Fnwbudz0lLpKSXyWiK5Eo%2FScreenshot%202023-02-01%20at%209.27.22%20AM.png?alt=media&#x26;token=b86668f2-c739-4630-a063-629a7c78bc7f" alt=""><figcaption></figcaption></figure>

## P12 証明書の設定

新しい P12 証明書を作成するよりも P8 キーの使用をおすすめします。既存の P12 証明書がある場合は、以下の手順で更新し、プラットフォームに追加してください。

### ステップ 1: 証明書署名要求（CSR）を作成する

1. Mac コンピュータで次を開きます： `Keychain Access` アプリケーション
2. 次の中で `Keychain Access` 主要アプリケーションメニューから次を選択します： `Keychain Access` > `証明書アシスタント` > `認証局に証明書を要求する`
3. 証明書情報ウィンドウで、次の情報を入力します：
   * 次の `User Email Address` 欄にメールアドレスを入力します。
   * 次の `Common Name` 欄で、秘密鍵の名前を作成します（例: Company Name Web Push）。
   * 次の `CA Email Address` 欄は空欄のままにします。
   * 次の `Request` グループで、次を選択します： `ディスクに保存` オプション。
4. 次をクリックし、 `続行` Keychain Access 内で、CSR をディスクに保存してこの手順を完了します。

### ステップ 2: アプリの識別子を作成する

{% hint style="danger" %}
すでに次を完了している場合は： [<mark style="color:青い;">App ID を登録する</mark>](#register-your-app-id) 上記、または既存の証明書を更新している場合は、この手順をスキップしてステップ 3 に進んでください — App Identifier はすでに Apple developer アカウント内に存在します。
{% endhint %}

1. [ログイン](https://developer.apple.com/account/ios/certificate/) あなたの会社の Apple Developer Console アカウントに。
2. 次をクリックします： `Identifiers` の下にあるリンクを `Certificates、Identifiers & Profiles`
3. 右上のドロップダウンで次が選択されていることを確認し、 `App IDs` が選択されていることを確認し、次の `+` の横にあるボタンをクリックします。 `Identifiers` 見出し。
4. 選択し、 `App IDs` オプション一覧から次を選び、 `続行` ボタンを押します。
5. 選択し、 `アプリ` を識別子タイプとして、次の `続行` ボタン
6. 説明を入力します。例： `YOUR_APP_NAME Push Notifications`
7. アプリの Bundle ID を入力します。例： `com.YOUR_APP_NAME.app-push`
8. 次の `Capabilities` タブを下にスクロールして次にチェックを入れます： `Push Notifications` 機能
9. 次をクリックします： `続行` そして次に `登録` ボタンを押します。

### ステップ 3: Web Push 証明書を生成する

1. 次をクリックします： `Certificates` 左側ナビゲーションで、次の `+` の横にある記号を押します： `Certificates` 見出し
2. 選択し、 `Apple Push Notification service SSL (Sandbox & Production)` をサービス一覧から選択し、次にクリックします： `続行`.
3. 証明書を生成するアプリケーションに対応する App Identifier を選択し、次をクリックします： `続行` ボタンを押します。
4. 次をクリックします： `ファイルを選択` ボタンを押し、最初の手順で作成した CSR ファイルを参照して、次をクリックします： `続行`.
5. 次の画面で、証明書の準備ができたことが通知されます。次をクリックします： `ダウンロード` 証明書をコンピュータに保存します。

### ステップ 4: .p12 証明書を生成する

* コンピュータに保存した証明書へ移動し、ダブルクリックして次にインストールします： `Keychain Access` アプリケーション。
* 次を開きます： `Keychain Access` アプリケーションを開き、次をクリックします： `My Certificates` タブを `ログイン` 左側ナビゲーションセクションで keychain を選択した状態にします。
* インストール済みの Apple Push Services 証明書を右クリックし、次を選択します： `エクスポート`.
* 保存ダイアログでファイル名を選択し（または既定値のまま）、次の形式を選びます： `.p12` ファイル形式を選択し、次をクリックします： `保存` ボタンを押します。
* パスワードの入力を求められます - どちらのボックスも空のままにして次をクリックします： `OK`.
* 次をクリックし、 `許可` p12 証明書をコンピュータに保存します。

### ステップ 5: プラットフォーム経由で証明書をアップロードする

これで次を用意できました： `Bundle ID` そして P12 証明書。Pushly プラットフォームにログインし、次へ移動できます： `設定` ページで、次を見つけます： `送信連携` セクション。

ここでは次をクリックします： `編集` ボタンを `送信連携` 見出しで、次を有効にし、 `Native` の下にあるスイッチを `Apple` 見出しの下で、次を行います：

1. アプリケーションの `Bundle ID`
2. 選択し、 `P12 Cert` ピル型の選択肢から
3. エリアをクリックして P12 証明書をアップロードします
4. 証明書を生成したときにパスフレーズを入力した場合は、スイッチを有効にしてそれを追加します
5. 次をクリックします： `送信` ボタン


---

# 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/apple-ios/p8kmatahap12no.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.
