NowAnalyticsServiceDelegate プロトコル - iOS
NowAnalyticsServiceDelegate プロトコルは、ユーザー セッションの開始と終了に関する情報と画面変更の検出を提供するコールバック関数を提供します。
NowAnalyticsServiceDelegate:nowAnalyticsDidDetectScreen( _ sessionId:文字列)
画面の変更が検出されたときに通知します。画面名はナビゲーションバーから検出されます。それが不可能な場合は、viewControllerサブクラス名です。
| 名前 | タイプ | Description (説明) |
|---|---|---|
| スクリーン名 | 文字列 | 変更があるかどうかを検出する画面の名前。 |
| タイプ | 説明 |
|---|---|
| 文字列 | 渡された 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)