@@ -47,7 +47,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
47
47
// - initialize immediately with the given JSON datafile or its cached copy
48
48
// - no network delay, but the local copy is not guaranteed to be in sync with the server experiment settings
49
49
50
- initializeOptimizelySDKAsynchronous ( )
50
+ //// initializeOptimizelySDKAsynchronous()
51
+ //// initializeOptimizelySDKSynchronous()
52
+ initializeOptimizelySDKWithCustomization ( )
53
+
51
54
}
52
55
53
56
// MARK: - Initialization Examples
@@ -101,14 +104,32 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
101
104
102
105
// notification listeners
103
106
104
- _ = optimizely? . notificationCenter. addDecisionNotificationListener ( decisionListener: { ( type, userId, attributes, decisionInfo) in
107
+ _ = optimizely. notificationCenter. addDecisionNotificationListener ( decisionListener: { ( type, userId, attributes, decisionInfo) in
105
108
print ( " Received decision notification: \( type) \( userId) \( String ( describing: attributes) ) \( decisionInfo) " )
106
109
} )
107
110
108
- _ = optimizely? . notificationCenter. addTrackNotificationListener ( trackListener: { ( eventKey, userId, attributes, eventTags, event) in
111
+ _ = optimizely. notificationCenter. addTrackNotificationListener ( trackListener: { ( eventKey, userId, attributes, eventTags, event) in
109
112
print ( " Received track notification: \( eventKey) \( userId) \( String ( describing: attributes) ) \( String ( describing: eventTags) ) \( event) " )
110
113
} )
111
114
115
+ _ = optimizely. notificationCenter. addDatafileChangeNotificationListener ( datafileListener: { ( data) in
116
+ DispatchQueue . main. async {
117
+ #if os(iOS)
118
+ let alert = UIAlertView ( title: " Datafile change " , message: " something changed. " , delegate: nil , cancelButtonTitle: " cancel " )
119
+ alert. show ( )
120
+ #else
121
+ print ( " Datafile changed " )
122
+ #endif
123
+ }
124
+
125
+ if let controller = self . window? . rootViewController as? VariationViewController {
126
+ //controller.showCoupon = toggle == FeatureFlagToggle.on ? true : false;
127
+ if let showCoupon = try ? self . optimizely. isFeatureEnabled ( featureKey: " show_coupon " , userId: self . userId) {
128
+ controller. showCoupon = showCoupon
129
+ }
130
+ }
131
+ } )
132
+
112
133
// initialize SDK
113
134
114
135
optimizely!. initializeSDK { result in
0 commit comments