NowAnalyticsServiceDelegate 프로토콜 - iOS

  • 릴리스 버전: Washingtondc
  • 업데이트 날짜 2024년 02월 01일
  • 읽기12분
  • NowAnalyticsServiceDelegate 프로토콜은 사용자 세션의 시작과 종료 및 화면 변경 감지에 대한 정보를 제공하는 콜백 함수를 제공합니다.

    NowAnalyticsServiceDelegate - nowAnalyticsDidDetectScreen( _ sessionId: String)

    화면 변경이 감지되면 알립니다. 탐색 모음에서 화면 이름이 감지됩니다. 이것이 가능하지 않은 경우 viewController 서브 클래스 이름입니다.

    표 1. 매개변수
    이름 유형 설명
    화면 이름 문자열 변경 내용 여부를 탐지하는 화면의 이름입니다.
    표 2. 반환
    유형 설명
    문자열 전달된 screenName을 재정의하는 데 사용할 사용자 지정 이름입니다.

    이 예제에서는 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: String)

    지정된 세션이 종료되면 알림을 표시합니다.

    지정된 세션이 실제로 종료될 때 호출되는 콜백 함수입니다.

    표 3. 매개변수
    이름 유형 설명
    sessionId 문자열 확인할 세션의 고유 식별자입니다.
    표 4. 반환
    유형 설명
    없음

    이 예제에서는 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: 문자열)

    지정된 세션이 시작되면 알림을 표시합니다.

    지정된 세션이 실제로 시작될 때 호출되는 콜백 함수입니다.

    표 5. 매개변수
    이름 유형 설명
    sessionId 문자열 확인할 세션의 고유 식별자입니다.
    표 6. 반환
    유형 설명
    부울 세션이 시작되고 있음을 나타내는 플래그입니다.
    유효한 값은 다음과 같습니다.
    • true: 세션이 시작 중입니다.
    • false: 세션이 시작되지 않습니다.

    이 예제에서는 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: 문자열)

    지정된 세션 이 종료되려고 할 때 알림을 표시합니다.

    지정된 세션이 종료되려고 할 때 호출되는 콜백 함수입니다.

    표 7. 매개변수
    이름 유형 설명
    sessionId 문자열 확인할 세션의 고유 식별자입니다.
    표 8. 반환
    유형 설명
    부울 세션이 종료됨을 나타내는 플래그입니다.
    유효한 값은 다음과 같습니다.
    • true: 세션이 종료 중입니다.
    • false: 세션이 종료되지 않습니다.

    이 예제에서는 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: 문자열)

    지정된 세션이 시작되는지 여부를 알릴 수 있습니다.

    지정된 세션이 시작되려고 할 때 호출되는 콜백 함수입니다.

    표 9. 매개변수
    이름 유형 설명
    sessionId 문자열 확인할 세션의 고유 식별자입니다.
    표 10. 반환
    유형 설명
    없음

    이 예제에서는 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)