1. Documents
  2. iOS SDK

Getting user profiles

You can use the iOS SDK to get a user’s LINE profile information. User profiles include a user’s user ID, display name, profile media (image or video), and status message.

Before you begin

Make sure you have completed the following:

Getting user profiles

To get a user’s LINE profile information, call the getProfileWithCompletion method. If the call succeeds the user’s profile information is returned in the profile argument. If the API call fails, the error argument is a non-nil value. You can use the error argument to get an error code and description.

The following is an example of how to save the user profile information into NSStrings.

[apiClient getProfileWithCompletion:^(LineSDKProfile * _Nullable profile, NSError * _Nullable error) {
        NSLog(@"Error getting profile: %@", error.description);
    } else {
        LineSDKProfile * profileInformation = profile;
        NSString * displayName = profileInformation.displayName;
        NSString * userID = profileInformation.userID;
        NSString * statusMessage = profileInformation.statusMessage;
        NSURL * pictureURL = profileInformation.pictureURL;
        NSString * pictureUrlString
        // If the user does not have a profile picture set, pictureURL will be nil
            NSString * profilePictureUrlString = profilePictureURL.absoluteString;

Executing the completion block in a different queue

getProfileWithCompletion executes its completion block in the main queue. To execute the completion block in a different queue, specify the queue by calling the getProfileWithCallbackQueue method.

[apiClient getProfileWithCallbackQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)
    completion:^(LineSDKProfile * _Nullable profile, NSError * _Nullable error) {

Handling errors

The following HTTP response codes and messages are returned when an API is called.

HTTP Status Description
200 OK Request successful
400 Bad Request Problem with the request. Check the request parameters and JSON format.
401 Unauthorized Check that the authorization header is correct.
403 Forbidden Not authorized to use the API. Confirm that your account or plan is authorized to use the API.
429 Too Many Requests Make sure that you are within the rate limits for requests.
500 Internal Server Error Temporary error on the API server.

Related pages

For more information on using the iOS SDK, see the following pages.