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