Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Friends get Friends Campaign LIFF Share Target ...

Friends get Friends Campaign LIFF Share Target Picker

LINE Developers Thailand

September 02, 2022
Tweet

More Decks by LINE Developers Thailand

Other Decks in Technology

Transcript

  1. Atchariya Darote CEO AIYA LINE Certified Coach for API 2022

    Friends get Friends Campaign LIFF Share Target Picker
  2. • Friends get Friends Campaign Overview • LINE Front-end Framework

    (LIFF) Kick-off • LIFF Share Target Picker Insight • Scale up on Production Agenda
  3. Friends get Friends LINE Journey Registration Invite to join Campaign

    Landing LIFF Share Target Picker Send Flex Message
  4. Friends get Friends Social Journey แช ร์ ลิ ง ค์

    ชวนเ พื ่ อน คั ดลอก ลิ ง ค์ รอง รั บโซเ ซี ยล อื่ น Registration
  5. • Share campaign via LINE • Collect point • Other

    social platforms 
 compatibility Features
  6. // Execute liff.init() when the app is initialized useEffect(() =>

    { // to avoid `window is not defined` error import("@line/liff").then((liff) => { console.log("start liff.init()..."); liff .init({ liffId: process.env.LIFF_ID }) .then(() => { console.log("liff.init() done"); setLiffObject(liff); }) .catch((error) => { console.log(`liff.init() failed: ${error}`); if (!process.env.liffId) { console.info( "LIFF Starter: Please make sure that you provided `LIFF_ID` as an environmental variable." ); } setLiffError(error.toString()); }); }); }, []); Import LIFF SDK in NextJS https://github.com/line/line-liff-v2-starter/blob/master/src/nextjs/pages/_app.js
  7. if (liff.isApiAvailable('shareTargetPicker')) { liff.shareTargetPicker([ { type: 'text', text: 'Hello, World!',

    }, ]); } Is LIFF Share Target Picker available? Target picker is supported on 10.3.0 or later for both LINE for iOS and LINE for Android.
  8. LIFF Share Target Picker Syntax Ref: https://developers.line.biz/en/reference/liff/#share-target-picker liff.shareTargetPicker(messages, options); 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!`) } }).catch(function (error) { // something went wrong before sending a message console.log('something wrong happen') }) 5 Bubbles
  9. Template messages Only a URI action can be set as

    an action Button Carousel Image Carousel
  10. const liffId = "LIFF_ID" await liff.init({ liffId }) await liff.ready

    if (!liff.isLoggedIn()) { liff.login({ redirectUri: "https://example.com/path" }); } else { const idToken = liff.getDecodedIDToken(); const profile = { userId: idToken?.sub, displayName: idToken?.name, pictureUrl: idToken?.picture, }; ... } LINE Login https://developers.line.biz/en/reference/liff/#login
  11. { "iss": "https://access.line.me", "sub": "U1234567890abcdef1234567890abcdef", "aud": "1234567890", "exp": 1504169092, "iat":

    1504263657, "amr": ["pwd"], "name": "Taro Line", "picture": "https://sample_line.me/aBcdefg123456" } liff.getDecodedIDToken() EXAMPLE DECODED ID TOKEN ====> USER ID ====> PICTURE URL ====> DISPLAY NAME
  12. liff.getFriendship() liff.getFriendship().then((friendship) => { if (!friendship.friendFlag) { window.location.href = `https://line.me/R/oaMessage/

    @premium-id/?${encodeURIComponent( '"กด ส่ ง"เพื่อรับลิง ก์ ชวนเพื่อน' )}`; } else { … } });
  13. Set Personalized Richmenu https://developers.line.biz/en/reference/messaging-api/#rich-menu const line = require("@line/bot-sdk"); const client

    = new line.Client({ channelAccessToken: "<channel access token>", }); client.linkRichMenuToUser("<user_id>", "<rich_menu_id>");
  14. Save Data to Redis https://samsung-invite-friend.aiya.ai/R/cOkrVS const body = {...} const

    code = "cOkrVS" const userId = "Uxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" await redis.set(`fgf-user:${userId}`, code); await redis.set(`fgf-code:${code}`,JSON.stringify(body));
  15. The Open Graph Protocol https://ogp.me/ <meta name="twitter:card" content="summary_large_image" /> <meta

    name="twitter:site" content="@samsungthailand" /> <meta name="twitter:creator" content="@samsungthailand" /> <meta name="twitter:url" content={config.TWITTER.url} /> <meta property="twitter:title" content={config.TWITTER.title} /> <meta property="twitter:description" content={config.TWITTER.description} /> <meta property="twitter:image:src" content={config.TWITTER.image} /> <meta property="twitter:image:alt" content="SAMSUNG Invite Friend" /> <meta property="og:title" content={config.OG.title} /> <meta property="og:description" content={config.OG.description} /> <meta property="og:image" content={config.OG.image} /> <meta property="og:url" content={config.OG.url} />
  16. https://invite.aiya.ai/xxx/join Mobile Detection export const isMobile = (userAgent: string) =>

    { let mobile = false; let ua = userAgent.toLowerCase(); if ( /(android|bb\d+|meego).+mobile|liff|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|…/i.test( ua ) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|…/i.test( ua.substr(0, 4) ) ) { mobile = true; } else if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(ua)) { mobile = true; } return mobile; };
  17. Serverless https://github.com/serverless-nextjs/serverless-next.js pageAppDev: component: '@sls-next/[email protected]' inputs: description: "aiya-ai" removeOldLambdaVersions: true

    tags: - cloudfront - nextjs bucketRegion: ap-southeast-1 bucketName: "aiya-ai-ap" bucketTags: - "cloudfront" cloudfront: distributionId: E1I4P19Z5XXXX aliases: [ 'invite.aiya.ai', ] … … 
 enableHTTPCompression: true timeout: defaultLambda: 15 apiLambda: 15 imageLambda: 15 name: defaultLambda: aiya-ai-default apiLambda: aiya-ai-api imageLambda: aiya-ai-image publicDirectoryCache: value: public, max-age=604800 test: /\.(gif|jpe?g|png|txt|xml)$/i policy: "arn:aws:iam::XXXXXXXX:policy/aiya-ai-policy" roleArn: "arn:aws:iam::XXXXXXXX:role/aiya-ai-role" build: cmd: 'yarn' args: ['build', 'page']