2016-07-20 17:55:20 +08:00
|
|
|
import { Plugin, Cordova } from './plugin';
|
2016-07-20 23:17:09 +08:00
|
|
|
|
|
|
|
|
2016-07-20 17:55:20 +08:00
|
|
|
/**
|
|
|
|
* @name Twitter Connect
|
|
|
|
* @description
|
|
|
|
* Plugin to use Twitter Single Sign On
|
|
|
|
* Uses Twitter's Fabric SDK
|
2016-08-11 19:55:26 +08:00
|
|
|
* ```typescript
|
|
|
|
* import {TwitterConnect} from 'ionic-native';
|
|
|
|
*
|
|
|
|
* function onSuccess(response) {
|
|
|
|
* console.log(response);
|
|
|
|
*
|
|
|
|
* // Will console log something like:
|
|
|
|
* // {
|
|
|
|
* // userName: 'myuser',
|
|
|
|
* // userId: '12358102',
|
|
|
|
* // secret: 'tokenSecret'
|
|
|
|
* // token: 'accessTokenHere'
|
|
|
|
* // }
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* TwitterConnect.login().then(onSuccess, onError);
|
|
|
|
*
|
|
|
|
* TwitterConnect.logout().then(onLogoutSuccess, onLogoutError);
|
|
|
|
* ```
|
2016-07-20 17:55:20 +08:00
|
|
|
*/
|
|
|
|
@Plugin({
|
|
|
|
plugin: 'twitter-connect-plugin',
|
|
|
|
pluginRef: 'TwitterConnect',
|
2016-08-11 19:55:26 +08:00
|
|
|
repo: 'https://github.com/ManifestWebDesign/twitter-connect-plugin',
|
2016-08-01 02:31:02 +08:00
|
|
|
install: 'ionic plugin add twitter-connect-plugin --variable FABRIC_KEY=fabric_API_key'
|
2016-07-20 17:55:20 +08:00
|
|
|
})
|
|
|
|
export class TwitterConnect {
|
|
|
|
/**
|
|
|
|
* Logs in
|
|
|
|
* @return {Promise<TwitterConnectResponse>} returns a promise that resolves if logged in and rejects if failed to login
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static login(): Promise<TwitterConnectResponse> {return; }
|
|
|
|
/**
|
|
|
|
* Logs out
|
|
|
|
* @return {Promise<any>} returns a promise that resolves if logged out and rejects if failed to logout
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static logout(): Promise<any> {return; }
|
2016-08-19 19:00:05 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns user's profile information
|
|
|
|
* @return {Promise<any>} returns a promise that resolves if user profile is successfully retrieved and rejects if request fails
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static showUser(): Promise<any> {return; }
|
2016-07-20 17:55:20 +08:00
|
|
|
}
|
|
|
|
export interface TwitterConnectResponse {
|
|
|
|
/**
|
|
|
|
* Twitter Username
|
|
|
|
*/
|
|
|
|
userName: string;
|
|
|
|
/**
|
|
|
|
* Twitter User ID
|
|
|
|
*/
|
|
|
|
userId: string;
|
|
|
|
/**
|
|
|
|
* Twitter OAuth Secret
|
|
|
|
*/
|
|
|
|
secret: string;
|
|
|
|
/**
|
|
|
|
* Twitter OAuth Token
|
|
|
|
*/
|
|
|
|
token: string;
|
|
|
|
}
|