> 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/sdk-swift-obj-c/dpurinku.md).

# ディープリンク

PushSDK は、通知の開封を次の方法で処理します:

* デフォルトでは、SDK は自動的に次を呼び出します `open` メソッドを、通知に添付されたランディング URL を使用して呼び出します。
* 次を実装する場合 `didReceiveNotificationDestination` 通知が開かれたときに必要なカスタムロジックを実行できるライフサイクルデリゲートです。

## URL 処理デリゲートの実装

PushSDK は、購読者が通知とやり取りしたときに呼び出されるデリゲートを提供します。これらのデリゲートは、通知を開いた後に購読者が適切なコントローラー、ページ、またはその他のビューへ自動的に移動するよう実装する必要があります。

{% hint style="danger" %}
すべての SDK デリゲートは、アプリケーションの `AppDelegate` クラス内に配置して、すべての通知イベントを適切に処理することを推奨します。
{% endhint %}

SDK が通知のオープンイベントを受信すると、以下のいずれかのデリゲートを、アプリ内で購読者を適切なビューへ移動させるために使用できるパラメータ付きで呼び出そうとします。これらのデリゲートを実装するには、 `PNNotificationLifecycleDelegate`.

このプロトコルを実装するクラスを SDK に通知する必要があります。これは、 `setNotificationLifecycleDelegate` メソッドを SDK で使用して行えます:

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

```swift
PushSDK.setNotificationLifecycleDelegate(self)
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
[PushSDK setNotificationLifecycleDelegate:self];
```

{% endtab %}
{% endtabs %}

たとえば、通知内にランディング URL が提供されており、あなたの `AppDelegate` 内で購読者のナビゲーションを処理するデリゲートを実装している場合、コードは次のようになります：

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

```swift
import Pushly

@main
class AppDelegate: UIResponder, UIApplicationDelegate, PNNotificationLifecycleDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        PushSDK.setConfiguration(appKey: "YOUR_APP_KEY", withLaunchOptions: launchOptions)
        PushSDK.PushNotifications.showPermissionPrompt() { granted, settings, error in
            // 任意のコールバック
            print("User accepted permissions: \(granted)")
        }
        PushSDK.setNotificationLifecycleDelegate(self)

        return true
    }

    func pushSDK(didReceiveNotificationDestination destination: String, withInteraction interaction: PNNotificationInteraction) -> Bool {
        // destination（ランディング URL）を使用して、アプリケーション内のビューへ移動
        
        // SDK に対して遷移しないよう通知するために true を返す
        return true
    }
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
@import Pushly;

@interface AppDelegate () <PNNotificationLifecycleDelegate>

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // アプリ起動後のカスタマイズ用のオーバーライドポイント。

    PushSDK.logLevel = PNLogLevelInfo;
    [PushSDK setConfigurationAppKey:@"YOUR_APP_KEY" withLaunchOptions:launchOptions];

    [PushSDKPushNotificationsSDK showPermissionPrompt:^(BOOL granted, UNNotificationSettings * _Nonnull settings, NSError * _Nullable error) {
        NSLog(@"User accepted permissions: %d", granted);
    }];
    
    [PushSDK setNotificationLifecycleDelegate:self];

    return YES;
}

- (BOOL)pushSDKDidReceiveNotificationDestination:(NSString *)destination withInteraction:(PNNotificationInteraction *)interaction {
    // destination（ランディング URL）を使用して、アプリケーション内のビューへ移動
    
    // SDK に対して、ナビゲートしないようにするには YES を返します
    return YES;
}
```

{% endtab %}
{% endtabs %}

## 通知インタラクション デリゲート

### URI/URL 宛先付きで通知が開かれた場合

このデリゲートは、ランディング URL が関連付けられた通知が開かれたときに呼び出されます。サブスクライバーは、その URL を表すビューへ移動する必要があります。

このメソッドは Boolean の応答を想定しています。応答が `true` の場合、この通知のオープンに対して SDK はナビゲーションを行いません。応答が `false` の場合、SDK は `open` メソッド内に追加します。

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

```swift
func pushSDK(didReceiveNotificationDestination destination: String, withInteraction interaction: PNNotificationInteraction) -> Bool {
    // destination（ランディング URL）を使用して、アプリケーション内のビューへ移動
        
    // SDK に対して遷移しないよう通知するために true を返す
    return true
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
- (BOOL)pushSDKDidReceiveNotificationDestination:(NSString *)destination withInteraction:(PNNotificationInteraction *)interaction {
    // destination（ランディング URL）を使用して、アプリケーション内のビューへリダイレクト
    
    // SDK に対して、リダイレクトしないことを通知するには YES を返します
    return YES;
}
```

{% endtab %}
{% endtabs %}

x


---

# 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/sdk-swift-obj-c/dpurinku.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.
