Ionic Framework 4 is almost here. Preview the beta docs and try it out now! Try Ionic 4 Beta

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/chroa/twitter-connect-plugin

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add https://github.com/chroa/twitter-connect-plugin --variable FABRIC_KEY=<Fabric API Key> --variable TWITTER_KEY=<Twitter Consumer Key> --variable TWITTER_SECRET=<Twitter Consumer Secret>
    $ 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