feat(line-login): add plugin (#2782)

* add line-login

* Update index.ts

* add params and result type

* Update index.ts

* Update index.ts
This commit is contained in:
nrikiji 2018-11-03 01:09:15 +09:00 committed by Daniel Sogl
parent b61b33987f
commit dc4183da07

View File

@ -0,0 +1,137 @@
import { Injectable } from '@angular/core';
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
export interface LineLoginParams {
/**
* Line Channel ID
*/
channel_id: string;
}
export interface LineLoginProfile {
/**
* Line User ID
*/
userID: string;
/**
* Line Profile Image URL
*/
pictureURL: string;
/**
* Line Profile Name
*/
displayName: string;
}
export interface LineLoginAccessToken {
/**
* Line Access Token
*/
accessToken: string;
/**
* Line Access Token Expire Time
*/
expireTime: string;
}
/**
* @name Line Login
* @description
* The function login, logs out, acquires, verifies, and refreshes the access token. The version of LineSDK you are using is as follows.
*
* @usage
* ```typescript
* import { LineLogin } from '@ionic-native/line-login';
*
*
* constructor(private lineLogin: LineLogin) { }
*
* ...
*
*
* this.lineLogin.initialize({ channel_id: "xxxxxxxxxx" })
*
* this.lineLogin.login()
* .then(result => console.log(result))
* .catch(error => console.log(error))
*
* ```
*
* @interfaces
* LineLoginParams
* LineLoginProfile
* LineLoginAccessToken
*
*/
@Plugin({
pluginName: 'LineLogin',
plugin: 'cordova-line-login-plugin',
pluginRef: 'lineLogin',
repo: 'https://github.com/nrikiji/cordova-line-login-plugin',
install: 'ionic cordova plugin add https://github.com/nrikiji/cordova-line-login-plugin.git --variable LINE_CHANNEL_ID="your_line_channel_id"',
installVariables: ['LINE_CHANNEL_ID'],
platforms: ['Android', 'iOS']
})
@Injectable()
export class LineLogin extends IonicNativePlugin {
/**
* Initialize
* @param param LineLoginParams
* @return {Promise<any>}
*/
@Cordova()
initialize(param: LineLoginParams): Promise<any> {
return;
}
/**
* Login
* @return {Promise<LineLoginProfile>}
*/
@Cordova({
successIndex: 1,
errorIndex: 2
})
login(): Promise<LineLoginProfile> {
return;
}
/**
* Logout
* @return {Promise<any>}
*/
@Cordova()
logout(): Promise<any> {
return;
}
/**
* Get Access Token
* @return {Promise<LineLoginAccessToken>}
*/
@Cordova()
getAccessToken(): Promise<LineLoginAccessToken> {
return;
}
/**
* Verify AccessToken
* @return {Promise<any>}
*/
@Cordova()
verifyAccessToken(): Promise<any> {
return;
}
/**
* Refresh Access Token
* @return {Promise<any>}
*/
@Cordova()
refreshAccessToken(): Promise<any> {
return;
}
}