Steps for A/B Testing Caffeine
Applying Caffeine to a percentage of user-sessions is supported. Because of a desire to change this percentage without submitting an update to the app store, this percentage value lives on a remote file that we control. The default value is 100%, so assuming a request is allowed and your license file is valid it will flow through Caffeine.
To change this percentage, please email our engineers at help@caffei.net
Determining whether Caffeine is enabled on the current session
Upon the start of every session, a notification whose name is stored as CaffeineHTTPProxy.caffeineInformationStringNotificationKey
is posted to the default notification center. Within the notification's userInfo is a boolean value keyed by the same string-value as the notification name (right above) indicating whether or not Caffeine is enabled for the current session.
An Example View Controller
Swift 3:
import UIKit
import Proxeine
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(receivedCaffeineNotification(aNotification:)), name: NSNotification.Name(rawValue: CaffeineHTTPProxy.caffeineInformationStringNotificationKey), object: nil)
}
// Our method to receive the Caffeine notification
func receivedCaffeineNotification(aNotification: NSNotification) {
if aNotification.name.rawValue == CaffeineHTTPProxy.caffeineInformationStringNotificationKey {
if let usingCaffeine = aNotification.userInfo?[CaffeineHTTPProxy.caffeineInformationStringNotificationKey] as? Bool {
// 'usingCaffeine` now tracks whether Caffeine is enabled for this SESSION
// You can log this value with your analytics service
}
}
}
deinit {
NotificationCenter.default.removeObserver(self)
}
}
Your method for receiving the Notification
can of course be anywhere in your project, but we strongly recommend adding the observer from within application:didFinishLaunchingWithOptions:
If at any time you require help, please contact our engineers at help@caffei.net. They're more than happy to help!