Promoted.ai provides an iOS logging library for gathering metrics and training delivery systems. This library contains the functionality required to track events in your iOS app and deliver them efficiently to Promoted.ai backends.
Our client library is available for iOS 11+, and works with both Swift and Objective-C apps.
Special thanks to Wendy Lu for expert review.
Pursuant to Apple's app privacy questions, Promoted's logging library collects the following kinds of data:
This data is used for the following purposes:
[1] This linkage can be easily broken if the user wants to be forgotten.
Our client library is built on a number of proven technologies:
Our client library is available via the following channels. You will receive instructions on how to integrate via the channel you choose.
Your app controls the initialization and behavior of our client library through the following classes:
MetricsLoggingService
configures the behavior and initialization of the library.MetricsLogger
accepts log messages to send to the server.ImpressionTracker
tracks impressions of content in a collection view.Initialization of the library is lightweight and mostly occurs in the background, and does not impact app startup performance.
Example usage (singleton):
// In your AppDelegate:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions...) -> Bool {
let config = ClientConfig()
config.metricsLoggingURL = "..."
config.metricsLoggingAPIKey = "..."
MetricsLoggingService.startServices(initialConfig: config)
let loggingService = MetricsLoggingService.sharedService
self.logger = loggingService.metricsLogger
return true
}
Example usage (dependency injection):
// In your AppDelegate:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions...) -> Bool {
let config = ClientConfig()
config.metricsLoggingURL = "..."
config.metricsLoggingAPIKey = "..."
self.service = MetricsLoggingService(initialConfig: config)
self.service.startLoggingServices()
self.logger = service.metricsLogger
return true
}
Handling user sign-in:
// Handling user sign-in/sign-out:
func userDidSignInWithID(_ userID: String) {
self.logger.startSessionAndLogUser(userID: userID);
}
func userDidSignOut() {
self.logger.startSessionAndLogSignedOutUser()
}
MetricsLogger
batches log messages to avoid wasteful network traffic that would affect battery life. It also provides hooks into the app’s life cycle to ensure delivery of client logs.
For UICollectionViews
and other scroll views, we can track the appearance and disappearance of individual cells for fine-grained impression logging. We provide ImpressionTracker
, a solution that hooks into most UICollectionView
s and UIViewController
s easily.
Example usage with UICollectionView:
class MyViewController: UIViewController {
var collectionView: UICollectionView
var impressionTracker: ImpressionTracker
func viewWillDisappear(_ animated: Bool) {
impressionTracker.collectionViewDidHideAllContent()
}
func collectionView(_ collectionView: UICollectionView,
willDisplay cell: UICollectionViewCell,
forItemAt indexPath: IndexPath) {
let content = contentFor(indexPath: indexPath)
impressionTracker.collectionViewWillDisplay(content: content)
}
func collectionView(_ collectionView: UICollectionView,
didEndDisplaying cell: UICollectionViewCell,
forItemAt indexPath: IndexPath) {
let content = contentFor(indexPath: indexPath)
impressionTracker.collectionViewDidHide(content: content)
}
func reloadCollectionView() {
collectionView.reloadData()
let visibleContent = collectionView.indexPathsForVisibleItems.map {
contentFor(indexPath: $0)
}
impressionTracker.collectionViewDidChangeVisibleContent(visibleContent)
}
}
link |
Stars: 4 |
Last commit: 4 days ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics