@@ -169,11 +169,17 @@ For details, see the [CMAB documentation](https://docs.developers.optimizely.com
169169ODP enables Advanced Audience Targeting:
170170
171171``` csharp
172- // Fetch user segments
172+ // Synchronous fetch
173173var user = optimizely .CreateUserContext (" user123" );
174- await user .FetchQualifiedSegments ();
174+ bool success = user .FetchQualifiedSegments ();
175175var decision = user .Decide (" personalized_feature" );
176176
177+ // Asynchronous fetch with callback
178+ var task = user .FetchQualifiedSegments ((success ) =>
179+ {
180+ Console .WriteLine ($" Segments fetched: {success }" );
181+ });
182+
177183// Send custom events
178184optimizely .SendOdpEvent (
179185 action : " purchase_completed" ,
@@ -290,11 +296,16 @@ var optimizely = OptimizelyFactory.NewDefaultInstance();
290296### Notification Listeners
291297
292298``` csharp
299+ // Define a decision callback method
300+ void OnDecision (string type , string userId , UserAttributes userAttributes , Dictionary < string , object > decisionInfo )
301+ {
302+ Console .WriteLine ($" Decision type: {type }, User: {userId }" );
303+ }
304+
305+ // Subscribe to decision notifications
293306optimizely .NotificationCenter .AddNotification (
294307 NotificationCenter .NotificationType .Decision ,
295- (DecisionNotification notification ) => {
296- Console .WriteLine ($" Decision: {notification .Type }" );
297- }
308+ OnDecision
298309);
299310```
300311
@@ -307,8 +318,17 @@ Implement `UserProfileService` for sticky bucketing:
307318``` csharp
308319public class MyUserProfileService : UserProfileService
309320{
310- public UserProfile Lookup (string userId ) { /* ... */ }
311- public void Save (UserProfile userProfile ) { /* ... */ }
321+ public Dictionary <string , object > Lookup (string userId )
322+ {
323+ // Retrieve user profile from your database
324+ return GetUserProfileFromDatabase (userId );
325+ }
326+
327+ public void Save (Dictionary <string , object > userProfile )
328+ {
329+ // Save user profile to your database
330+ SaveUserProfileToDatabase (userProfile );
331+ }
312332}
313333```
314334
0 commit comments