# Pluggable SDK
# What is the pluggable SDK
The pluggable SDK is a feature that allows you to choose which LIFF APIs to include in the LIFF SDK.
By including only the LIFF APIs used by your LIFF app, you can reduce the LIFF SDK file size by up to about 34%. As a result, you can improve the display speed of your LIFF app.
# Use conditions of the pluggable SDK
The pluggable SDK is only available in the npm version of LIFF v2.22.0 or later. It's not available in the CDN version. For more information about using the npm package, see Use the npm package.
# How to use the pluggable SDK
The pluggable SDK can be used as follows:
# Import the liff object
First, import the liff
object from @line/liff/core
.
import liff from "@line/liff/core";
This liff
object includes only the following properties and methods:
liff.id
propertyliff.ready
propertyliff.init()
methodliff.getVersion()
methodliff.use()
method
To use LIFF APIs other than those listed above, import the corresponding modules. In the following example, the corresponding modules are imported for the liff.getOS()
method and the liff.getLanguage()
method:
import liff from "@line/liff/core";
import GetOS from "@line/liff/get-os";
import GetLanguage from "@line/liff/get-language";
For more information on the modules corresponding to each LIFF API, see LIFF API and the corresponding module list.
# Activate the LIFF APIs
Next, pass the imported LIFF API modules to the liff.use()
method to activate the LIFF APIs. Since the LIFF API modules are defined as classes, you must pass the instances to the liff.use()
method.
import liff from "@line/liff/core";
import GetOS from "@line/liff/get-os";
import GetLanguage from "@line/liff/get-language";
liff.use(new GetOS());
liff.use(new GetLanguage());
Once the LIFF APIs are activated, you can use the LIFF APIs.
In the example below, the activated liff.getOS()
method and the liff.getLanguage()
method are available, but the unactivated liff.login()
method isn't available:
import liff from "@line/liff/core";
import GetOS from "@line/liff/get-os";
import GetLanguage from "@line/liff/get-language";
liff.use(new GetOS());
liff.use(new GetLanguage());
liff.init({
liffId: "123456-abcedfg",
});
liff.getOS(); // Available
liff.getLanguage(); // Available
liff.login(); // Not available
# Important points about the pluggable SDK
Due to technical limitations, the liff.use()
method should be executed before the liff.init()
method. The execution of the liff.use()
method after the liff.init()
method isn't guaranteed to work.
# Example of correct execution of the liff.use() method
import liff from "@line/liff/core";
import GetOS from "@line/liff/get-os";
// The liff.use() method is executed before the liff.init() method
liff.use(new GetOS());
liff.init({
liffId: "123456-abcedfg",
});
# Example of wrong execution of the liff.use() method
import liff from "@line/liff/core";
import GetOS from "@line/liff/get-os";
liff.init({
liffId: "123456-abcedfg",
});
// The liff.use() method is executed after the liff.init() method
liff.use(new GetOS());
# LIFF API and the corresponding module list
LIFF API | Module |
---|---|
liff.getOS() | @line/liff/get-os |
liff.getLanguage() | @line/liff/get-language |
liff.getLineVersion() | @line/liff/get-line-version |
liff.getContext() | @line/liff/get-context |
liff.isInClient() | @line/liff/is-in-client |
liff.isLoggedIn() | @line/liff/is-logged-in |
liff.isApiAvailable() | @line/liff/is-api-available |
liff.login() | @line/liff/login |
liff.logout() | @line/liff/logout |
liff.getAccessToken() | @line/liff/get-access-token |
liff.getIDToken() | @line/liff/get-id-token |
liff.getDecodedIDToken() | @line/liff/get-decoded-id-token |
liff.permission.query() liff.permission.requestAll() | @line/liff/permission |
liff.getProfile() | @line/liff/get-profile |
liff.getFriendship() | @line/liff/get-friendship |
liff.openWindow() | @line/liff/open-window |
liff.closeWindow() | @line/liff/close-window |
liff.sendMessages() | @line/liff/send-messages |
liff.shareTargetPicker() | @line/liff/share-target-picker |
liff.scanCodeV2() | @line/liff/scan-code-v2 |
liff.scanCode() | @line/liff/scan-code |
liff.initPlugins() | @line/liff/init-plugins |
liff.permanentLink.createUrlBy() liff.permanentLink.createUrl() liff.permanentLink.setExtraQueryParam() | @line/liff/permanent-link |
liff.i18n.setLang() | @line/liff/i18n |