### LIFF App Configuration Example Source: https://developers.line.biz/en/reference/liff-server Example JSON response showing the configuration of LIFF apps, including their IDs, view settings, descriptions, features, permanent link patterns, scopes, and bot prompt settings. ```json { "apps": [ { "liffId": "{liffId}", "view": { "type": "full", "url": "https://example.com/myservice" }, "description": "Happy New York", "permanentLinkPattern": "concat" }, { "liffId": "{liffId}", "view": { "type": "tall", "url": "https://example.com/myservice2" }, "features": { "ble": true, "qrCode": true }, "permanentLinkPattern": "concat", "scope": ["profile", "chat_message.write"], "botPrompt": "none" } ] } ``` -------------------------------- ### Example menuColorSetting object Source: https://developers.line.biz/en/reference/liff/index.html.md This JSON object demonstrates the structure and possible values for the menuColorSetting, including settings for both light and dark adaptable color schemes. ```json { "adaptableColorSchemes": [ "light" ], "lightModeColor": { "iconColor": "#111111", "statusBarColor": "black", "titleTextColor": "#111111", "titleSubtextColor": "#B7B7B7", "titleButtonColor": "#111111", "titleBackgroundColor": "#FFFFFF", "progressBarColor": "#06C755", "progressBackgroundColor": "#FFFFFF" }, "darkModeColor": { "iconColor": "#FFFFFF", "statusBarColor": "white", "titleTextColor": "#FFFFFF", "titleSubtextColor": "#949494", "titleButtonColor": "#FFFFFF", "titleBackgroundColor": "#111111", "progressBarColor": "#06C755", "progressBackgroundColor": "#111111" } } ``` -------------------------------- ### Execute Code After LIFF Initialization Source: https://developers.line.biz/en/reference/liff/index.html.md This example shows how to use the `liff.ready` Promise to execute code only after the LIFF app has been successfully initialized. This ensures that all LIFF functionalities are available. ```javascript liff.ready.then(() => { // do something you want when liff.init finishes }); ``` -------------------------------- ### Get LIFF Context Source: https://developers.line.biz/en/reference/liff/index.html.md Retrieves the screen type (e.g., 1-on-1 chat, group chat) from which the LIFF app was launched. This example logs the context object to the console. ```javascript const context = liff.getContext(); console.log(context); ``` -------------------------------- ### Get access token Source: https://developers.line.biz/en/reference/liff Retrieves the current user's access token. This token is valid for 12 hours and can be used to send user data to your server. The token is obtained during liff.init() if the user starts the app in a LIFF browser, or after liff.login() and liff.init() in an external browser. ```javascript liff.getAccessToken(); ``` -------------------------------- ### liff.getVersion() Source: https://developers.line.biz/en/reference/liff/index.html.md Gets the version of the LIFF SDK. ```APIDOC ## liff.getVersion() ### Description Gets the version of the LIFF SDK. **Note:** This method can be used before the LIFF app is initialized. ### Method ```javascript liff.getVersion(); ``` ### Arguments None ### Return Value The version of the LIFF SDK is returned as a string. ``` -------------------------------- ### liff.getVersion() Source: https://developers.line.biz/en/reference/liff Gets the version of the LIFF SDK. This method can be used before the LIFF app is initialized. ```APIDOC ## liff.getVersion() ### Description Gets the version of the LIFF SDK. This method can be used even before the initialization of the LIFF app by `liff.init()` has finished. ### Syntax ```javascript liff.getVersion(); ``` ### Arguments None ### Return value The version of the LIFF SDK is returned as a string. ``` -------------------------------- ### Get All LIFF Apps Source: https://developers.line.biz/en/reference/liff-server Retrieves a list of all LIFF apps associated with the channel. Requires a channel access token for authorization. ```sh curl -X GET https://api.line.me/liff/v1/apps \ -H "Authorization: Bearer {channel access token}" ``` -------------------------------- ### Get LIFF SDK Version Source: https://developers.line.biz/en/reference/liff Retrieves the version of the LIFF SDK. This method can be used before LIFF initialization. ```javascript liff.getVersion(); ``` -------------------------------- ### Query Specific Permission Status Source: https://developers.line.biz/en/reference/liff/index.html.md This JavaScript example demonstrates how to check if a specific permission scope has been granted by the user. It returns a Promise that resolves with the permission status. ```javascript liff.permission.query("profile").then((permissionStatus) => { // permissionStatus = { state: 'granted' } }); ``` -------------------------------- ### liff.ready Source: https://developers.line.biz/en/reference/liff A property holding a Promise that resolves when `liff.init()` is called for the first time after the LIFF app starts. This allows executing processes after initialization is complete. ```APIDOC ## liff.ready ### Description A property holding the `Promise` object that resolves when you run `liff.init()` for the first time after starting the LIFF app. If you use `liff.ready`, you can execute any process after the completion of `liff.init()`. ### Usage This property can be used before the LIFF app is initialized. ### Note If `liff.init()` fails, `liff.ready` will not be rejected. Also, it doesn't return a `LiffError` object. ### Example ```javascript liff.ready.then(() => { console.log('LIFF SDK is ready.'); }); ``` ``` -------------------------------- ### Share Target Picker Example Source: https://developers.line.biz/en/reference/liff/index.html.md Use this snippet to share a text message using the share target picker. It handles both successful message sending and user cancellation. ```javascript liff .shareTargetPicker([ { type: "text", text: "Hello, World!", }, ], { isMultiple: true, } ) .then(function (res) { if (res) { // succeeded in sending a message through TargetPicker console.log(`[${res.status}] Message sent!`); } else { // sending message canceled console.log("TargetPicker was closed!"); } }) .catch(function (error) { // something went wrong before sending a message console.log("something wrong happen"); }); ``` -------------------------------- ### Get and use access token Source: https://developers.line.biz/en/reference/liff/index.html.md Retrieves the current user's access token and demonstrates how to use it in an Authorization header for API requests. Ensure the token is valid before making requests. ```javascript const accessToken = liff.getAccessToken(); if (accessToken) { fetch("https://api...", { headers: { "Content-Type": "application/json", Authorization: `Bearer ${accessToken}`, }, //... }); } ``` -------------------------------- ### Check and Use liff.scanCode() Source: https://developers.line.biz/en/reference/liff/index.html.md Before using liff.scanCode(), check if it's available. This method starts a 2D code reader. It is not available on LINE for iOS. ```javascript if (liff.scanCode) { liff.scanCode().then((result) => { // result = { value: "" } }); } ``` -------------------------------- ### Scan QR Code with liff.scanCodeV2() Source: https://developers.line.biz/en/reference/liff/index.html.md Use this snippet to launch the 2D code reader and get the scanned string. Ensure 'Scan QR' is enabled in the LINE Developers Console. The promise resolves with the scanned value or rejects with a LiffError. ```javascript liff .scanCodeV2() .then((result) => { // result = { value: "" } }) .catch((error) => { console.log("error", error); }); ``` -------------------------------- ### Get Operating System of LIFF App Environment Source: https://developers.line.biz/en/reference/liff Retrieve the operating system on which the LIFF app is running. This method can be called before the LIFF app is fully initialized. ```javascript liff.getOS(); ``` -------------------------------- ### Create Permanent Link by URL Source: https://developers.line.biz/en/reference/liff Generates a permanent link for a given URL, allowing for query parameters and URL fragments. The provided URL must start with the 'Endpoint URL' configured in the LINE Developers Console. ```javascript liff.permanentLink.createUrlBy(url); ``` -------------------------------- ### Initialize Pluggable SDK with GetOS Source: https://developers.line.biz/en/reference/liff/index.html.md Initializes the LIFF SDK using the pluggable SDK pattern, specifically integrating the `GetOS` module to detect the operating system. ```javascript import liff from "@line/liff/core"; import GetOS from "@line/liff/get-os"; liff.use(new GetOS()); liff.init({ liffId: "123456-abcedfg", // Use own liffId }); ``` -------------------------------- ### Get ID Token Payload Example Source: https://developers.line.biz/en/reference/liff/index.html.md This JSON object represents a sample ID token payload, containing information about the issuer, subject, audience, expiration, and user profile details. ```json { "iss": "https://access.line.me", "sub": "U1234567890abcdef1234567890abcdef ", "aud": "1234567890", "exp": 1504169092, "iat": 1504263657, "amr": ["pwd"], "name": "Taro Line", "picture": "https://sample_line.me/aBcdefg123456" } ``` -------------------------------- ### Get Current Page Permanent Link Source: https://developers.line.biz/en/reference/liff Retrieves the permanent link for the current LIFF app page. This method may be deprecated in favor of createUrlBy(). The current page URL must start with the 'Endpoint URL' configured in the LINE Developers Console. ```javascript liff.permanentLink.createUrl(); ``` -------------------------------- ### liff.init() Source: https://developers.line.biz/en/reference/liff Initializes the LIFF app with provided configurations. It can accept optional success and error callbacks, and returns a Promise. ```APIDOC ## liff.init() ### Description Initializes the LIFF app with provided configurations. It can accept optional success and error callbacks, and returns a Promise. ### Method ```javascript liff.init(config, successCallback, errorCallback); ``` ### Parameters #### Arguments - **config** (Object) - Required. LIFF app configurations. - **config.liffId** (String) - Required. LIFF app ID. - **config.withLoginOnExternalBrowser** (Boolean) - Optional. Specifies whether to automatically execute `liff.login()` in external browsers. Defaults to `false`. - **successCallback** (Function) - Optional. Callback function executed upon successful initialization. - **errorCallback** (Function) - Optional. Callback function executed upon failure to initialize. ### Return value Returns a `Promise` object. ### Error response When the `Promise` is rejected, `LiffError` is passed. ``` -------------------------------- ### LIFF SDK Initialization Syntax Source: https://developers.line.biz/en/reference/liff The syntax for initializing the LIFF SDK, including configuration options for login behavior in external browsers and optional callbacks for success and error. ```javascript liff.init(config, successCallback, errorCallback); ``` -------------------------------- ### liff.getLineVersion() Source: https://developers.line.biz/en/reference/liff/index.html.md Gets the user's LINE version. ```APIDOC ## liff.getLineVersion() ### Description Gets the user's LINE version. **Note:** This method can be used before the LIFF app is initialized. ### Method ```javascript liff.getLineVersion(); ``` ### Arguments None ### Return Value If a user opens the LIFF app using a LIFF browser, the LINE version of the user is returned as a string. If a user opens the LIFF app using an external browser, `null` is returned. ``` -------------------------------- ### Initialize LIFF App with liff.id Source: https://developers.line.biz/en/reference/liff/index.html.md Demonstrates how to initialize a LIFF app using its ID. The `liff.id` property will hold the provided LIFF ID after initialization. ```javascript const liffId = "my-liff-id"; liff.init({ liffId }); // liff.id equals to liffId ``` -------------------------------- ### External Browser Return Value Example Source: https://developers.line.biz/en/reference/liff/index.html.md This JSON object shows the data returned by the LIFF API when accessed from an external browser. It includes similar information to the LIFF browser example but may differ in certain fields like 'type' and 'utouId'. ```json { "type": "external", "liffId": "123456-abcedfg", "endpointUrl": "https://example.com/", "accessTokenHash": "EVWYWo1yYA...", "availability": { "shareTargetPicker": { "permission": true, "minVer": "10.3.0" }, "multipleLiffTransition": { "permission": true, "minVer": "10.18.0" }, "subwindowOpen": { "permission": true, "minVer": "11.7.0" }, "scanCode": { "permission": true, "minVer": "9.4.0", "unsupportedFromVer": "9.19.0" }, "scanCodeV2": { "permission": true, "minVer": "11.7.0", "minOsVer": "14.3.0" }, "getAdvertisingId": { "permission": false, "minVer": "7.14.0" }, "addToHomeScreen": { "permission": false, "minVer": "9.16.0" }, "bluetoothLeFunction": { "permission": false, "minVer": "9.14.0", "unsupportedFromVer": "9.19.0" }, "skipChannelVerificationScreen": { "permission": false, "minVer": "11.14.0" }, "addToHomeV2": { "permission": false, "minVer": "13.20.0" }, "addToHomeHideDomain": { "permission": false, "minVer": "13.20.0" }, "addToHomeLineScheme": { "permission": false, "minVer": "13.20.0" } }, "scope": [ "chat_message.write", "openid", "profile" ], "menuColorSetting": { "adaptableColorSchemes": [ "light" ], "lightModeColor": { "iconColor": "#111111", "statusBarColor": "black", "titleTextColor": "#111111", "titleSubtextColor": "#B7B7B7", "titleButtonColor": "#111111", "titleBackgroundColor": "#FFFFFF", "progressBarColor": "#06C755", "progressBackgroundColor": "#FFFFFF" }, "darkModeColor": { "iconColor": "#FFFFFF", "statusBarColor": "white", "titleTextColor": "#FFFFFF", "titleSubtextColor": "#949494", "titleButtonColor": "#FFFFFF", "titleBackgroundColor": "#111111", "progressBarColor": "#06C755", "progressBackgroundColor": "#111111" } } } ``` -------------------------------- ### Initialize LIFF with Custom Plugin Source: https://developers.line.biz/en/reference/liff/index.html.md Activates a custom LIFF plugin named 'greetPlugin' which adds a 'hello' method to the LIFF object. This demonstrates how to extend LIFF functionality with custom plugins. ```javascript class greetPlugin { constructor() { this.name = "greet"; } install() { return { hello: this.hello, }; } hello() { console.log("Hello, World!"); } } liff.use(new greetPlugin()); ``` -------------------------------- ### Initialize LIFF App with Promise Source: https://developers.line.biz/en/reference/liff/index.html.md Initializes the LIFF app using a Promise. Ensure liff.init() is called before other LIFF SDK methods. This method obtains the user's access token and ID token. ```javascript liff .init({ liffId: "123456-abcedfg", // Use own liffId }) .then(() => { // Start to use liff's api }) .catch((err) => { // Error happens during initialization console.log(err.code, err.message); }); ``` -------------------------------- ### liff.permission.requestAll() Source: https://developers.line.biz/en/reference/liff Initiates the display of the verification screen for permissions requested by LINE MINI Apps. This method is only operational within LINE MINI Apps and requires 'Channel consent simplification' to be enabled. It's recommended to use `liff.permission.query()` beforehand to check for already consented permissions and only call this method if there are unconsented ones, as calling it when all permissions are already granted will result in a rejected Promise. ```APIDOC ## liff.permission.requestAll() ### Description Displays the "Verification screen" for the permissions requested by LINE MINI Apps. ### Method ```javascript liff.permission.requestAll(); ``` ### Arguments None ### Return value Returns a `Promise` object. ### Error response If **Channel consent simplification** isn't turned on, and the user has already consented to all the permissions, `Promise` will be rejected and `LiffError` will be returned. ``` -------------------------------- ### liff.getLineVersion() Source: https://developers.line.biz/en/reference/liff Gets the user's LINE version. This method can be used before the LIFF app is initialized. ```APIDOC ## liff.getLineVersion() ### Description Gets the user's LINE version. This method can be used even before the initialization of the LIFF app by `liff.init()` has finished. ### Syntax ```javascript liff.getLineVersion(); ``` ### Arguments None ### Return value If a user opens the LIFF app using a LIFF browser, the LINE version of the user is returned as a string. If a user opens the LIFF app using an external browser, `null` is returned. ``` -------------------------------- ### liff.createShortcutOnHomeScreen() Source: https://developers.line.biz/en/reference/liff Displays a screen for adding a shortcut to a LINE MINI App to the user's home screen. This method is intended for verified MINI Apps and requires specific conditions to be met. ```APIDOC ## liff.createShortcutOnHomeScreen() ### Description Displays a screen for adding a shortcut to your LINE MINI App to the home screen of the user's device. ### Conditions of use * It's a LINE MINI App. * The LIFF SDK version of the LINI MINI App is v2.23.0 or later. * The LINE app version on the user's device is 13.20.0 or later. ### Operating conditions Details on operating conditions based on OS and browser versions are provided. ### Method ```javascript liff.createShortcutOnHomeScreen(params); ``` ### Parameters #### Arguments * **params** (Object) - Required - Parameter object * **params.url** (String) - Required - URL. You can specify the following URLs: * LIFF URL * Permanent link * The endpoint URL of the LINE MINI App * URL that begins with the endpoint URL of the LINE MINI App ### Return value Returns a `Promise` object. When the Add Shortcut screen is displayed, the `Promise` is resolved. No value is passed. You can't confirm whether the user has actually added a shortcut to your LINE MINI app to the home screen of the user's device. ##### Error response When the `Promise` is rejected, `LiffError` is passed. ``` -------------------------------- ### liff.getLanguage() Source: https://developers.line.biz/en/reference/liff Gets the language setting of the environment in which the LIFF app is running. This method is deprecated and `liff.getAppLanguage()` should be used instead. ```APIDOC ## liff.getLanguage() ### Description The `liff.getLanguage()` method is deprecated. To get the language setting of the environment in which the LIFF app is running, use the `liff.getAppLanguage()` method. This method can be used even before the initialization of the LIFF app by `liff.init()` has finished. ### Syntax ```javascript liff.getLanguage(); ``` ### Arguments None ### Return value String containing language settings specified in `navigator.language` in the LIFF app's running environment. ``` -------------------------------- ### Perform login process Source: https://developers.line.biz/en/reference/liff Use `liff.login(loginConfig)` to initiate the login process in LINE's in-app or external browser. This method should not be used in a LIFF browser, where login is automatic. ```javascript liff.login(loginConfig); ``` -------------------------------- ### liff.getFriendship() Source: https://developers.line.biz/en/reference/liff/index.html.md Gets the friendship status between a user and a LINE Official Account linked to the same LINE Login channel as the LIFF app. ```APIDOC ## liff.getFriendship() ### Description Gets the friendship status between a user and a LINE Official Account. This is only possible if the LINE Official Account is linked to the same LINE Login channel as your LIFF app. ### Method `liff.getFriendship()` ### Parameters None ### Return value Returns a `Promise` object that resolves with friendship information. #### friendFlag (Boolean) - `true`: The user has added the LINE Official Account as a friend and has not blocked it. - `false`: Otherwise. ### Request Example ```javascript liff.getFriendship().then((data) => { if (data.friendFlag) { // User is a friend } }); ``` ### Response Example ```json { "friendFlag": true } ``` ### Error response When the `Promise` is rejected, [`LiffError`](https://developers.line.biz/en/reference/liff/#liff-errors) is passed. ``` -------------------------------- ### Create Home Screen Shortcut Source: https://developers.line.biz/en/reference/liff/index.html.md This method displays a screen for adding a shortcut to a verified LINE MINI App to the user's device home screen. It should be executed in response to a user action. ```javascript // If the endpoint URL of the LINE MINI App // is https://example.com/path1/path2 // and its LIFF ID is 1234567890-AbcdEfgh // Example of specifying the LIFF URL liff .createShortcutOnHomeScreen({ url: "https://miniapp.line.me/1234567890-AbcdEfgh", }) .then(() => { /* ... */ }); liff .createShortcutOnHomeScreen({ url: "https://liff.line.me/1234567890-AbcdEfgh", }) .then(() => { /* ... */ }); // Example of specifying a permanent link liff .createShortcutOnHomeScreen({ url: "https://liff.line.me/1234567890-AbcdEfgh/path3", }) .then(() => { /* ... */ }); // Example of specifying the endpoint URL of the LINE MINI App liff .createShortcutOnHomeScreen({ url: "https://example.com/path1/path2", }) .then(() => { /* ... */ }); // Example of specifying a URL that begins with the endpoint URL of the LINE MINI App liff .createShortcutOnHomeScreen({ url: "https://example.com/path1/path2/path3", }) .then(() => { /* ... */ }); // Example of specifying a URL that results in an error liff .createShortcutOnHomeScreen({ url: "https://example.com/invalid-path", }) .then(() => { /* ... */ }) .catch((error) => { // invalid URL. console.log(error.message); }); ``` -------------------------------- ### Request All Permissions Source: https://developers.line.biz/en/reference/liff/index.html.md Requests all necessary permissions from the user if they haven't already granted them. Ensure 'Channel consent simplification' is enabled and check existing permissions with `liff.permission.query()` before calling. ```javascript liff.permission.query("profile").then((permissionStatus) => { if (permissionStatus.state === "prompt") { liff.permission.requestAll(); } }); ``` -------------------------------- ### liff.getAppLanguage() Source: https://developers.line.biz/en/reference/liff Gets the language setting of the LINE app running the LIFF app. This method can be used before the LIFF app is initialized. ```APIDOC ## liff.getAppLanguage() ### Description Gets the language setting of the LINE app running the LIFF app. This method can be used even before the initialization of the LIFF app by `liff.init()` has finished. ### Conditions of use LIFF SDK versions v2.24.0 or later ### Operating conditions * The LIFF application is running on the LIFF browser. * The LINE app version is 14.11.0 or later. If the above conditions aren't met, the `liff.getAppLanguage()` method behaves the same as the `liff.getLanguage()` method. ### Syntax ```javascript liff.getAppLanguage(); ``` ### Arguments None ### Return value The language setting of the LINE app running the LIFF app is returned as a string that follows RFC 5646. ``` -------------------------------- ### Get LIFF App ID Source: https://developers.line.biz/en/reference/liff The property that holds the LIFF app ID passed to liff.init(). It is null until liff.init() is called. ```javascript const liffId = liff.id; console.log(liffId); ``` -------------------------------- ### liff.init() Source: https://developers.line.biz/en/reference/liff Initializes a LIFF app. This method must be called before any other LIFF SDK methods. It obtains the user's access token and ID token from the LINE Platform. ```APIDOC ## liff.init() ### Description Initializes a LIFF app. This method must be called before any other LIFF SDK methods. It obtains the user's access token and ID token from the LINE Platform. ### Method `liff.init()` ### Parameters This method does not take any parameters. ### Request Example ```javascript liff.init({ id: "YOUR_LIFF_ID" }).then(() => { // LIFF app is ready }).catch((error) => { // Handle initialization error }); ``` ### Response This method returns a Promise that resolves when the LIFF app is successfully initialized. Errors during initialization are handled via the `catch` block. ``` -------------------------------- ### Initialize LIFF App with Callback Source: https://developers.line.biz/en/reference/liff/index.html.md Initializes the LIFF app using a callback function. This method must be called on every page load to ensure LIFF features function correctly. ```javascript liff.init({ liffId: "123456-abcedfg" }, successCallback, errorCallback); ``` -------------------------------- ### liff.getContext() Source: https://developers.line.biz/en/reference/liff/index.html.md Gets the screen type (1-on-1 chat, group chat, multi-person chat, or external browser) from which the LIFF app is launched. ```APIDOC ## liff.getContext() ### Description Gets the screen type (1-on-1 chat, group chat, multi-person chat, or external browser) from which the LIFF app is launched. **Warning:** We've discontinued providing company internal identifiers of chat rooms to LIFF apps. ### Method ```javascript liff.getContext(); ``` ### Arguments None ### Example ```javascript const context = liff.getContext(); console.log(context); ``` ``` -------------------------------- ### liff.permission.requestAll() Source: https://developers.line.biz/en/reference/liff/index.html.md Displays the 'Verification screen' for permissions requested by LINE MINI Apps. Ensure users have consented to all permissions before calling this method to avoid Promise rejection. ```APIDOC ## liff.permission.requestAll() ### Description Displays the 'Verification screen' for the permissions requested by LINE MINI Apps. This method operates only within LINE MINI Apps and requires 'Channel consent simplification' to be enabled. ### Method `liff.permission.requestAll()` ### Arguments None ### Return value Returns a `Promise` object. ### Error response If 'Channel consent simplification' isn't turned on, or if the user has already consented to all permissions, the `Promise` will be rejected with a `LiffError`. ### Example ```javascript liff.permission.query("profile").then((permissionStatus) => { if (permissionStatus.state === "prompt") { liff.permission.requestAll(); } }); ``` ``` -------------------------------- ### liff.getFriendship() Source: https://developers.line.biz/en/reference/liff Gets the friendship status between a user and a LINE Official Account linked to the same LINE Login channel. Requires the 'profile' scope. ```APIDOC ## liff.getFriendship() ### Description Gets the friendship status between a user and a LINE Official Account. This is only possible if the LINE Official Account is linked to the same LINE Login channel as the LIFF app. ### Method JavaScript ### Endpoint N/A (Client-side SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript liff.getFriendship(); ``` ### Response #### Success Response Returns a `Promise` object that resolves with information about the friendship status: - **friendFlag** (Boolean) - `true` if the user has added the LINE Official Account as a friend and has not blocked it, otherwise `false`. #### Response Example ```json { "friendFlag": true } ``` ### Error Response When the `Promise` is rejected, `LiffError` is passed. ``` -------------------------------- ### Create Shortcut on Home Screen Source: https://developers.line.biz/en/reference/liff This method displays a screen for adding a shortcut to a LINE MINI App on the user's device home screen. It requires specific conditions to be met, including the app being a verified MINI App and using a recent LIFF SDK version. Execute this in response to a user action. ```javascript liff.createShortcutOnHomeScreen(params); ``` -------------------------------- ### Initialize LIFF SDK Source: https://developers.line.biz/en/reference/liff Initializes the LIFF SDK. This method must be called before any other LIFF SDK methods. It obtains the user's access token and ID token from the LINE Platform. ```javascript liff.init({ liffId: "YOUR_LIFF_ID" }).then(() => { // LIFF app is ready }); ``` -------------------------------- ### Get all LIFF apps Source: https://developers.line.biz/en/reference/liff-server Retrieves information about all LIFF apps associated with the channel. This endpoint allows you to list all configured LIFF applications. ```APIDOC ## GET https://api.line.me/liff/v1/apps ### Description Gets information on all the LIFF apps added to the channel. ### Method GET ### Endpoint https://api.line.me/liff/v1/apps ### Request Headers - **Authorization** (string) - Required - Bearer `{channel access token}` ### Response #### Success Response (200) - **apps** (Array of objects) - Array of LIFF app objects - **apps[].liffId** (string) - LIFF app ID - **apps.view.type** (string) - Size of the LIFF app view. One of these values: `compact`, `tall`, `full` - **apps.view.url** (string) - Endpoint URL for the web app. - **apps.view.moduleMode** (boolean) - `true` to use the LIFF app in modular mode. - **apps[].description** (string) - Name of the LIFF app. - **apps.features.ble** (boolean) - `true` if the LIFF app supports Bluetooth® Low Energy for LINE Things. - **apps.features.qrCode** (boolean) - `true` if the 2D code reader can be launched in the LIFF app. - **apps[].permanentLinkPattern** (string) - How additional information in LIFF URLs is handled. `concat` is returned. - **apps[].scope** (Array of strings) - Scopes of the LIFF app. e.g., `openid`, `email`, `profile`, `chat_message.write` - **apps[].botPrompt** (string) - The setting for add friend option. Values: `normal`, `aggressive`, `none` #### Response Example ```json { "apps": [ { "liffId": "{liffId}", "view": { "type": "full", "url": "https://example.com/myservice" }, "description": "Happy New York", "permanentLinkPattern": "concat" }, { "liffId": "{liffId}", "view": { "type": "tall", "url": "https://example.com/myservice2" }, "features": { "ble": true, "qrCode": true }, "permanentLinkPattern": "concat", "scope": ["profile", "chat_message.write"], "botPrompt": "none" } ] } ``` #### Error Response - **400** - The request contains an invalid value. - **401** - Authentication failed. - **404** - The specified LIFF app does not exist or has been added to another channel. ``` -------------------------------- ### Initialize LIFF App and Send Pageview Source: https://developers.line.biz/en/reference/liff Initialize the LIFF app and send a pageview event after successful initialization. This method is recommended for versions v2.11.0 or later to prevent credential leakage. ```javascript liff .init({ liffId: "1234567890-AbcdEfgh", // Use own liffId }) .then(() => { ga("send", "pageview"); }); ``` -------------------------------- ### liff.permanentLink.createUrl() Source: https://developers.line.biz/en/reference/liff Gets the permanent link for the current page of the LIFF app. This method may be deprecated in the future, and `liff.permanentLink.createUrlBy()` is recommended for new implementations. ```APIDOC ## liff.permanentLink.createUrl() ### Description Gets the permanent link for the current page. Permanent link format: ``` https://liff.line.me/{liffId}/{path}?{query}#{URL fragment} ``` __liff.permanentLink.createUrl() may be deprecated in the next major version update Due to technical issues, `liff.permanentLink.createUrl()` may be deprecated in the next major version update. To get the permanent link of the current page, we recommend using `liff.permanentLink.createUrlBy()`. ### Method None (This is a JavaScript method call) ### Endpoint None (This is a JavaScript method call) ### Parameters #### Arguments None ### Return value Returns the current page's permanent link as a string. A `LiffError` exception is thrown if the current page URL doesn't start with the URL specified in **Endpoint URL** of the LINE Developers console. ``` -------------------------------- ### LIFF Initialization URL Guarantee Source: https://developers.line.biz/en/reference/liff The `liff.init()` method is guaranteed to work on the exact endpoint URL or any URL at a lower level. Behavior is not guaranteed on other URLs, potentially affecting features like multi-tab view. ```text URL to execute `liff.init()`| Guaranteed to work ---|--- `https://example.com/`| ❌ `https://example.com/path1/`| ✅ `https://example.com/path1/language/`| ✅ `https://example.com/path2/`| ❌ ``` -------------------------------- ### Request All Permissions Source: https://developers.line.biz/en/reference/liff Displays the verification screen for all requested permissions for LINE MINI Apps. This method only operates on LINE MINI Apps and requires 'Channel consent simplification' to be enabled. Ensure to check existing permissions with liff.permission.query() before calling. ```javascript liff.permission.requestAll(); ``` -------------------------------- ### Get All Granted Permissions Source: https://developers.line.biz/en/reference/liff/index.html.md Use this JavaScript snippet to retrieve an array of scopes for which the user has granted permission. This method returns a Promise that resolves with the scopes. ```javascript liff.permission.getGrantedAll().then((scopes) => { // ["profile", "chat_message.write", "openid", "email"] console.log(scopes); }); ``` -------------------------------- ### liff.getOS() Source: https://developers.line.biz/en/reference/liff/index.html.md Retrieves the operating system environment where the LIFF app is running. ```APIDOC ## liff.getOS() ### Description Gets the environment in which the user is running the LIFF app. This method can be used before the LIFF app is initialized. ### Method ```javascript liff.getOS(); ``` ### Arguments None ### Return value The environment in which the user is running the LIFF app is returned as a string. Possible values are `ios`, `android`, or `web`. ``` -------------------------------- ### liff.getProfile() Source: https://developers.line.biz/en/reference/liff Gets the current user's profile information (userId, displayName, pictureUrl, statusMessage). Requires the 'profile' scope to be selected and granted by the user. ```APIDOC ## liff.getProfile() ### Description Gets the current user's profile information. Only the main profile information can be obtained; subprofile information cannot be retrieved. It is crucial not to send user info to the server. ### Method JavaScript ### Endpoint N/A (Client-side SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript liff.getProfile(); ``` ### Response #### Success Response Returns a `Promise` object that resolves with an object containing the user's profile information: - **userId** (String) - User ID - **displayName** (String) - Display name - **pictureUrl** (String) - Image URL (Optional) - **statusMessage** (String) - Status message (Optional) #### Response Example ```json { "userId": "Uxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "displayName": "John", "pictureUrl": "https://example.com/image.jpg", "statusMessage": "Hello!" } ``` ### Error Response When the `Promise` is rejected, `LiffError` is passed. ``` -------------------------------- ### Scan QR Code Syntax Source: https://developers.line.biz/en/reference/liff This is the basic syntax for launching the 2D code reader using the LIFF SDK. ```javascript liff.scanCodeV2(); ``` -------------------------------- ### Get Friendship Status Source: https://developers.line.biz/en/reference/liff Checks the friendship status between the user and a LINE Official Account linked to the same LINE Login channel. Requires the 'profile' scope. ```javascript liff.getFriendship(); ``` -------------------------------- ### liff.use() Source: https://developers.line.biz/en/reference/liff Activates and initializes LIFF API within a pluggable SDK or a LIFF plugin. This method is used for integrating LIFF functionalities into modular or plugin-based architectures. ```APIDOC ## liff.use() ### Description Activates and initializes LIFF API in the pluggable SDK or a LIFF plugin. ### Method None (This is a JavaScript method call) ### Endpoint None (This is a JavaScript method call) ### Parameters #### Arguments * **module** (Object) - The LIFF API module to use. * **option** (Object) - Optional - Configuration options for the module. ### Example _Example of LIFF API in the pluggable SDK_ _Example of LIFF plugin_ ``` -------------------------------- ### liff.getContext() Source: https://developers.line.biz/en/reference/liff Gets the screen type (e.g., 1-on-1 chat, group chat) from which the LIFF app is launched. This method can be used before the LIFF app is initialized. ```APIDOC ## liff.getContext() ### Description Gets the screen type (1-on-1 chat, group chat, multi-person chat, or external browser) from which the LIFF app is launched. Note that company internal identifiers of chat rooms are no longer provided. ### Syntax ```javascript liff.getContext(); ``` ### Arguments None ``` -------------------------------- ### liff.getOS() Source: https://developers.line.biz/en/reference/liff Retrieves the operating system environment in which the LIFF app is running. This method can be called before the LIFF app is fully initialized. ```APIDOC ## liff.getOS() ### Description Retrieves the operating system environment in which the LIFF app is running. This method can be called before the LIFF app is fully initialized. ### Method ```javascript liff.getOS(); ``` ### Arguments None ``` -------------------------------- ### Get LIFF Environment Language (Deprecated) Source: https://developers.line.biz/en/reference/liff Retrieves the language setting of the environment where the LIFF app is running. This method is deprecated and can be used before LIFF initialization. ```javascript liff.getLanguage(); ``` -------------------------------- ### liff.getContext() Source: https://developers.line.biz/en/reference/liff Retrieves context information about the LIFF app's launch environment. This includes details about the chat type, user, LIFF app itself, and its availability and permissions. ```APIDOC ## liff.getContext() ### Description Retrieves context information about the LIFF app's launch environment. This includes details about the chat type, user, LIFF app itself, and its availability and permissions. ### Method ``` javascript liff.getContext() ``` ### Return value A data object that contains the information necessary to make various API calls. - **type** (String) - The type of screen from where the LIFF app was launched. One of: `utou`, `group`, `room`, `external`, `none`. - **userId** (String) - User ID. Included when the `type` property is `utou`, `room`, `group`, `none` or `external`. However, null may be returned when `type` is `external`. - **liffId** (String) - LIFF ID. - **viewType** (String) - Size of the LIFF app view, only returned if the `type` property isn't `external`. One of: `compact`, `tall`, `full`. - **endpointUrl** (String) - URL of the service endpoint. - **accessTokenHash** (String) - First half of the hashed SHA256 value of the access token. Used to validate the access token. - **availability** (Object) - Indicates whether the LIFF features are available in the environment in which the LIFF app was launched. - **scope** (Array of strings) - Returns which of the scopes the LIFF app has within the scope required to use some of the LIFF SDK methods. Possible values: `openid`, `email`, `profile`, `chat_message.write`. - **menuColorSetting** (Object) - Returns the color setting of the LIFF browser header. - **miniAppId** (String) - Returns the string set by the Custom Path feature of the LINE MINI App. Not always included. - **miniDomainAllowed** (Boolean) - Returns whether the LINE MINI App is available on the `miniapp.line.me` domain. - **permanentLinkPattern** (String) - How additional information in LIFF URLs is handled. `concat` is returned. ### Response Example (LIFF browser) ```json { "type": "utou", "userId": "u0123456789abcdef0123456789abcdef", "liffId": "1234567890", "viewType": "tall", "endpointUrl": "https://example.com", "accessTokenHash": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890", "availability": { "scanBot": true, "getProfile": true, "sendMessage": true, "openWindow": true, "shareTargetPicker": true, "getFriendship": true, "getGroupInfo": true, "getRoomInfo": true, "getExternalMapId": true, "sendMessages": true, "agreement": { "email": true } }, "scope": [ "profile", "openid", "email" ], "menuColorSetting": { "backgroundColor": "#000000" }, "miniAppId": "abcdef0123456789abcdef0123456789", "miniDomainAllowed": true, "permanentLinkPattern": "concat" } ``` ### Response Example (external browser) ```json { "type": "external", "userId": null, "liffId": "1234567890", "endpointUrl": "https://example.com", "accessTokenHash": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890", "availability": { "scanBot": false, "getProfile": false, "sendMessage": false, "openWindow": true, "shareTargetPicker": false, "getFriendship": false, "getGroupInfo": false, "getRoomInfo": false, "getExternalMapId": false, "sendMessages": false, "agreement": { "email": false } }, "scope": [], "menuColorSetting": null, "miniDomainAllowed": false, "permanentLinkPattern": "concat" } ``` ``` -------------------------------- ### LIFF SDK Error Object Example Source: https://developers.line.biz/en/reference/liff/index.html.md This JSON object represents a typical error returned by the LIFF SDK. It includes an error code and a descriptive message. ```json { "code": "INIT_FAILED", "message": "Failed to init LIFF SDK" } ``` -------------------------------- ### Create Permanent Link Source: https://developers.line.biz/en/reference/liff/index.html.md Generates a permanent link for the current LIFF page. Use this to get the full URL of the current page within the LIFF app. ```javascript // For example, if current location is // /shopping?item_id=99#details // (LIFF ID = 1234567890-AbcdEfgh) const myLink = liff.permanentLink.createUrl(); // myLink equals "https://liff.line.me/1234567890-AbcdEfgh/shopping?item_id=99#details" ``` -------------------------------- ### Check LIFF SDK Readiness Source: https://developers.line.biz/en/reference/liff A property holding a Promise that resolves when liff.init() has completed. This allows executing processes after initialization. ```javascript liff.ready.then(() => { console.log("LIFF app is ready"); }); ``` -------------------------------- ### Get User ID Token Source: https://developers.line.biz/en/reference/liff/index.html.md Retrieves the ID token for the current user after LIFF initialization. Ensure the 'openid' scope is selected in the LINE Developers Console. ```javascript liff .init({ liffId: "123456-abcedfg", // Use own liffId }) .then(() => { const idToken = liff.getIDToken(); console.log(idToken); // print idToken object }); ``` -------------------------------- ### liff.openWindow() Source: https://developers.line.biz/en/reference/liff/index.html.md Opens the specified URL in the LINE in-app browser or an external browser. ```APIDOC ## liff.openWindow() ### Description Opens the specified URL in the LINE's in-app browser or external browser. Usage in an external browser isn't guaranteed. ### Method `liff.openWindow(options)` ### Parameters #### Request Body - **options** (object) - Required - Configuration for opening the window. - **url** (string) - Required - The URL to open. - **external** (boolean) - Optional - If `true`, opens the URL in an external browser. Defaults to `false`. ### Request Example ```javascript liff.openWindow({ url: "https://line.me", external: true, }); ``` ```