# cordova-line-login-plugin

> LineSDKを使用してLINEログインを簡単に実装するためのcordovaプラグイン。

Latest version **1.2.11** (published 2020-10-07) · 0 weekly downloads

## Install

```sh
npm install cordova-line-login-plugin
pnpm add cordova-line-login-plugin
yarn add cordova-line-login-plugin
bun add cordova-line-login-plugin
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.11 |
| Published | 2020-10-07 |
| First published | 2019-07-12 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 42 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 19 |
| Maintainers | nrikiji |

## Links

- npm: https://www.npmjs.com/package/cordova-line-login-plugin
- Repository: https://github.com/nrikiji/cordova-line-login-plugin
- Homepage: https://github.com/nrikiji/cordova-line-login-plugin#readme
- Issues: https://github.com/nrikiji/cordova-line-login-plugin/issues
- npm.io page: https://npm.io/package/cordova-line-login-plugin

## Recent versions

- 1.2.11 (latest) — 2020-10-07
- 1.2.10 — 2020-07-19
- 1.2.9 — 2020-07-19
- 1.2.8 — 2020-07-12
- 1.2.7 — 2020-06-04
- 1.2.6 — 2020-05-12
- 1.2.5 — 2019-12-27
- 1.2.4 — 2019-12-27
- 1.2.3 — 2019-12-12
- 1.2.2 — 2019-10-02
- 1.2.1 — 2019-10-02
- 1.2.0 — 2019-09-29
- 1.1.0 — 2019-09-17
- 1.0.3 — 2019-07-15
- 1.0.2 — 2019-07-15
- … 3 more at https://npm.io/package/cordova-line-login-plugin/versions

## README

# cordova-line-login-plugin
A cordova plugin for easy implementation of LINE login using LineSDK.　　

The function login, logs out, acquires, verifies, and refreshes the access token. The version of LineSDK you are using is as follows.  

iOS：5.5.1  
Android：5.3.1  

cordova >= 7.1.0  
cordova-ios >= 4.5.0  
cordova-android >= 8.0.0  

The flow until incorporation is as follows  
Create a business account corresponding to LINE login from "LINE BUSINESS CENTER". Select NATIVE_APP for Application Type.

### ios
1. "IOS Bundle ID" "iOS Scheme" is set from "LINE DEVELOPERS".
1. When using swift5, specify version in config.xml. (Default is swift4)
1. Install this plugin
1. Implementing the program

```
example)When using swift5
config.xml  
<platform name="ios">
  <preference name="UseSwiftLanguageVersion" value="5" />
</platform>
```

### android
1. "Android Package Name" "Android Package Signature" "Android Scheme" is set from "LINE DEVELOPERS"
1. Install this plugin
1. Implementing the program

```
example)  
Android Package Name : com.example.sample
Android Package Signature : 11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:gg:hh:ii:jj:kk
Android Scheme : com.example.sample://
```

## Requirement
https://github.com/akofman/cordova-plugin-add-swift-support  

## Installation
cordova plugin add cordova-line-login-plugin

## Supported Platforms
- iOS
- Android

## LINE SDK
This plugin use the SDKs provided by LINE. More information about these in their documentation for [iOS](https://developers.line.me/ja/docs/ios-sdk/) or [Android](https://developers.line.me/ja/docs/android-sdk/)

## Usage

### Example

Usage examples with ionic
```js
angular.module('starter', ['ionic'])
  .run(function($ionicPlatform) {
    ・・・

    // initialize
    lineLogin.initialize({channel_id: "your_chanel_id"});
  })
  .controller("LineCtrl", function($scope) {
    $scope.onLineLogin = function() {
      // login...
      lineLogin.login(
        function(result) {
          console.log(result); // {userID:12345, displayName:'user name', pictureURL:'thumbnail url'}
        }, function(error) {
          console.log(error);
        });
    }

    $scope.onLineLogout = function() {
      // logout...
      lineLogin.logout(
        function(result) {
          console.log(result);
        }, function(error) {
          console.log(error);
        });
    }

    $scope.onLineLoginWeb = function() {
      // login with web...(iOS only)
      lineLogin.loginWeb(
        function(result) {
          console.log(result); // {userID:12345, displayName:'user name', pictureURL:'thumbnail url'}
        }, function(error) {
          console.log(error);
        });
    }

    $scope.onLineGetAccessToken = function() {
      // get access token
      lineLogin.getAccessToken(
        function(result) {
          // success
          console.log(result); // {accessToken:'xxxxxxxx', expireTime: 123456789}
        }, function(error) {
          // failed
        });
    }

    $scope.onLineVerifyAccessToken = function() {
      // verify current access token
      lineLogin.verifyAccessToken(
        function() {
          // success
        }, function(error) {
          // failed
        });
    }

    $scope.onLineRefreshAccessToken = function() {
      // refresh access token
      lineLogin.verifyAccessToken(
        function(accessToken) {
          // success
        }, function(error) {
          // failed
        });
    }

  });
```

### Error Code
error callback returns an error of the form 　
```
{
  code: -1: Invalid parameter, -2:SDK returned an error, -3: Unknown error
  sdkErrorCode: Error code returned by SDK
  description: Error message
}
```

## use in capacitors

### install
```
$ npm install cordova-line-login-plugin
```

### iOS configuration

Overwrite AppDelegate and info.plist in capcitor or add value Please take the following actions as I have not found a way to do so.  
Please note that you will have to deal with this every time you recreate the ios directory.  

In file ios/App/App/AppDelegate.swift add or replace the following:
```
+ import LineSDK
  [...]
   func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
-   return CAPBridge.handleOpenUrl(url, options)
+     if CAPBridge.handleOpenUrl(url, options) {
+        return LoginManager.shared.application(app, open: url)
+     } else {
+         return false
+     }
   }
```

Add the following in the ios/App/App/info.plist file:  
```
+ <key>CFBundleURLTypes</key>
+ <array>
+     <dict>
+         <key>CFBundleTypeRole</key>
+         <string>Editor</string>
+         <key>CFBundleURLSchemes</key>
+         <array>
+             <string>line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+         </array>
+     </dict>
+ </array>
+ <key>LSApplicationQueriesSchemes</key>
+ <array>
+     <string>lineauth2</string>
+ </array>
```

---
_Source: https://npm.io/package/cordova-line-login-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
