The 2017 Ionic Developer Survey Results are in!

Twitter Connect

Improve this doc

Plugin to use Twitter Single Sign On Uses Twitter's Fabric SDK

import { TwitterConnect } from '@ionic-native/twitter-connect';

constructor(private twitter: TwitterConnect) { }

...

function onSuccess(response) {
  console.log(response);

  // Will console log something like:
  // {
  //   userName: 'myuser',
  //   userId: '12358102',
  //   secret: 'tokenSecret'
  //   token: 'accessTokenHere'
  // }
}

this.twitter.login().then(onSuccess, onError);

this.twitter.logout().then(onLogoutSuccess, onLogoutError);

Repo: https://github.com/ManifestWebDesign/twitter-connect-plugin

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add twitter-connect-plugin --variable FABRIC_KEY=fabric_API_key
    $ npm install --save @ionic-native/twitter-connect
    
  2. Add this plugin to your app's module

Supported platforms

Instance Members

login()

Logs in

Returns: Promise<TwitterConnectResponse> returns a promise that resolves if logged in and rejects if failed to login

logout()

Logs out

Returns: Promise<any> returns a promise that resolves if logged out and rejects if failed to logout

showUser()

Returns user’s profile information

Returns: Promise<any> returns a promise that resolves if user profile is successfully retrieved and rejects if request fails

TwitterConnectResponse

Param Type Details
userName string

Twitter Username

userId string

Twitter User ID

secret string

Twitter OAuth Secret

token string

Twitter OAuth Token

API

Native

General