GithubHelp home page GithubHelp logo

justjavac / react-native-login-twitter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from goldenowlasia/react-native-twitter-signin

7.0 5.0 15.0 33.65 MB

This package provides necessary code to get your social sign in using Twitter works with least pain possible.

License: MIT License

JavaScript 100.00%

react-native-login-twitter's Introduction

npm version

Note: this guide is for TwitterKit 3.3 and ReactNative 0.56+.

React Native : Twitter Signin

This package provides necessary code to get your social sign in using Twitter works with least pain possible.

Table of contents

Prerequisites

Go to Twitter Apps to create your app so that you can obtain API key and secret, note:

  • Remember to set a Callback Url, whatever will work
  • By default, Twitter won't allow you to grab user's email, so you have to apply for a permission for your app to retrieve user's email

Here is how callbacks would look like: callbacks

From Twitter Kit 3.3, Fabric is no longer required.

Setup

Firstly, install the npm package:

npm install react-native-login-twitter --save

or

yarn add react-native-login-twitter

iOS

  • Link RNTwitterSignIn.xcodeproj by running react-native link react-native-login-twitter
  • Configure Info.Plist like below, replace <consumerKey> with your own key:
// Info.plist
<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>twitterkit-<consumerKey></string>
    </array>
  </dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>twitter</string>
    <string>twitterauth</string>
</array>
  • Modify AppDelegate.m to #import <TwitterKit/TWTRKit.h> and handle openUrl
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
  return [[Twitter sharedInstance] application:app openURL:url options:options];
}
  • Add TwitterKit:

With CocoaPods

  • Add TwitterKit to your Podfile
// Podfile
target 'MyApp' do
  # use_frameworks!
  pod 'TwitterKit', '~> 3.3.0'
end
  • Run pod install

Manually

Android

Run react-native link react-native-login-twitter, or:

On Android, it will use Gradle so all you need to do is to point to the correct project location:

  • In your ${project_dir}/android/settings.gradle add this:

    include ':react-native-login-twitter'
    project(':react-native-login-twitter').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-login-twitter/android')
    
  • In your ${project_dir}/android/app/build.gradle add this:

    depedencies {
       ...
       compile project(':react-native-login-twitter')
       ...
    }
    
  • In you MainApplication.java makes use of the package as following:

        /**
        * A list of packages used by the app. If the app uses additional views
        * or modules besides the default ones, add more packages here.
        */
        @Override
        protected List<ReactPackage> getPackages() {
           return Arrays.<ReactPackage>asList(
             new MainReactPackage(),
             new FacebookLoginPackage(),
             new TwitterSigninPackage(),
             new RNGoogleSigninPackage(this),
             new VectorIconsPackage(),
             new RNSvgPackage()
           );
         }

Keeps in mind that all the configure is for your build tools to recognise the files. So open your Xcode and Android Studio to try making builds and make sure they pass.

Usage

  • See the Example project.

Sample

Todo

The code was extracted from my project so it satisfies my current need, if you need extra functions, feel free to submit to issue list or fork it.

Copyright and license

Code and documentation copyright 2016 Justin Nguyen. Code released under the MIT license.

Inspiration

react-native react-native-login-google

react-native-login-twitter's People

Contributors

daisy1754 avatar djinne avatar franjospark avatar hideyaswider avatar justjavac avatar mauriliohrc avatar melihberberolu avatar mrnickel avatar phuongwd avatar rhernandez513 avatar smartarray avatar sylvain-l avatar thethanghn avatar xmarianox avatar xuanhescript avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-native-login-twitter's Issues

Compatibility with React Native 0.64.0

Hello,
I am using this library in my React Native project.
When I try to build my android application using gradle, the manifest merge fails.

Here is how I want to build my Android project:

  • cd android
  • gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug

I have this error message:
...\node_modules\react-native-login-twitter\android\build\intermediates\tmp\manifest\androidTest\debug\manifestMerger1735801381514322441.xml:5:5-74 Error:
uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [com.facebook.react:react-native:0.64.0] C:\Users\mkn5.gradle\caches\transforms-2\files-2.1\3c60dec4d2e7311185325b2ffd835b57\jetified-react-native-0.64.0\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="com.facebook.react" to force usage (may lead to runtime failures)

