|
@@ -65,49 +65,77 @@ function logout() {
|
|
|
|
|
|
function createFlexMessageData() {
|
|
|
var flex = {
|
|
|
- "type": "flex",
|
|
|
- "altText": redistitle,
|
|
|
- "contents": redisdata,
|
|
|
- };
|
|
|
+ "type": "flex",
|
|
|
+ "altText": redistitle,
|
|
|
+ "contents": redisdata,
|
|
|
+ };
|
|
|
|
|
|
return flex;
|
|
|
}
|
|
|
|
|
|
-var redisdata='';
|
|
|
+var redisdata = '';
|
|
|
|
|
|
function shareTargetPicker() {
|
|
|
- const url = 'https://liff.googo.org:9898/yuri'
|
|
|
- axios
|
|
|
- .get(url)
|
|
|
- .then(({data}) => {
|
|
|
- redisdata=data.data;
|
|
|
- redistitle=data.title;
|
|
|
- console.log(redistitle);
|
|
|
- console.log(redisdata);
|
|
|
-
|
|
|
- liff.shareTargetPicker([
|
|
|
- {
|
|
|
- type: "text",
|
|
|
- text: "Test!"
|
|
|
+
|
|
|
+ liff.shareTargetPicker([
|
|
|
+ {
|
|
|
+ 'type': 'text',
|
|
|
+ 'text': 'Hello, World!'
|
|
|
+ }
|
|
|
+ ])
|
|
|
+ .then(function (res) {
|
|
|
+ if (res) {
|
|
|
+ // succeeded in sending a message through TargetPicker
|
|
|
+ console.log(`[${res.status}] Message sent!`)
|
|
|
+ } else {
|
|
|
+ const [majorVer, minorVer] = (liff.getLineVersion() || "").split('.');
|
|
|
+ if (parseInt(majorVer) == 10 && parseInt(minorVer) < 11) {
|
|
|
+ // LINE 10.3.0 - 10.10.0
|
|
|
+ // Old LINE will access here regardless of user's action
|
|
|
+ console.log('TargetPicker was opened at least. Whether succeeded to send message is unclear')
|
|
|
+ } else {
|
|
|
+ // LINE 10.11.0 -
|
|
|
+ // sending message canceled
|
|
|
+ console.log('TargetPicker was closed!')
|
|
|
}
|
|
|
- ])
|
|
|
- .then(
|
|
|
- console.log("ShareTargetPicker was launched")
|
|
|
- ).catch(function (res) {
|
|
|
- alert(res);
|
|
|
- console.log("Failed to launch ShareTargetPicker", res)
|
|
|
- })
|
|
|
-
|
|
|
- // liff
|
|
|
- // .shareTargetPicker([
|
|
|
- // createFlexMessageData()
|
|
|
- // ])
|
|
|
- // .then(() => {
|
|
|
- // alert("Shared to the friend(s) you picked");
|
|
|
- // })
|
|
|
- // .catch(function(res) {
|
|
|
- // alert(res);
|
|
|
- // });
|
|
|
-
|
|
|
- });
|
|
|
+ }
|
|
|
+ }).catch(function (error) {
|
|
|
+ // something went wrong before sending a message
|
|
|
+ console.log('something wrong happen', error)
|
|
|
+ })
|
|
|
+
|
|
|
+ // const url = 'https://liff.googo.org:9898/yuri'
|
|
|
+ // axios
|
|
|
+ // .get(url)
|
|
|
+ // .then(({data}) => {
|
|
|
+ // redisdata=data.data;
|
|
|
+ // redistitle=data.title;
|
|
|
+ // console.log(redistitle);
|
|
|
+ // console.log(redisdata);
|
|
|
+
|
|
|
+ // liff.shareTargetPicker([
|
|
|
+ // {
|
|
|
+ // type: "text",
|
|
|
+ // text: "Test!"
|
|
|
+ // }
|
|
|
+ // ])
|
|
|
+ // .then(
|
|
|
+ // console.log("ShareTargetPicker was launched")
|
|
|
+ // ).catch(function (res) {
|
|
|
+ // alert(res);
|
|
|
+ // console.log("Failed to launch ShareTargetPicker", res)
|
|
|
+ // })
|
|
|
+
|
|
|
+ // // liff
|
|
|
+ // // .shareTargetPicker([
|
|
|
+ // // createFlexMessageData()
|
|
|
+ // // ])
|
|
|
+ // // .then(() => {
|
|
|
+ // // alert("Shared to the friend(s) you picked");
|
|
|
+ // // })
|
|
|
+ // // .catch(function(res) {
|
|
|
+ // // alert(res);
|
|
|
+ // // });
|
|
|
+
|
|
|
+ // });
|
|
|
}
|