メッセージを送信する

プロフィールを取得する

URLを開く

LIFFアプリを閉じる


const idSPace = document.getElementById(‘id’); const errorSpace = document.getElementById(‘error’);

//liff init liff.init( data => { const userId = data.context.userId; idSPace.innerText = userId; }, err => { console.log(‘error’, err); } );

document.getElementById(‘profile’).addEventListener(‘click’, function () { liff.getProfile() .then(profile => { const userIdSpace = document.getElementById(‘userId’); const displayNameSpace = document.getElementById(‘displayName’); const pictureUrlSpace = document.getElementById(‘pictureUrl’); const statusMessageSpace = document.getElementById(‘statusMessage’);

userIdSpace.innerText = profile.userId; displayNameSpace.innerHTML = profile.displayName; pictureUrlSpace.innerHTML = profile.pictureUrl; statusMessageSpace.innerHTML = profile.statusMessage;

}) .catch((err) => { console.log(‘error’, err); }); });

document.getElementById(‘open’).addEventListener(‘click’, function () { liff.openWindow({ url: ‘https://classmethod.jp/’ }); });

document.getElementById(‘close’).addEventListener(‘click’, function () { liff.closeWindow(); });

document.getElementById(‘message’).addEventListener(‘click’, function () { liff.sendMessages([ { type:’text’, text:’Hello, World!’ } ]) .then(() => { console.log(‘message sent’); }) .catch((err) => { console.log(‘error’, err); }); });