Protocolo NowAnalyticsServiceDelegate - iOS
. NowAnalyticsServiceDelegate o protocolo fornece funções de retorno de chamada que fornecem informações sobre o início e o término de uma sessão do usuário e a detecção de mudança de tela.
NowAnalyticsServiceDelegate - nowAnalyticsDidDetectScreen( _ SessionID: Cadeia de caracteres)
Notifica quando uma mudança de tela é detectada. O nome da tela é detectado na barra de navegação. Se isso não for possível, será o nome da subclasse ViewController.
| Nome | Tipo | Descrição |
|---|---|---|
| Nome de tela | Cadeia de caracteres | Nome da tela para detectar se há alguma mudança. |
| Tipo | Descrição |
|---|---|
| Cadeia de caracteres | Nome personalizado a ser usado para substituir o nome de tela aprovado. |
Este exemplo mostra como definir uma classe de delegado para 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: Cadeia de caracteres)
Notifica quando a sessão especificada foi encerrada.
Esta é uma função de retorno de chamada que é chamada quando a sessão especificada realmente termina.
| Nome | Tipo | Descrição |
|---|---|---|
| sessionId | Cadeia de caracteres | Identificador exclusivo da sessão a ser verificada. |
| Tipo | Descrição |
|---|---|
| Nenhum(a) |
Este exemplo mostra como definir uma classe de delegado para 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: Cadeia de caracteres)
Notifica quando a sessão especificada é iniciada.
Esta é uma função de retorno de chamada que é chamada quando a sessão especificada realmente é iniciada.
| Nome | Tipo | Descrição |
|---|---|---|
| sessionId | Cadeia de caracteres | Identificador exclusivo da sessão a ser verificada. |
| Tipo | Descrição |
|---|---|
| Booliano | Sinalizador que indica que a sessão está sendo iniciada. Valores válidos:
|
Este exemplo mostra como definir uma classe de delegado para 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: Cadeia de caracteres)
Notifica quando a sessão especificada está prestes a terminar
Esta é uma função de retorno de chamada que é chamada quando a sessão especificada está prestes a terminar
| Nome | Tipo | Descrição |
|---|---|---|
| sessionId | Cadeia de caracteres | Identificador exclusivo da sessão a ser verificada. |
| Tipo | Descrição |
|---|---|
| Booliano | Sinalizador que indica que a sessão está sendo encerrada . Valores válidos:
|
Este exemplo mostra como definir uma classe de delegado para 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: Cadeia de caracteres)
Notifica se a sessão especificada está prestes a iniciar.
Esta é uma função de retorno de chamada que é chamada quando a sessão especificada está prestes a iniciar.
| Nome | Tipo | Descrição |
|---|---|---|
| sessionId | Cadeia de caracteres | Identificador exclusivo da sessão a ser verificada. |
| Tipo | Descrição |
|---|---|
| Nenhum(a) |
Este exemplo mostra como definir uma classe de delegado para 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)