Advertisement
Guest User

Yandex AppMetrica Profiles iOS Example

a guest
Jul 23rd, 2018
964
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void example()
  2. {
  3.     YMMMutableUserProfile *profile = [[YMMMutableUserProfile alloc] init];
  4.     id<YMMCustomCounterAttribute> timeLeftAttribute = [YMMProfileAttribute customCounter:@"time_left"];
  5.     [profile apply:[timeLeftAttribute withDelta:4.42]];
  6.     [profile applyFromArray:@[
  7.         [[YMMProfileAttribute customString:@"name"] withValue:@"Jack"],
  8.         [[YMMProfileAttribute customString:@"born_in"] withValueIfUndefined:@"Moscow"],
  9.         [[YMMProfileAttribute customString:@"address"] withValueReset],
  10.         [[YMMProfileAttribute customNumber:@"age"] withValue:24],
  11.         [[YMMProfileAttribute customNumber:@"birth_year"] withValueIfUndefined:1991],
  12.         [[YMMProfileAttribute customNumber:@"height"] withValueReset],
  13.         [[YMMProfileAttribute customCounter:@"logins_count"] withDelta:1],
  14.         [[YMMProfileAttribute customBool:@"has_premium"] withValue:YES],
  15.         [timeLeftAttribute withDelta:-8.23],
  16.         [[YMMProfileAttribute name] withValue:@"Jack Smith"],
  17.         [[YMMProfileAttribute gender] withValue:YMMGenderTypeMale],
  18.         [[YMMProfileAttribute birthDate] withAge:23],
  19.         [[YMMProfileAttribute notificationsEnabled] withValue:NO],
  20.     ]];
  21.  
  22.     [YMMYandexMetrica setUserProfileID:@"jack23"];
  23.     [YMMYandexMetrica reportUserProfile:[profile copy] onFailure:^(NSError *error) {
  24.         NSLog(@"Error: %@", error);
  25.     }];
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement