Skip to content

Instantly share code, notes, and snippets.

@jirawatee
Last active July 1, 2020 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jirawatee/18bd8b30924b430c638bd951be0163f4 to your computer and use it in GitHub Desktop.
Save jirawatee/18bd8b30924b430c638bd951be0163f4 to your computer and use it in GitHub Desktop.
if (result) {
// ผู้ใช้งานได้กดแชร์ข้อความ แต่จะสำเร็จหรือไม่ให้ดูที่ ${result.status}
alert(`[${result.status}] Message sent!`)
} else {
// ผู้ใช้งานกดปิดหน้า ShareTargetPicker หรือใช้แอป LINE เวอร์ชันต่ำกว่า 10.10.1
// ใช้ liff.getLineVersion() เพื่อดึงเลขเวอร์ชันจากแอป LINE ของผู้ใช้
const [majorVer, minorVer, patchVer] = (liff.getLineVersion() || "").split('.');
// alert ในกรณที่ใช้งาน LIFF ใน external browser ค่า minorVer จะเป็น undefined
if (minorVer === undefined) {
alert('ShareTargetPicker was canceled in external browser')
return
}
// alert ในกรณีที่ผู้ใช้งานใช้แอป LINE v10.10.1 หรือเวอร์ชันใหม่กว่า
if (parseInt(majorVer) >= 10 && parseInt(minorVer) >= 10 && parseInt(patchVer) > 0) {
alert('ShareTargetPicker was canceled in LINE app')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment