Protocole NowAnalyticsServiceDelegate : iOS
Le protocole NowAnalyticsServiceDelegate fournit des fonctions de rappel qui fournissent des informations sur le démarrage et la fin d’une session utilisateur et la détection des changements d’écran.
NowAnalyticsServiceDelegate : nowAnalyticsDidDetectScreen( _ sessionId : chaîne)
Notifie lorsqu’un changement d’écran est détecté. Le nom de l’écran est détecté à partir de la barre de navigation. Si ce n’est pas possible, c’est le nom de la sous-classe viewController.
| Nom | Type | Description |
|---|---|---|
| screenName | Chaîne | Nom de l’écran permettant de détecter s’il y a un changement. |
| Type | Description |
|---|---|
| Chaîne | Nom personnalisé à utiliser pour remplacer le screenName transmis. |
Cet exemple montre comment définir une classe de délégué pour 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 : chaîne)
Notifie lorsque la session spécifiée est terminée.
Il s’agit d’une fonction de rappel qui est appelée lorsque la session spécifiée se termine réellement.
| Nom | Type | Description |
|---|---|---|
| sessionId | Chaîne | Identificateur unique de la session à vérifier. |
| Type | Description |
|---|---|
| Aucun |
Cet exemple montre comment définir une classe de délégué pour 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 : chaîne)
Notifie lorsque la session spécifiée a démarré.
Il s’agit d’une fonction de rappel qui est appelée lorsque la session spécifiée démarre réellement.
| Nom | Type | Description |
|---|---|---|
| sessionId | Chaîne | Identificateur unique de la session à vérifier. |
| Type | Description |
|---|---|
| Booléen | Marqueur qui indique que la session est en cours de démarrage. Valeurs valides :
|
Cet exemple montre comment définir une classe de délégué pour 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 : chaîne)
Notifie quand la session spécifiée est sur le point de se terminer.
Il s’agit d’une fonction de rappel qui est appelée lorsque la session spécifiée est sur le point de se terminer.
| Nom | Type | Description |
|---|---|---|
| sessionId | Chaîne | Identificateur unique de la session à vérifier. |
| Type | Description |
|---|---|
| Booléen | Marqueur indiquant que la session se termine. Valeurs valides :
|
Cet exemple montre comment définir une classe de délégué pour 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 : chaîne)
Notifie si la session spécifiée est sur le point de commencer.
Il s’agit d’une fonction de rappel qui est appelée lorsque la session spécifiée est sur le point de démarrer.
| Nom | Type | Description |
|---|---|---|
| sessionId | Chaîne | Identificateur unique de la session à vérifier. |
| Type | Description |
|---|---|
| Aucun |
Cet exemple montre comment définir une classe de délégué pour 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)