# Integrating LINE Login with your iOS app

Once you install the SDK and configure your project, you can start leveraging LINE Login to improve your app's user experience.

# Importing the LineSDK header file

Import the LineSDK.h file to all files where the LINE SDK is used.

#import <LineSDK/LineSDK.h>

# Performing a login process

To let the user log in to your iOS app, you can create a LINE-branded login button to take the user through the login process.

There are two methods to perform a login process.

# Use the LINE SDK's built-in login button

The LINE SDK for iOS Objective-C provides a predefined login button. The LineSDKLoginButton class follows the style recommended in the LINE Login button design guidelines. You can add a login button to the user interface of your app to provide your users with a quick way to log in.

To add a login button to your view hierarchy, take the following steps:

  1. Create a LineSDKLoginButton object.
  2. Set up the LineSDKLoginButton object's delegate and permissions properties.
  3. Add the LineSDKLoginButton object.

The code should look as below:

@interface LoginViewController() <LineSDKLoginButtonDelegate>

@implementation LoginViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    LineSDKLoginButton *loginBtn = [[LineSDKLoginButton alloc] init];
    loginBtn.delegate = self;
    loginBtn.permissions = @[@"profile", @"openid", @"email"];

    [self.view addSubview:loginBtn];
    // ... additional setup for login button layout



When your user taps the login button, the user will be authenticated with proper login flow: if the user has LINE installed on the device, your app retrieves the user’s LINE credentials from LINE to perform authentication. Otherwise, the user is redirected to the LINE Login dialog on their browser and prompted for their LINE credentials.

To receive the login state, implement the related delegate methods of the LineSDKLoginButtonDelegate protocol as below:

@implementation LoginViewController

// ...

- (void)loginButton:(LineSDKLoginButton *)button didFailLoginWithError:(nullable NSError *)error
    NSLog(@"Error, %@", error);

- (void)loginButton:(LineSDKLoginButton *)button
 didSucceedLoginWithCredential:(nullable LineSDKCredential *)credential
            profile:(nullable LineSDKProfile *)profile
    NSString *result = [NSString stringWithFormat:@"Result : %@ \n %@", credential, profile];
    NSLog(@"Login Success: %@", result);


When the login process finishes, either of the delegate methods is invoked with the login result.

# Use your own code

Instead of using the default login button, you can also customize your user interface and login process with your own code.

# Setting the LINE Login delegate to handle the login results

To listen for and handle the results of the login process, you need to first set the delegate as the view controller where you want to receive the login results. Once you get the results after the user logs in, you can extract and store the user’s access token, user ID, and user profile information in NSStrings. The user profile includes the user’s display name, status message, and profile picture URL.

  1. Set the delegate in the view’s viewDidLoad method.

    - (void)viewDidLoad {
        [super viewDidLoad];
        // Set the LINE Login Delegate
        [LineSDKLogin sharedInstance].delegate = self;
  2. To handle the login result and store the data, use the didLogin method of the LineSDKLoginDelegate protocol.

    #pragma mark LineSDKLoginDelegate
    - (void)didLogin:(LineSDKLogin *)login
        credential:(LineSDKCredential *)credential
            profile:(LineSDKProfile *)profile
            error:(NSError *)error
        if (error) {
            // Login failed with an error. Use the error parameter to identify the problem.
            NSLog(@"Error: %@", error.localizedDescription);
        else {
            // Login success. Extracts the access token, user profile ID, display name, status message, and profile picture.
            NSString * accessToken = credential.accessToken.accessToken;
            NSString * userID = profile.userID;
            NSString * displayName = profile.displayName;
            NSString * statusMessage = profile.statusMessage;
            NSURL * pictureURL = profile.pictureURL;
            NSString * pictureUrlString;
            // If the user doesn't have a profile picture set, pictureURL will be nil
            if (pictureURL) {
                pictureUrlString = profile.pictureURL.absoluteString;

    You can get the following information from the parameters from the didLogin method.

    Parameter Description
    credential Contains the user’s access token.
    profile Contains the user’s profile information.
    error Contains login error information. This is nil if the login succeeds.

# Logging in with code

To log in with code, call the startLogin method. The callback function gets the [LineSDKLogin sharedInstance] common instance and the results are handled in the methods of the LineSDKLoginDelegate protocol defined above.

- (IBAction)startLogin:(id)sender {
    NSLog(@"Button pressed: %@");
    [[LineSDKLogin sharedInstance] startLoginWithPermissions:@[@"profile", @"friends", @"groups"]];

For how to design your login interface, see LINE Login button design guidelines where you can also download the LINE Login button images.

# Note for users upgrading from the LINE SDK 4.x for iOS

When you call the startLoginWithPermissions method, make sure to specify the permissions parameter. Otherwise, the LINE Platform returns this error:

Error Domain=LineSDKInternalErrorDomain Code=1 "'scope' is not specified." UserInfo={NSLocalizedDescription='scope' is not specified.}

"Scope" in the error message means "permissions" in the LINE SDK for iOS Objective-C. For more information about the startLoginWithPermissions method, see -startLoginWithPermissions: in the LINE SDK for iOS Objective-C reference.

# Initializing the LineSDKAPI object

The LINE Platform is called through a LineSDKAPI instance. To call the LINE Platform, initialize the LineSDKAPI object.

apiClient = [[LineSDKAPI alloc] initWithConfiguration:[LineSDKConfiguration defaultConfig]];