NowAnalyticsServiceDelegate 프로토콜 - iOS
NowAnalyticsServiceDelegate 프로토콜은 사용자 세션의 시작 및 종료와 화면 변경 감지에 대한 정보를 제공하는 콜백 함수를 제공합니다.
NowAnalyticsServiceDelegate - nowAnalyticsDidDetectScreen( _ sessionId: String)
화면 변경이 감지되면 알립니다. 탐색 모음에서 화면 이름이 감지됩니다. 이것이 가능하지 않은 경우 viewController 하위 클래스 이름입니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| screenName | 문자열 | 변경 사항이 있는지 여부를 감지하는 화면의 이름입니다. |
| 유형 | 설명 |
|---|---|
| 문자열 | 전달된 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: 문자열)
지정된 세션이 종료되었을 때 알립니다.
지정된 세션이 실제로 종료될 때 호출되는 콜백 함수입니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| sessionId | 문자열 | 확인할 세션의 고유 식별자입니다. |
| 유형 | 설명 |
|---|---|
| 안 함 |
이 예시에서는 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: 문자열)
지정된 세션이 시작된 경우 알립니다.
지정된 세션이 실제로 시작될 때 호출되는 콜백 함수입니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| sessionId | 문자열 | 확인할 세션의 고유 식별자입니다. |
| 유형 | 설명 |
|---|---|
| 부울 | 세션이 시작 중임을 나타내는 플래그입니다. 유효한 값은 다음과 같습니다.
|
이 예시에서는 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: 문자열)
지정된 세션이 종료되려고 할 때 알립니다.
지정된 세션이 종료되려고 할 때 호출되는 콜백 함수입니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| sessionId | 문자열 | 확인할 세션의 고유 식별자입니다. |
| 유형 | 설명 |
|---|---|
| 부울 | 세션이 종료되고 있음을 나타내는 플래그입니다. 유효한 값은 다음과 같습니다.
|
이 예시에서는 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: 문자열)
지정된 세션이 시작되는지 여부를 알 수 있습니다.
지정된 세션이 시작되려고 할 때 호출되는 콜백 함수입니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| sessionId | 문자열 | 확인할 세션의 고유 식별자입니다. |
| 유형 | 설명 |
|---|---|
| 안 함 |
이 예시에서는 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)