Protocolo NowAnalyticsServiceDelegate - iOS
O protocolo NowAnalyticsServiceDelegate fornece funções de retorno de chamada que fornecem informações sobre o início e o término de uma sessão de usuário e 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 |
|---|---|---|
| screenName | 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 screenName passado. |
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 termina.
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á terminando. 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)