大家好,我是做出「LINE 數位版名片」的 LINE API 專家均民。
最近 LINE 在開發者新聞中宣佈(查看英文公告 1)、(查看英文公告 2)、(查看英文公告 3),於 2023/02/06 時將無法在 LIFF 中取得聊天室的相關辨識用 ID(roomId, groupId, utouId),這個修改不管你的 LIFF SDK 使用什麼版本都會被影響,記得要趕快檢查一下自己的 LIFF 程式中有沒有用到,如果有的話記得提早使用本文提供的替代方案進行修改,才不會到時候手忙腳亂喔!
在開發者新聞中有說明這次的修改主要會影響 LIFF 的兩個功能:
liff.getContext() 的回傳資料 在均民寫這篇文章時,liff.getContext() 中可以取得的資料如下:
{
"accessTokenHash": "Lwo84VP2mkMcf7biW5DxwQ",
"endpointUrl": "https://taichunmin.idv.tw/pug/line-liff-20200406.html",
"liffId": "1654046335-DzXpM8mx",
"permanentLinkPattern": "concat",
"type": "utou",
"userId": "U039423df742116d5ee31878c9dfeb11b",
"utouId": "UUa4e02fcbc417ba728cbcb13e389a4544735404c12dfc54f48f7d386ca7f4ad819196b92f7796a8e7639d8d516790c20d1f574c2b734bb87446c762abcf962087",
"viewType": "tall",
"availability": {
"addToHomeScreen": {
"minVer": "9.16.0",
"permission": false
},
"bluetoothLeFunction": {
"minVer": "9.14.0",
"permission": false
},
"getAdvertisingId": {
"minVer": "7.14.0",
"permission": false
},
"multipleLiffTransition": {
"minVer": "10.18.0",
"permission": true
},
"scanCode": {
"minVer": "9.4.0",
"permission": false
},
"scanCodeV2": {
"minVer": "11.7.0",
"permission": false
},
"shareTargetPicker": {
"minVer": "10.3.0",
"permission": true
},
"skipChannelVerificationScreen": {
"minVer": "11.14.0",
"permission": false
},
"subwindowOpen": {
"minVer": "11.7.0",
"permission": false
}
},
"menuColorSetting": {
"adaptableColorSchemes": [
"light"
],
"darkModeColor": {
"iconColor": "#FFFFFF",
"progressBackgroundColor": "#111111",
"progressBarColor": "#06C755",
"statusBarColor": "white",
"titleBackgroundColor": "#111111",
"titleButtonColor": "#FFFFFF",
"titleSubtextColor": "#949494",
"titleTextColor": "#FFFFFF"
},
"lightModeColor": {
"iconColor": "#111111",
"progressBackgroundColor": "#EFEFEF",
"progressBarColor": "#07B53B",
"statusBarColor": "black",
"titleBackgroundColor": "#FFFFFF",
"titleButtonColor": "#111111",
"titleSubtextColor": "#B7B7B7",
"titleTextColor": "#111111"
}
},
"scope": [
"chat_message.write",
"profile"
],
"utsTracking": {
"mode": "none",
"sendRatio": 1
}
}
{
"accessTokenHash": "EbDb3-9VFSisckstIMnRqg",
"endpointUrl": "https://taichunmin.idv.tw/pug/line-liff-20200406.html",
"groupId": "C8c9b9dbcca620a2c356259ad8462b128",
"liffId": "1654046335-DzXpM8mx",
"permanentLinkPattern": "concat",
"type": "group",
"userId": "U039423df742116d5ee31878c9dfeb11b",
"viewType": "tall",
"availability": {
"addToHomeScreen": {
"minVer": "9.16.0",
"permission": false
},
"bluetoothLeFunction": {
"minVer": "9.14.0",
"permission": false
},
"getAdvertisingId": {
"minVer": "7.14.0",
"permission": false
},
"multipleLiffTransition": {
"minVer": "10.18.0",
"permission": true
},
"scanCode": {
"minVer": "9.4.0",
"permission": false
},
"scanCodeV2": {
"minVer": "11.7.0",
"permission": false
},
"shareTargetPicker": {
"minVer": "10.3.0",
"permission": true
},
"skipChannelVerificationScreen": {
"minVer": "11.14.0",
"permission": false
},
"subwindowOpen": {
"minVer": "11.7.0",
"permission": false
}
},
"menuColorSetting": {
"adaptableColorSchemes": [
"light"
],
"darkModeColor": {
"iconColor": "#FFFFFF",
"progressBackgroundColor": "#111111",
"progressBarColor": "#06C755",
"statusBarColor": "white",
"titleBackgroundColor": "#111111",
"titleButtonColor": "#FFFFFF",
"titleSubtextColor": "#949494",
"titleTextColor": "#FFFFFF"
},
"lightModeColor": {
"iconColor": "#111111",
"progressBackgroundColor": "#EFEFEF",
"progressBarColor": "#07B53B",
"statusBarColor": "black",
"titleBackgroundColor": "#FFFFFF",
"titleButtonColor": "#111111",
"titleSubtextColor": "#B7B7B7",
"titleTextColor": "#111111"
}
},
"scope": [
"chat_message.write",
"profile"
],
"utsTracking": {
"mode": "none",
"sendRatio": 1
}
}
{
"accessTokenHash": "_w9LYgeBGCawI8t0xmEp1g",
"endpointUrl": "https://taichunmin.idv.tw/pug/line-liff-20200406.html",
"liffId": "1654046335-DzXpM8mx",
"permanentLinkPattern": "concat",
"squareChatId": "M176a2d293f592466505741540e56441e",
"squareId": "Sb90956211a48e2dbe7f5b897a642d20e",
"squareMemberId": "Pf38deca9da7e850de54c82e8f2ac075a",
"type": "square_chat",
"viewType": "tall",
"availability": {
"addToHomeScreen": {
"minVer": "9.16.0",
"permission": false
},
"bluetoothLeFunction": {
"minVer": "9.14.0",
"permission": false
},
"getAdvertisingId": {
"minVer": "7.14.0",
"permission": false
},
"multipleLiffTransition": {
"minVer": "10.18.0",
"permission": true
},
"scanCode": {
"minVer": "9.4.0",
"permission": false
},
"scanCodeV2": {
"minVer": "11.7.0",
"permission": false
},
"shareTargetPicker": {
"minVer": "10.3.0",
"permission": true
},
"skipChannelVerificationScreen": {
"minVer": "11.14.0",
"permission": false
},
"subwindowOpen": {
"minVer": "11.7.0",
"permission": false
}
},
"menuColorSetting": {
"adaptableColorSchemes": [
"light"
],
"darkModeColor": {
"iconColor": "#FFFFFF",
"progressBackgroundColor": "#111111",
"progressBarColor": "#06C755",
"statusBarColor": "white",
"titleBackgroundColor": "#111111",
"titleButtonColor": "#FFFFFF",
"titleSubtextColor": "#949494",
"titleTextColor": "#FFFFFF"
},
"lightModeColor": {
"iconColor": "#111111",
"progressBackgroundColor": "#EFEFEF",
"progressBarColor": "#07B53B",
"statusBarColor": "black",
"titleBackgroundColor": "#FFFFFF",
"titleButtonColor": "#111111",
"titleSubtextColor": "#B7B7B7",
"titleTextColor": "#111111"
}
},
"scope": [
"chat_message.write",
"profile"
],
"utsTracking": {
"mode": "none",
"sendRatio": 1
}
}
.
liff.getContext() 可以用來取得 LIFF 網址被開啟的這個聊天室的類型(一對一聊天、群組聊天、多人聊天室、社群、外部瀏覽器),在這個修改生效後,以下的欄位將無法再透過這個 API 來取得:
utouIdgroupIdroomId在 liff.getContext() 的英文文件也已經可以看到這些欄位即將被棄用(Deprecated)的警告:

