|
2 | 2 |
|
3 | 3 | Capacitor plugin to enable some native twitter features
|
4 | 4 |
|
5 |
| -## Notice |
| 5 | +## API |
6 | 6 |
|
7 |
| -This plugin is currently under active development and has not yet been published. |
| 7 | +- Login |
| 8 | +- Logout |
| 9 | +- isLogged |
8 | 10 |
|
9 |
| -## iOS |
| 11 | +## iOS Setup |
10 | 12 |
|
11 |
| -- [x] login |
12 |
| -- [x] logout |
13 |
| -- [ ] share (wip) |
| 13 | +- `ionic start my-cap-app --capacitor` |
| 14 | +- `cd my-cap-app` |
| 15 | +- `npm install —save capacitor-twitter` |
| 16 | +- `mkdir www && touch www/index.html` |
| 17 | +- `npx cap add ios` |
| 18 | +- add the consumer keys at `capacitor.config.json` |
14 | 19 |
|
15 |
| -## Android |
| 20 | +``` |
| 21 | +{ |
| 22 | + … |
| 23 | + "plugins": { |
| 24 | + "TwitterPlugin": { |
| 25 | + "consumerKey": "xxx", |
| 26 | + "consumerSecret": "yyy" |
| 27 | + } |
| 28 | + } |
| 29 | +… |
| 30 | +} |
| 31 | +``` |
16 | 32 |
|
17 |
| -- [ ] login |
18 |
| -- [ ] logout |
19 |
| -- [ ] share |
| 33 | +- npx cap open ios |
| 34 | +- sign your app at xcode (general tab) |
| 35 | +- 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) |
| 36 | +- also at twitter developer site, add a new callback url in the same format: `twitterkit-your_consumer_api_key` |
20 | 37 |
|
21 |
| -Check it out on the [ionic sample app](https://github.com/stewwan/capacitor-twitter-example) using this plugin. |
| 38 | +Then you should be set to go. Run `ionic cap run ios --livereload` to start the server and then play it through xcode |
| 39 | + |
| 40 | +> 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. |
| 41 | +
|
| 42 | +## Android Setup |
| 43 | + |
| 44 | +- `ionic start my-cap-app --capacitor` |
| 45 | +- `cd my-cap-app` |
| 46 | +- `npm install —save capacitor-twitter` |
| 47 | +- `mkdir www && touch www/index.html` |
| 48 | +- `npx cap add android` |
| 49 | +- add the consumer keys at `capacitor.config.json` |
| 50 | + |
| 51 | +``` |
| 52 | +{ |
| 53 | + … |
| 54 | + "plugins": { |
| 55 | + "TwitterPlugin": { |
| 56 | + "consumerKey": "xxx", |
| 57 | + "consumerSecret": "yyy" |
| 58 | + } |
| 59 | + } |
| 60 | +… |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +- at twitter developer site, add the callback url in the following format: `twittersdk://` |
| 65 | +- `[extra step]` in android case we need to tell Capacitor to initialise the plugin: |
| 66 | + |
| 67 | +> on your `MainActivity.java` file add to the header `import cap.twitter.plugin.TwitterPlugin;` and then inside the init callback `add(TwitterPlugin.class);` |
| 68 | +
|
| 69 | +Now you should be set to go. Try `ionic cap run android --livereload` to start the server and then play/debug it through Android Studio |
| 70 | + |
| 71 | +> 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. |
| 72 | +
|
| 73 | +## Sample app |
| 74 | + |
| 75 | +Check it out on the [sample app](https://github.com/stewwan/capacitor-twitter-example) using this plugin. |
22 | 76 |
|
23 | 77 | Follow me [@Twitter](https://twitter.com/StewanSilva)
|
24 | 78 |
|
| 79 | +Cheers 🍻 |
| 80 | + |
25 | 81 | ## License
|
26 | 82 |
|
27 | 83 | MIT
|
0 commit comments