# capacitor-twitter

> Enable TwitterKit features for Capacitor

Latest version **2.0.0** (published 2020-03-25) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install capacitor-twitter
pnpm add capacitor-twitter
yarn add capacitor-twitter
bun add capacitor-twitter
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2020-03-25 |
| First published | 2019-03-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 819.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Stewan Silva |
| Maintainers | stewan |
| Keywords | capacitor, plugin, native, twitter, twitter kit, twitter ios, twitter android |

## Links

- npm: https://www.npmjs.com/package/capacitor-twitter
- Repository: https://github.com/stewwan/capacitor-twitter
- Homepage: https://github.com/stewwan/capacitor-twitter#readme
- Issues: https://github.com/stewwan/capacitor-twitter/issues
- npm.io page: https://npm.io/package/capacitor-twitter

## Dependencies (1)

- [@capacitor/core](https://npm.io/package/@capacitor/core.md) latest

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2020-03-25
- 0.0.14 — 2019-05-03
- 0.0.12 — 2019-05-03
- 0.0.13 — 2019-05-03
- 0.0.11 — 2019-03-31
- 0.0.10 — 2019-03-31
- 0.0.9 — 2019-03-31
- 0.0.8 — 2019-03-24
- 0.0.7 — 2019-03-23
- 0.0.6 — 2019-03-23
- 0.0.5 — 2019-03-23
- 0.0.4 — 2019-03-23
- 0.0.3 — 2019-03-22
- 0.0.2 — 2019-03-22
- 0.0.1 — 2019-03-22

## README

# capacitor-twitter [![npm version](https://badge.fury.io/js/capacitor-twitter.svg)](https://badge.fury.io/js/capacitor-twitter)

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

```js
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](https://github.com/stewwan/capacitor-twitter-example) using this plugin.

## You may also like

- [capacitor-fcm](https://github.com/stewwan/capacitor-fcm)
- [capacitor-analytics](https://github.com/stewwan/capacitor-analytics)
- [capacitor-crashlytics](https://github.com/stewwan/capacitor-crashlytics)
- [capacitor-intercom](https://github.com/stewwan/capacitor-intercom)

Follow me [@Twitter](https://twitter.com/StewanSilva)

Cheers 🍻

## License

MIT

---
_Source: https://npm.io/package/capacitor-twitter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
