Enabling the bot link feature with the SDK

By linking your LINE official account with your LINE Login channel, 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.

Before getting started with the configuration, see Linking a LINE official account with your LINE Login channel in the LINE Login guide to understand the bot link feature and the following specifics:

  • Linking a LINE official account with your channel on the 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 parameter when using the LoginButton widget.

...
LoginButton loginButton = rootView.findViewById(R.id.line_login_btn);

loginButton.setAuthenticationParams(new LineAuthenticationParams.Builder()
        .scopes(Arrays.asList(Scope.PROFILE))
        .botPrompt(BotPrompt.normal) // configure it here
        .build()
);
...

The following sample code shows how to set the botPrompt parameter when using the LoginApi.getLoginIntent() method.

Intent loginIntent = LineLoginApi.getLoginIntent(
    view.getContext(), 
    Constants.CHANNEL_ID, 
    new LineAuthenticationParams.Builder()
            .scopes(Arrays.asList(Scope.PROFILE))
            .botPrompt(BotPrompt.normal) // configure it here
            .build());

startActivityForResult(loginIntent, REQUEST_CODE);

For more information about the parameter values, see LineAuthenticationParams.BotPrompt in the LINE SDK for Android 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 LineLoginResult object in the login response

After successful login, the LineLoginResult object contains a boolean value that indicates whether the friendship status has changed. You can get the value with the getFriendshipStatusChanged() method.

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

  • The botPrompt parameter is specified with the LineAuthenticationParams object 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 friendship status from the LineLoginResult object.

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    ...

    LineLoginResult result = LineLoginApi.getLoginResultFromIntent(data);

    boolean friendshipStatusChanged = result.getFriendshipStatusChanged();

    ...
}

For more information about the return values, see getFriendshipStatusChanged() in the LINE SDK for Android reference.

Use the Social API to get friendship status

Call the LineApiClient.getFriendshipStatus() method after the user has logged in to your app and an access token has been returned.

boolean isFriendToTheBot = lineApiClient.getFriendshipStatus();

For more information about the return values, see getFriendshipStatus() in the LINE SDK for Android reference.

{{ $t("form.question.helpful") }}

{{ $t("form.question.detail") }}

{{ $t("form.question.improve") }}

{{ $t("form.info.start") }}{{ $t("form.info.link") }}{{ $t("form.info.end") }}


{{ $t("form.result.success") }}
{{ $t("form.result.error") }}
{{ $t("form.result.errorLink") }}