README.md
July 8, 2022 ยท View on GitHub

Capacitor Twitter
@capacitor-community/twitter
Capacitor community plugin for enabling TwitterKit capabilities
Sponsors
|
|
Intenseloop |
Maintainers
| Maintainer | GitHub | Social |
|---|---|---|
| Stewan Silva | stewones | @stewones |
Notice ๐
We're starting fresh under an official org. If you were using the previous npm package capacitor-twitter, please update your package.json to @capacitor-community/twitter. Check out changelog for more info.
Installation
Using npm:
npm install @capacitor-community/twitter
Using yarn:
yarn add @capacitor-community/twitter
Sync native files:
npx cap sync
API
- Login
- Logout
- isLogged
Usage
import { Twitter } from "@capacitor-community/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 --capacitorcd my-cap-appnpm install โ-save @capacitor-community/twittermkdir www && touch www/index.htmlnpx cap add ios- add the consumer keys at
capacitor.config.json
{
โฆ
"plugins": {
"Twitter": {
"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://(with nothing behind it)
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 --capacitorcd my-cap-appnpm install โ-save @capacitor-community/twittermkdir www && touch www/index.htmlnpx cap add android- add the consumer keys at
capacitor.config.json
{
โฆ
"plugins": {
"Twitter": {
"consumerKey": "xxx",
"consumerSecret": "yyy"
}
}
โฆ
}
- at twitter developer site, add this callback url:
twittersdk://(with nothing behind it) [extra step]in android case we need to tell Capacitor to initialise the plugin:
on your
MainActivity.javafile addimport com.getcapacitor.community.twitter.TwitterPlugin;and then inside the init callbackadd(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.
Example
License
MIT
Contributors โจ
Thanks goes to these wonderful people (emoji key):
Stew ๐ป ๐ |
Luca Ban ๐ |
eidanfi ๐ง |
This project follows the all-contributors specification. Contributions of any kind welcome!