This package has been deprecated

Author message:

This plugin has been moved to the capacitor community org 🎉. Please install it from the newer package @capacitor-community/twitter

capacitor-twitter
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

capacitor-twitter npm version

Capacitor plugin to enable some native twitter features such as login, logout and check if whether user is logged in or not.

API

  • Login
  • Logout
  • isLogged

Usage

import { Twitter } from 'capacitor-twitter';
const twitter = new Twitter();
 
twitter
  .login()
  .then(r => console.log(r)) // { authToken:string, authTokenSecret:string, userName:string, userID:string }
  .catch(err => console.log(err));
 
twitter
  .isLogged()
  .then(r => console.log(r)) // returns { in: boolean, out: boolean }
  .catch(err => console.log(err));
 
twitter.logout();

iOS setup

  • ionic start my-cap-app --capacitor
  • cd my-cap-app
  • npm install —-save capacitor-twitter
  • mkdir www && touch www/index.html
  • npx cap add ios
  • add the consumer keys at capacitor.config.json
{
 …
  "plugins": {
   "TwitterPlugin": {
      "consumerKey": "xxx",
      "consumerSecret": "yyy"
    }
  }
…
}
  • npx cap open ios
  • sign your app at xcode (general tab)
  • add a new url type at Xcode (info tab) and make sure the url scheme follows the format twitterkit-your_consumer_api_key (grab a key at twitter developer site)
  • also at twitter developer site, add a new callback url in the same format: twitterkit-your_consumer_api_key

Then you should be set to go. Run ionic cap run ios --livereload to start the server and play it through xcode

Important Notice: every time you change a native code you may need to clean the cache (Product > Clean build folder) and then run the app again.

Android setup

  • ionic start my-cap-app --capacitor
  • cd my-cap-app
  • npm install —-save capacitor-twitter
  • mkdir www && touch www/index.html
  • npx cap add android
  • add the consumer keys at capacitor.config.json
{
 …
  "plugins": {
   "TwitterPlugin": {
      "consumerKey": "xxx",
      "consumerSecret": "yyy"
    }
  }
…
}
  • at twitter developer site, add this callback url: twittersdk://
  • [extra step] in android case we need to tell Capacitor to initialise the plugin:

on your MainActivity.java file add import io.stewan.capacitor.twitter.TwitterPlugin; and then inside the init callback add(TwitterPlugin.class);

Now you should be set to go. Try ionic cap run android --livereload to start the server and play/debug it through Android Studio

Important Notice: every time you change a native code you may need to clean the cache (Build > Clean Project | Build > Rebuild Project) and then run the app again.

Sample app

Check it out on the sample app using this plugin.

You may also like

Follow me @Twitter

Cheers 🍻

License

MIT

Package Sidebar

Install

npm i capacitor-twitter

Weekly Downloads

9

Version

2.0.0

License

MIT

Unpacked Size

840 kB

Total Files

186

Last publish

Collaborators

  • stewan