npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-twitter-connect-wkwebview

v1.0.1

Published

Twitter Connect Plugin - Allows single-sign on logins using Twitter

Downloads

2

Readme

cordova-plugin-twitter-connect-wkwebview

Cordova/PhoneGap plugin to use Twitter Single Sign On

NOTE: This plugin has been extended from https://github.com/ManifestWebDesign/twitter-connect-plugin to make it can work with wkwebview.

Using Twitter's Fabric SDK, you can enable SSO with your Android and iOS apps. It's a fairly involved process, so I'll try to lay out every step necessary.

Install

Get a Fabric API key

The only thing we really need is the API key. Getting the API key is fairly tricky, but this process seems to work:

  1. Sign up for a Fabric account and then open https://fabric.io/kits/android/crashlytics/install. You don't need to do the onboarding process.
  2. Find the meta-data code block in AndroidManifest.xml
  3. Find your API Key pre filled in the code.
Create a Twitter app

Create a Twitter application and get the consumer key and consumer secret.

Add plugin to your Cordova app

Make sure you put in your valid API keys in their respective place.

cordova plugin add cordova-plugin-twitter-connect-wkwebview --variable FABRIC_KEY=<Fabric API Key> --variable TWITTER_KEY=<Twitter Consumer Key> --variable TWITTER_SECRET=<Twitter Consumer Secret>

For iOS, the deployment target needs to be at least 9.0. You can set this in the config.xml file like so:

<preference name="deployment-target" value="9.0" />
Dependencies

Dependencies have been added in the Android version for the core SDK (com.twitter.sdk.android.core) and for retrofit retrofit.* to simplify the REST URLs (See Square Retrofit)

Finished!

You should now be able to: cordova run android or cordova run ios

Phonegap Build

Add the following to your config:

<gap:plugin name="cordova-plugin-twitter-connect-wkwebview" source="npm" spec="1.0.1">
  <param name="FABRIC_KEY" value="<Fabric API Key>" />
  <param name="TWITTER_KEY" value="<Twitter Consumer Key>" />
  <param name="TWITTER_SECRET" value="<Twitter Consumer Secret>" />
</gap:plugin>

You'll need to specify iOS7 for TwitterKit

<preference name="deployment-target" value="7.0" />

Usage

This plugin adds an object to the window named TwitterConnect. The showUser method shows how to call any of the Twitter REST API methods using the TwitterAPIClient.

Login

Login using the .login method:

TwitterConnect.login(
  function(result) {
    console.log('Successful login!');
    console.log(result);
  },
  function(error) {
    console.log('Error logging in');
    console.log(error);
  }
);

The login reponse object is defined as:

{
  userName: '<Twitter User Name>',
  userId: '<Twitter User Id>',
  secret: '<Twitter Oauth Secret>',
  token: '<Twitter Oauth Token>'
}
Logout

Logout using the .logout method:

TwitterConnect.logout(
  function() {
    console.log('Successful logout!');
  },
  function() {
    console.log('Error logging out');
  }
);
ShowUser

Show a user's profile information using the a GET to the /1.1/users/show.json REST API call:

TwitterConnect.showUser(
  function(result) {
    console.log('User Profile:');
    console.log(result);
    console.log('Twitter handle :'+ result.screen_name);
  },
  function(error) {
    console.log('Error retrieving user profile');
    console.log(error);
  }
);

The user/show.json API returns a JSON response object containing all the published information as per the Twitter API specifications.

See Twitter GET users/show Developer Documentation

OpenComposer

Calls the tweet composer in order to send tweets with embedded images and other. Must be authenticated in order to open the composer.

TwitterConnect.openComposer('insert default text here, can be empty',
  function() {
    console.log('Success');
  },
  function() {
    console.log('Error');
  }
);
ShowTimeline

Launches a new view with a search timeline. Warning: this view will override the root view!

TwitterConnect.showTimeline('#fabric',
  function() {
    console.log('Success');
  },
  function() {
    console.log('Error');
  }
);

Troubleshooting

Android - Problem: "com.android.dex.DexException: Multiple dex files define Landroid/support"

Go to your Platforms/android/build.gradle

Add the following code to the end.

configurations {
	all*.exclude group: 'com.android.support', module: 'support-v4'
}

Thanks to @jineum