Developers » AS2 tagging » Apple » Advanced features » Sending hits according to the application state
Sending hits according to the application state
- iOS
- watchOS
- tvOS
Foreword
The Internet AT SDK allows you to condition the sending of hits, depending on the application state (Active, Inactive, other).
The SDK has a configuration key “sendOnApplicationState” which can take different values:
- “activeOnly”: to send hits when the application is in active mode only.
- “activeOrInactive”: to send hits when the application is in active or inactive mode.
- “all” (default value): to send hits without considering the application state.
Tagging examples
The settings can be changed in the application code via the dedicated helper “setSendOnApplicationState” or via the “setConfig” configuration update method.
The “setSendOnApplicationState” helper is only available on Swift.
Using the 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)
Using the configuration update method:
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];