如果想要知道更多細節,你可以查看 liff.getContext() 的英文文件。
如果你的 LIFF 有用到 chat_message.write 這個 scope,原本在以下的 API 可以拿到 utouId,在這個修改生效後,將不會再拿到 utouId:

如果想要知道更多細節,你可以查看 Issue access token、Refresh access token、Verify access token validity 的英文文件。
如果你的程式內有用到這次所提到即將移除的資料欄位,你可以考慮採用以下列出的幾個替代方案:
在給予 LIFF 網址的同時,你的程式應該要透過網址帶入一個由你的程式自行產生的獨立 ID,以便辨識使用者是在哪個聊天室開啟你的 LIFF;以下是簡單的範例:
https://liff.line.me/{liffId}/?talk_id={ID generated by your service}
以下則是這個替代方案的使用者流程比較:
| 現有流程範例 | 替代方案 |
|---|---|
|
|
如果你不知道怎麼使用 LIFF 網址,請查看 LIFF app development guidelines 文件。
如果想要知道更多有關 LIFF 網址打開後第二次跳轉的細節,請查看 Create a secondary redirect URL 文件。
groupId 以及 roomId 如果你目前是透過 liff.getContext() 來取得 groupId 或 roomId,你可以改從 Webhook 的事件中取得。
| 現有流程範例 | 替代方案 |
|---|---|
|
|
如果想要知道更多細節,請查看 Messaging API 文件中的 Webhook events for one-on-one chats or group chats and multi-person chats 以及 Webhook Event Objects。
本文範例程式的原始碼授權為 MIT License,如果有疑問歡迎透過 Facebook 跟我聯繫。