-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(line-login): add plugin (#2782)
* add line-login * Update index.ts * add params and result type * Update index.ts * Update index.ts
- Loading branch information
1 parent
b61b339
commit dc4183d
Showing
1 changed file
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |