Envoi des hits en fonction de l’état de l’application

  • iOS
  • watchOS
  • tvOS
 

Avant-propos

Le SDK AT Internet permet de conditionner l’envoi des hits, en fonction de l’état de l’application (Active, Inactive, autre).

Le SDK dispose pour cela d’une clé de configuration « sendOnApplicationState » pouvant prendre différentes valeurs :

  • « activeOnly » : pour envoyer les hits lorsque l’application est dans un mode actif seulement,
  • « activeOrInactive » : pour envoyer les hits lorsque l’application est dans un mode actif ou inactif,
  • « all » (valeur par défaut) : pour envoyer les hits sans considérer l’état de l’application.
 

Exemples de marquage

Le paramétrage peut être modifié dans le code de l’application via le helper dédié « setSendOnApplicationState » ou encore via la méthode de mise à jour de la configuration « setConfig ».

Le helper « setSendOnApplicationState » est seulement disponible en Swift.

Utilisation du helper :

let tracker = ATInternet.sharedInstance.defaultTracker

// Send hits without considering application state
tracker.setSendOnApplicationState(SendApplicationState.all, sync: true, completionHandler: nil)

// Send hits when application is active only
tracker.setSendOnApplicationState(SendApplicationState.activeOnly, sync: true, completionHandler: nil)

// Send hits when application is active or inactive
tracker.setSendOnApplicationState(SendApplicationState.activeOrInactive, sync: true, completionHandler: nil)

Utilisation de la méthode de mise à jour de la configuration :


let tracker = ATInternet.sharedInstance.defaultTracker

// Send hits without considering application state
tracker.setConfig("sendOnApplicationState", value: "all", sync: true, completionHandler: nil)

// Send hits when application is active only
tracker.setConfig("sendOnApplicationState", value: "activeOnly", sync: true, completionHandler: nil)

// Send hits when application is active or inactive
tracker.setConfig("sendOnApplicationState", value: "activeOrInactive", sync: true, completionHandler: nil)

Tracker* tracker = [ATInternet sharedInstance].defaultTracker; 

// Send hits without considering application state
[tracker setConfig:@"sendOnApplicationState" value:@"all" sync:YES completionHandler:nil];

// Send hits when application is active only 
[tracker setConfig:@"sendOnApplicationState" value:@"activeOnly" sync:YES completionHandler:nil]; 

// Send hits when application is active or inactive 
[tracker setConfig:@"sendOnApplicationState" value:@"activeOrInactive" sync:YES completionHandler:nil];

Dernière mise à jour : 17/12/2018