---
sourceDocument: Xanadu API リファレンス
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - ja-JP

ft:publication_title :

    - Xanadu API リファレンス

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# NowAnalyticsServiceDelegate プロトコル - iOS

# NowAnalyticsServiceDelegate プロトコル - iOS {#ariaid-title1}

* リリースバージョン: Xanadu
* 
* 更新日 2024年08月01日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：13分

NowAnalyticsServiceDelegate プロトコルは、ユーザー セッションの開始と終了に関する情報と画面変更の検出を提供するコールバック関数を提供します。

## NowAnalyticsServiceDelegate:nowAnalyticsDidDetectScreen( _ sessionId:文字列) {#ariaid-title2}

画面の変更が検出されたときに通知します。画面名はナビゲーションバーから検出されます。それが不可能な場合は、viewControllerサブクラス名です。
{#NAnServDel-nowAnalDidDetectScreen_S__table_ljr_3bb_kqb__entry__3}

| 名前 | タイプ | Description (説明) |
|-|-|-|
| スクリーン名 | 文字列 | 変更があるかどうかを検出する画面の名前。 |
[表 : 1. パラメーター]

{#NAnServDel-nowAnalDidDetectScreen_S__table_ljr_3bb_kqb} {#NAnServDel-nowAnalDidDetectScreen_S__table_mjr_3bb_kqb__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | 渡された screenName を上書きするために使用するカスタム名。 |
[表 : 2. 返される内容]

{#NAnServDel-nowAnalDidDetectScreen_S__table_mjr_3bb_kqb}  
この例では、 NowAnalyticsServiceDelegate のデリゲートクラスを定義する方法を示します。

    import NowAnalytics

    // Initialize the Analytics SDK
    NowAnalytics.configure(for: URL(string: "https://my.instance.service-now.com")!)

    // Define a delegate class for NowAnalyticsServiceDelegate
    class NowAnalyticsDelegate: NowAnalytics.NowAnalyticsServiceDelegate {
      func nowAnalyticsSessionShouldStart() -> Bool {
        // Session is about to start, return true to allow session to start
        return true
      }

      func nowAnalyticsSessionDidStart(_ sessionId: String) {
        // Session was started
      }

      func nowAnalyticsSessionShouldEnd(_ sessionId: String) -> Bool {
        // Session is about to end, return true to allow session to end
        return true
      }

      func nowAnalyticsSessionDidEnd(_ sessionId: String) {
        // Session was ended
      }

      func nowAnalyticsDidDetectScreen(_ screenName: String) -> String? {
        // Example of skipping specific screen detection
        if (screenName == "LoginViewController") {
          return nil
        }

        // Example of appending a prefix for every screen detected
        return "MyApp_" + screenName
      }
    }

    // Register delegate
    private var analyticsDelegate = NowAnalyticsDelegate()  // Keep ref of delegate
    NowAnalytics.sharedAnalyticsService.setDelegate(analyticsDelegate)

## NowAnalyticsServiceDelegate:nowAnalyticsSessionDidEnd( _ sessionId:文字列) {#ariaid-title3}

指定したセッションが 終了したことを通知します。
これは、指定されたセッションが実際に終了したときに呼び出されるコールバック関数です。
{#NAnServDel-nowAnalSessionDidEnd_S__table_hnt_b2v_1qb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| sessionId | 文字列 | チェックするセッションの一意の識別子。 |
[表 : 3. パラメーター]

{#NAnServDel-nowAnalSessionDidEnd_S__table_hnt_b2v_1qb} {#NAnServDel-nowAnalSessionDidEnd_S__table_int_b2v_1qb__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 4. 返される内容]

{#NAnServDel-nowAnalSessionDidEnd_S__table_int_b2v_1qb}  
この例では、 NowAnalyticsServiceDelegate のデリゲートクラスを定義する方法を示します。

    import NowAnalytics

    // Initialize the Analytics SDK
    NowAnalytics.configure(for: URL(string: "https://my.instance.service-now.com")!)

    // Define a delegate class for NowAnalyticsServiceDelegate
    class NowAnalyticsDelegate: NowAnalytics.NowAnalyticsServiceDelegate {
      func nowAnalyticsSessionShouldStart() -> Bool {
        // Session is about to start, return true to allow session to start
        return true
      }

      func nowAnalyticsSessionDidStart(_ sessionId: String) {
        // Session was started
      }

      func nowAnalyticsSessionShouldEnd(_ sessionId: String) -> Bool {
        // Session is about to end, return true to allow session to end
        return true
      }

      func nowAnalyticsSessionDidEnd(_ sessionId: String) {
        // Session was ended
      }

      func nowAnalyticsDidDetectScreen(_ screenName: String) -> String? {
        // Example of skipping specific screen detection
        if (screenName == "LoginViewController") {
          return nil
        }

        // Example of appending a prefix for every screen detected
        return "MyApp_" + screenName
      }
    }

    // Register delegate
    private var analyticsDelegate = NowAnalyticsDelegate()  // Keep ref of delegate
    NowAnalytics.sharedAnalyticsService.setDelegate(analyticsDelegate)

## NowAnalyticsServiceDelegate:nowAnalyticsSessionDidStart( _ sessionId:文字列) {#ariaid-title4}

指定したセッションが開始されたときに通知します。
これは、指定されたセッションが実際に開始されたときに呼び出されるコールバック関数です。
{#NAnServDel-nowAnalSessionDidStart_S__table_ntx_m2v_1qb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| sessionId | 文字列 | チェックするセッションの一意の識別子。 |
[表 : 5. パラメーター]

{#NAnServDel-nowAnalSessionDidStart_S__table_ntx_m2v_1qb} {#NAnServDel-nowAnalSessionDidStart_S__table_otx_m2v_1qb__entry__2}

| タイプ | 説明 |
|-|-|
| ブーリアン | セッションが開始中であることを示すフラグ。 有効な値： * true:セッションを開始しています * false:セッションが開始されていません |
[表 : 6. 返される内容]

{#NAnServDel-nowAnalSessionDidStart_S__table_otx_m2v_1qb}  
この例では、 NowAnalyticsServiceDelegate のデリゲートクラスを定義する方法を示します。

    import NowAnalytics

    // Initialize the Analytics SDK
    NowAnalytics.configure(for: URL(string: "https://my.instance.service-now.com")!)

    // Define a delegate class for NowAnalyticsServiceDelegate
    class NowAnalyticsDelegate: NowAnalytics.NowAnalyticsServiceDelegate {
      func nowAnalyticsSessionShouldStart() -> Bool {
        // Session is about to start, return true to allow session to start
        return true
      }

      func nowAnalyticsSessionDidStart(_ sessionId: String) {
        // Session was started
      }

      func nowAnalyticsSessionShouldEnd(_ sessionId: String) -> Bool {
        // Session is about to end, return true to allow session to end
        return true
      }

      func nowAnalyticsSessionDidEnd(_ sessionId: String) {
        // Session was ended
      }

      func nowAnalyticsDidDetectScreen(_ screenName: String) -> String? {
        // Example of skipping specific screen detection
        if (screenName == "LoginViewController") {
          return nil
        }

        // Example of appending a prefix for every screen detected
        return "MyApp_" + screenName
      }
    }

    // Register delegate
    private var analyticsDelegate = NowAnalyticsDelegate()  // Keep ref of delegate
    NowAnalytics.sharedAnalyticsService.setDelegate(analyticsDelegate)

## NowAnalyticsServiceDelegate:nowAnalyticsSessionShouldEnd( _ sessionId:文字列) {#ariaid-title5}

指定されたセッション の終了が近づいたときに通知します。
これは、指定されたセッションが終了する直前に呼び出されるコールバック関数です。
{#NAnServDel-nowAnalSessShouldEnd_S__table_lrd_pcv_1qb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| sessionId | 文字列 | チェックするセッションの一意の識別子。 |
[表 : 7. パラメーター]

{#NAnServDel-nowAnalSessShouldEnd_S__table_lrd_pcv_1qb} {#NAnServDel-nowAnalSessShouldEnd_S__table_mrd_pcv_1qb__entry__2}

| タイプ | 説明 |
|-|-|
| ブーリアン | セッションが終了していることを示すフラグ。 有効な値： * true:セッションを終了しています * false:セッションは終了していません |
[表 : 8. 返される内容]

{#NAnServDel-nowAnalSessShouldEnd_S__table_mrd_pcv_1qb}  
この例では、 NowAnalyticsServiceDelegate のデリゲートクラスを定義する方法を示します。

    import NowAnalytics

    // Initialize the Analytics SDK
    NowAnalytics.configure(for: URL(string: "https://my.instance.service-now.com")!)

    // Define a delegate class for NowAnalyticsServiceDelegate
    class NowAnalyticsDelegate: NowAnalytics.NowAnalyticsServiceDelegate {
      func nowAnalyticsSessionShouldStart() -> Bool {
        // Session is about to start, return true to allow session to start
        return true
      }

      func nowAnalyticsSessionDidStart(_ sessionId: String) {
        // Session was started
      }

      func nowAnalyticsSessionShouldEnd(_ sessionId: String) -> Bool {
        // Session is about to end, return true to allow session to end
        return true
      }

      func nowAnalyticsSessionDidEnd(_ sessionId: String) {
        // Session was ended
      }

      func nowAnalyticsDidDetectScreen(_ screenName: String) -> String? {
        // Example of skipping specific screen detection
        if (screenName == "LoginViewController") {
          return nil
        }

        // Example of appending a prefix for every screen detected
        return "MyApp_" + screenName
      }
    }

    // Register delegate
    private var analyticsDelegate = NowAnalyticsDelegate()  // Keep ref of delegate
    NowAnalytics.sharedAnalyticsService.setDelegate(analyticsDelegate)

## NowAnalyticsServiceDelegate:nowAnalyticsSessionShouldStart( _ sessionId: 文字列) {#ariaid-title6}

指定したセッションが開始しようとしているかどうかを通知します。
これは、指定されたセッションが開始される直前に呼び出されるコールバック関数です。
{#NAnServDel-nowAnalSessShouldStart_S__table_ojw_z1v_1qb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| sessionId | 文字列 | チェックするセッションの一意の識別子。 |
[表 : 9. パラメーター]

{#NAnServDel-nowAnalSessShouldStart_S__table_ojw_z1v_1qb} {#NAnServDel-nowAnalSessShouldStart_S__table_pjw_z1v_1qb__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 10. 返される内容]

{#NAnServDel-nowAnalSessShouldStart_S__table_pjw_z1v_1qb}  
この例では、 NowAnalyticsServiceDelegate のデリゲートクラスを定義する方法を示します。

    import NowAnalytics

    // Initialize the Analytics SDK
    NowAnalytics.configure(for: URL(string: "https://my.instance.service-now.com")!)

    // Define a delegate class for NowAnalyticsServiceDelegate
    class NowAnalyticsDelegate: NowAnalytics.NowAnalyticsServiceDelegate {
      func nowAnalyticsSessionShouldStart() -> Bool {
        // Session is about to start, return true to allow session to start
        return true
      }

      func nowAnalyticsSessionDidStart(_ sessionId: String) {
        // Session was started
      }

      func nowAnalyticsSessionShouldEnd(_ sessionId: String) -> Bool {
        // Session is about to end, return true to allow session to end
        return true
      }

      func nowAnalyticsSessionDidEnd(_ sessionId: String) {
        // Session was ended
      }

      func nowAnalyticsDidDetectScreen(_ screenName: String) -> String? {
        // Example of skipping specific screen detection
        if (screenName == "LoginViewController") {
          return nil
        }

        // Example of appending a prefix for every screen detected
        return "MyApp_" + screenName
      }
    }

    // Register delegate
    private var analyticsDelegate = NowAnalyticsDelegate()  // Keep ref of delegate
    NowAnalytics.sharedAnalyticsService.setDelegate(analyticsDelegate)