Please note that my android/build.gradle file has a minSdkVersion = 21.

Do you have any idea?
For more information, don't hesitate.
Thank you

the package needs to be updated to remove the .git directory from the package

error:
`
npm ERR! code EISGIT
npm ERR! path /Users/guilhermeramos/Desktop/projects/fillgi-react-native/node_modules/react-native-login-twitter
npm ERR! git /Users/guilhermeramos/Desktop/projects/fillgi-react-native/node_modules/react-native-login-twitter: Appears to be a git repo or submodule.
npm ERR! git /Users/guilhermeramos/Desktop/projects/fillgi-react-native/node_modules/react-native-login-twitter
npm ERR! git Refusing to remove it. Update manually,
npm ERR! git or move it out of the way first.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/guilhermeramos/.npm/_logs/2020-03-18T03_23_28_740Z-debug.log
`

ref to fix it:
APSL/react-native-version-number#13

iOS integration is not working in any way at all!!

Callback URL
twitterkit-{API_KEY}://
twittersdk://

API key:
l***************h

info.plist:

<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleTypeRole</key>
			<string>Editor</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>twitterkit-{AP_KEY}</string>
			</array>
		</dict>
	</array>
	<key>CFBundleVersion</key>
	<string>1</string>
	<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>twitter</string>
		<string>twitterauth</string>
	</array>

Error:

2020-07-28 20:02:05.536 [fatal][tid:main] Exception 'Attempt made to Log in or Like a Tweet without a valid Twitter Kit URL Scheme set up in the app settings. Please see https://dev.twitter.com/twitterkit/ios/installation for more info.' was thrown while invoking logIn on target RNTwitterSignIn with params (
    3028,
    3029
)
callstack: (
	0   CoreFoundation                      0x00007fff23e3cf0e __exceptionPreprocess + 350
	1   libobjc.A.dylib                     0x00007fff50ba89b2 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff23e3cd4c +[NSException raise:format:] + 188
	3   TwitterKit                          0x000000010be838ad -[TWTRTwitter logInWithViewController:completion:] + 649
	4   superduperradar                     0x0000000109a9bd61 -[RNTwitterSignIn logIn:rejecter:] + 241
	5   CoreFoundation                      0x00007fff23e43e8c __invoking___ + 140
	6   CoreFoundation                      0x00007fff23e41071 -[NSInvocation invoke] + 321
	7   CoreFoundation                      0x00007fff23e41344 -[NSInvocation invokeWithTarget:] + 68
	8   superduperradar                     0x0000000109823d94 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2660
	9   superduperradar                     0x0000000109827f61 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 801
	10  superduperradar                     0x0000000109827a36 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 134
	11  superduperradar                     0x000000010982799c ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28
	12  libdispatch.dylib                   0x000000010c042f11 _dispatch_call_block_and_release + 12
	13  libdispatch.dylib                   0x000000010c043e8e _dispatch_client_callout + 8
	14  libdispatch.dylib                   0x000000010c051d97 _dispatch_main_queue_callback_4CF + 1149
	15  CoreFoundation                      0x00007fff23da0909 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
	16  CoreFoundation                      0x00007fff23d9b459 __CFRunLoopRun + 2041
	17  CoreFoundation                      0x00007fff23d9a944 CFRunLoopRunSpecific + 404
	18  GraphicsServices                    0x00007fff38ba6c1a GSEventRunModal + 139
	19  UIKitCore                           0x00007fff48c8b9ec UIApplicationMain + 1605
	20  superduperradar                     0x0000000109415bb0 main + 112
	21  libdyld.dylib                       0x00007fff51a231fd start + 1
)

HELP

[Error: Failed to get request token]

When i am trying to login . it shows the error i already did the changes in callBack url (twittersdk://) and (twitterkit-Consumer_key://) h=but still i am getting this error.

[Error: Failed to get request token]

and showing "Unable to complete the action." in toast
any help regarding this will be appreciated .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.