Skip to content

Instantly share code, notes, and snippets.

@timelincoln7648
Last active January 17, 2020 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timelincoln7648/bceed334b374fab582060dd27654a01c to your computer and use it in GitHub Desktop.
Save timelincoln7648/bceed334b374fab582060dd27654a01c to your computer and use it in GitHub Desktop.
function to add notification listeners to the Optimizely client
func addListeners() {
let notificationCenter = optimizely.notificationCenter
//notification fired when a value is returned by isFeatureEnabled function call
_ = notificationCenter?.addDecisionNotificationListener(decisionListener: { (type, userId, attributes, decisionInfo) in
print("Received decision notification: \(type) \(userId) \(String(describing: attributes)) \(decisionInfo)")
})
//notification fired when SDK polls for a new datafile and the datafile has changed
_ = notificationCenter?.addDatafileChangeNotificationListener(datafileListener: { (_) in
print("data file did change!")
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment