- Overview
- Trying the starter app
- Integrating LINE Login
- Enabling the bot link feature with the SDK
- Managing users
- Managing access tokens
- Handling errors
- LINE SDK v5 for Android reference
- Overview
- Trying LINE Login
- Integrating LINE Login
- Logging out users
- Getting user profiles
- Managing access tokens
- LINE SDK v4.0 for Android reference
- LINE Developers
- Document top
- LINE SDK for Android
- Enabling the bot link feature with the SDK
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
- Checking the friendship status between the user and the LINE official account
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: This method checks whether the friendship status has changed during login. - Use the Social API to get friendship status: This method gets the friendship status between the user and the LINE official account.
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 theLineAuthenticationParams
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.