# @goldenapple/liff-extend

> line的liff用的東西

Latest version **2.0.4** (published 2019-10-24) · 0 weekly downloads

## Install

```sh
npm install @goldenapple/liff-extend
pnpm add @goldenapple/liff-extend
yarn add @goldenapple/liff-extend
bun add @goldenapple/liff-extend
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.4 |
| Published | 2019-10-24 |
| First published | 2019-09-04 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 134.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | eisekson, ruro |

## Links

- npm: https://www.npmjs.com/package/@goldenapple/liff-extend
- npm.io page: https://npm.io/package/@goldenapple/liff-extend

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^1.9.0

## Recent versions

- 2.0.4 (latest) — 2019-10-24
- 2.0.3 — 2019-10-21
- 2.0.2 — 2019-10-21
- 2.0.1 — 2019-10-21
- 2.0.0 — 2019-10-21
- 1.0.0 — 2019-09-04
- 0.0.1 — 2019-09-04

## README

# LiffExtend

在 angular 中更方便的使用 liff。

## 新增 service 到 component

```ts
import { LiffExtendService } from '@goldenapple/liff-extend';
@Component({
  // ...
})
export class SomeComponent implements OnInit {
  constructor(private liff: LiffExtendService) {
    this.liff.init('1612312312-97ooOOoY').then(async () => {
      const profile = await this.liff.getProfile();
      // ...
    });
  }
}
```

## 使用

```ts
// 參考:https://developers.line.biz/en/reference/liff/
// 初始化
await this.liff.init('1612312312-97ooOOoY');
// 取得使用者資料
const profile = await this.liff.getProfile();
// line id
this.userId = profile.userId;
// line name
this.displayName = profile.displayName;
// 大頭照
this.pictureUrl = profile.pictureUrl;
// 狀態訊息
this.statusMessage = profile.statusMessage;

// 判斷是否在liff裡，大部分的function都必須在liff才能使用
if (this.liff.isInClient()) {
  // 傳送訊息 內容參考:https://developers.line.biz/en/reference/liff/#send-messages
  this.liff.sendMessages([
    // ...
  ]);
  // 關閉視窗
  this.liff.closeWindow();

  // 掃描QR code
  let result = await this.liff.scanCode();
}

// 登入
if (!this.liff.isLoggedIn()) {
  this.liff.login();
}
```

---
_Source: https://npm.io/package/@goldenapple/liff-extend · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
