NowAnalyticsServiceDelegate-Protokoll – iOS
Das NowAnalyticsServiceDelegate- Protokoll bietet Rückruffunktionen, die Informationen über das Starten und Beenden einer Benutzersitzung und die Erkennung von Bildschirmänderungen bereitstellen.
NowAnalyticsServiceDelegate – nowAnalyticsDidDetectScreen( _sessionId: String)
Benachrichtigt, wenn eine Bildschirmänderung erkannt wird. Der Bildschirmname wird in der Navigationsleiste erkannt. Wenn dies nicht möglich ist, ist dies der Unterklassenname viewController.
| Name | Typ | Beschreibung |
|---|---|---|
| screenName | Zeichenfolge | Name des Bildschirms, um zu erkennen, ob eine Änderung vorliegt. |
| Typ | Beschreibung |
|---|---|
| Zeichenfolge | Benutzerdefinierter Name, der zum Überschreiben des übergebenen screenName verwendet werden soll. |
Dieses Beispiel zeigt, wie eine Delegiertenklasse für NowAnalyticsServiceDelegatedefiniert wird.
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)
Benachrichtigt, wenn die angegebene Sitzung beendet wurde.
Dies ist eine Rückruffunktion, die aufgerufen wird, wenn die angegebene Sitzung tatsächlich beendet wird.
| Name | Typ | Beschreibung |
|---|---|---|
| sessionId | Zeichenfolge | Eindeutiger Bezeichner der zu überprüfenden Sitzung. |
| Typ | Beschreibung |
|---|---|
| Keine |
Dieses Beispiel zeigt, wie eine Delegiertenklasse für NowAnalyticsServiceDelegatedefiniert wird.
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: String)
Benachrichtigt, wenn die angegebene Sitzung gestartet wurde.
Dies ist eine Rückruffunktion, die aufgerufen wird, wenn die angegebene Sitzung tatsächlich beginnt.
| Name | Typ | Beschreibung |
|---|---|---|
| sessionId | Zeichenfolge | Eindeutiger Bezeichner der zu überprüfenden Sitzung. |
| Typ | Beschreibung |
|---|---|
| Boolean | Kennzeichnung, die angibt, dass die Sitzung gestartet wird. Gültige Werte:
|
Dieses Beispiel zeigt, wie eine Delegiertenklasse für NowAnalyticsServiceDelegatedefiniert wird.
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: String)
Benachrichtigt, wenn die angegebene Sitzung kurz vor dem Ende steht.
Dies ist eine Rückruffunktion, die aufgerufen wird, wenn die angegebene Sitzung kurz vor dem Ende steht.
| Name | Typ | Beschreibung |
|---|---|---|
| sessionId | Zeichenfolge | Eindeutiger Bezeichner der zu überprüfenden Sitzung. |
| Typ | Beschreibung |
|---|---|
| Boolean | Kennzeichnung, die angibt, dass die Sitzung beendet wird. Gültige Werte:
|
Dieses Beispiel zeigt, wie eine Delegiertenklasse für NowAnalyticsServiceDelegatedefiniert wird.
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: String)
Benachrichtigt, ob die angegebene Sitzung gerade gestartet wird.
Dies ist eine Rückruffunktion, die aufgerufen wird, wenn die angegebene Sitzung gerade gestartet wird.
| Name | Typ | Beschreibung |
|---|---|---|
| sessionId | Zeichenfolge | Eindeutiger Bezeichner der zu überprüfenden Sitzung. |
| Typ | Beschreibung |
|---|---|
| Keine |
Dieses Beispiel zeigt, wie eine Delegiertenklasse für NowAnalyticsServiceDelegatedefiniert wird.
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)