Working with Activity Likes

Like Post

To like or dislike activity post or comment, do next:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
BOOL setLiked = YES;
GetSocial likeActivityWithId:activityId
                     isLiked:setLiked
                     success:^(GetSocialActivityPost *post) {
                          NSLog(@"Successfully like an activity");
                          // You can check if activity is liked by calling
                          // BOOL isLiked = post.isLikedByMe;
                     } failure:^(NSError *error) {
                         NSLog(@"Failed to like an activity, error: %@", error);
                     }];

If you want to unlike activity, pass NO as parameter setLiked.

We handle data consistency, so if you’re trying to like already liked the activity, or dislike not liked the activity, an operation will call successful callback without any changes.

GetSocial UI

Activity is liked/unliked when user presses Like button.

List of Post Likes

To get a list of users, who liked an activity:

1
2
3
4
5
6
7
8
9
[GetSocial activityLikers:activityId
                   offset:offset
                    limit:limit
                  success:^(NSArray<GetSocialPublicUser *> *users) {
                      NSLog(@"Successfully retrieved a list of users who liked an activity.");
                      [self showUsersList:users];
                  } failure:^(NSError *error) {
                     NSLog(@"Failed to retrieve likers list, error: %@", error);
                  }];

Where offset and limit is pagination parameters, for example, to get first 50 users, who liked a post, use offset=0 and limit=50, to get next page - offset=50, limit=50 etc.

GetSocial UI

Likers list is displayed after user pressed on likes count:


GetSocial Activity Likes View

Give us your feedback! Was this article helpful?

😀 🙁