npm i --save @nativescript/twitter
                    
                    - Version: 1.0.1
- GitHub: https://github.com/NativeScript/plugins
- NPM: https://www.npmjs.com/package/%40nativescript%2Ftwitter
- Downloads:
- Last Day: 0
- Last Week: 0
- Last Month: 22
@nativescript/twitter
A plugin that allows you to authenticate a user with their Twitter account.
Contents
- Installation
- Prerequisites
- Usage
- [License]
Installation
npm install @nativescript/twitterPrerequisites
- 
Go to Twitter Apps and create your app to obtain the API key and secret. 
- 
Set a Callback Url with the Twitter.callbackproperty. Whatever will work. For iOS, add the following code to theApp_Resources/ios/Info.plistfile, and replace theyourschemetext with your URL.
<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>yourscheme></string>
    </array>
  </dict>
</array>- Request for the user's permission for your app to retrieve their email. By default, Twitter won't allow you to grab a user's email.
Here is what callbacks would look like:

Usage
Initializing Twitter Sign-in
To set up Twitter Sign in, call the Twitter class's init() method passing it the consumer key and the consumer secret.
import { Twitter, TwitterSignIn } from '@nativescript/twitter';
Twitter.callback = 'yourscheme://';
Twitter.init(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);Sign in a user
To sign a user in, call the logIn() method on the TwitterSignIn class.
TwitterSignIn.logIn()
	.then((session) => {
		// session.authToken
		// session.authTokenSecret
	})
	.catch((e) => {});API
callback
Twitter.callback = "the callback url"The callback URL
init()
Twitter.init(consumerKey, consumerSecret)Initializes the Twitter authentification with the specified key and secret.
| Parameter | Type | 
|---|---|
| consumerKey | string | 
| consumerSecret | string | 
TwitterSignIn
logIn()
TwitterSignIn.logIn().then((session: Session) =>{
}).catch((err) =>{
})Session
| Property | Type | Description | 
|---|---|---|
| authToken | string | readonly | 
| authTokenSecret | string | readonly | 
| userName | string | readonly | 
| userId | string | readonly | 
| ios | any | readonly | 
| android | any | readonly | 
getCurrentUser()
TwitterSignIn.getCurrentUser().then((user: TwitterUser) =>{
}).catch((err) =>{
})TwitterUser
| Property | Type | Description | 
|---|---|---|
| formattedScreenName | string | readonly | 
| isProtected | boolean | readonly | 
| isVerified | boolean | readonly | 
| name | string | readonly | 
| profileImageUrl | string | readonly | 
| profileUrl | string | readonly | 
| screenName | string | readonly | 
| userId | string | readonly | 
logOut()
TwitterSignIn.logIn()License
Apache License Version 2.0