# Enabling the bot link feature with the SDK

You can display an option to add the LINE Official Account as a friend when a user logs in to your app. This is called the bot link feature. Developers can specify the LINE Official Account to be added as a friend.

Before getting started with the configuration, see Add a LINE Official Account as a friend when logged in (bot link) in the LINE Login documentation to understand the bot link feature and the following specifics:

  • Linking a LINE Official Account with your channel on the LINE Developers Console
  • The bot prompt parameter sent to the LINE Platform and its behavior
  • The friendship status flag returned from the LINE Platform and its meaning

This topic explains how to enable these bot link functions with the LINE SDK:

# Setting the bot prompt parameter in the login request

The following sample code shows how to set the botPrompt property of the LineSDKLogin object in the login request:

// Includes an option to add a LINE Official Account as a friend on the consent screen.
[LineSDKLogin sharedInstance].botPrompt = LineSDKBotPromptNormal;

// Opens a new screen to add the LINE Official Account as a friend after the user agrees to the permissions on the consent screen.
[LineSDKLogin sharedInstance].botPrompt = LineSDKBotPromptAggressive;

For more information about the return values, see LineSDKBotPrompt in the LINE SDK for iOS Objective-C reference.

# Checking the friendship status between the user and the LINE Official Account

You can check the friendship status between the user and the LINE Official Account using the following methods.

# Check the friendshipStatusChanged property in the login response

After successful login, the friendshipStatusChanged property of the LineSDKCredential object contains a boolean value that indicates whether the friendship status has changed.

The following conditions must be met to get the friendship status flag:

  • The bot prompt option is specified in the login request.
  • The consent screen with the option to add your LINE Official Account as a friend is displayed to the user.

The following sample code shows how to get the friendshipStatusChanged property.

// In the didLogin delegate method
- (void)didLogin:(LineSDKLogin *)login
      credential:(LineSDKCredential *)credential
         profile:(LineSDKProfile *)profile
           error:(NSError *)error
{
    BOOL statusChanged = [credential.friendshipStatusChanged boolValue];
}

For more information about the friendshipStatusChanged property, see friendshipStatusChanged in the LINE SDK for iOS Objective-C reference.

# Use LINE Login to get friendship status

Call the getBotFriendshipStatusWithCompletion method after the user has logged in to your app and an access token has been returned.

[self.apiClient getBotFriendshipStatusWithCompletion:^(LineSDKBotFriendshipStatusResult * _Nullable result, NSError * _Nullable error) {
    BOOL flag = result.friendFlag;
}];

For more information about the return values, see -getBotFriendshipStatusWithCompletion: in the LINE SDK for iOS Objective-C reference.