Giter Site home page Giter Site logo

react-native-twitter-signin'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-twitter-signin --save

iOS

  • Link RNTwitterSignIn.xcodeproj by running react-native link react-native-twitter-signin
  • 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-twitter-signin, 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-twitter-signin'
    project(':react-native-twitter-signin').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-twitter-signin/android')
    
  • In your ${project_dir}/android/app/build.gradle add this:

    depedencies {
       ...
       compile project(':react-native-twitter-signin')
       ...
    }
    
  • 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-facebook-login

react-native-twitter-signin's People

Contributors

daisy1754 avatar djinne avatar franjospark avatar hideyaswider avatar khalid283 avatar kkusanagi avatar lxcid avatar mauriliohrc avatar melihberberolu avatar mrnickel avatar phuongwd avatar rhernandez513 avatar sylvain-l avatar thethanghn avatar xmarianox avatar ziyoshams avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-twitter-signin's Issues

Android compile error in TwitterSigninModule

Please update your code for solve Android compile error. Thanks.

//TwitterSigninModule.java

// ...

@Override
public void onNewIntent(Intent intent) {

}

@Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
    if(twitterAuthClient != null && twitterAuthClient.getRequestCode()==requestCode) {
        boolean twitterLoginWasCanceled = (resultCode == RESULT_CANCELED);
        twitterAuthClient.onActivityResult(requestCode, resultCode, data);
    }
}

[Question] Logging Out Functionality?

Hey @GoldenOwlAsia great repo, and it worked as expected on the first try!

I was wondering if it was possible to log a user out? I was able to successfully log in once, but I would like to log out so that another Twitter user could log in.

Is there any way to achieve this right now? I'm not an expert at Objective C, but I could only find one logIn method available to me.

Please let me know what you think, and thanks again!

TwitterSigninModule is not abstract and does not override abstract method onNewIntent

React-native 0.35


/Users/job/workspace/spartask-mobile/node_modules/react-native-twitter-signin/android/src/main/java/com/goldenowl/twittersignin/TwitterSigninModule.java:32: error: TwitterSigninModule is not abstract and does not override abstract method onNewIntent(Intent) in ActivityEventListener
public class TwitterSigninModule extends ReactContextBaseJavaModule implements ActivityEventListener {
       ^
/Users/job/workspace/spartask-mobile/node_modules/react-native-twitter-signin/android/src/main/java/com/goldenowl/twittersignin/TwitterSigninModule.java:88: error: method does not override or implement a method from a supertype
    @Override
    ^
2 errors
:react-native-twitter-signin:compileReleaseJavaWithJavac FAILED

'TwitterSignin.login' failed

Follow the instructions as written, but what i get is this

undefined is not an object(evaluating 'TwitterSignin.logIn')

Support for React Native v0.40

On RN v0.40, iOS native headers have been moved. Imports of RN Headers should be changed from:

#import "RCTBridge.h"

to

#import <React/RCTBridge.h>

createJSModules method does not override or implement a method from a supertype

Hi,

react-native: 0.47.2
react-native-twitter-signin: 1.0.2

There is an error while building:

:react-native-twitter-signin:compileReleaseJavaWithJavac ...node_modules\react-native-twitter-signin\
android\src\main\java\com\goldenowl\twittersignin\TwitterSigninPackage.java:28:
error: method does not override or implement a method from a supertype
    @Override
    ^
1 error

It seems createJSModules @OverRide is deprecated: oblador/react-native-vector-icons#515

If it is commented, you can build again:

    //@Override
    public List<Class<? extends JavaScriptModule>> createJSModules() {
        return Collections.emptyList();
    }

Import "RCTEventDispatcher.h"

Hey, in first place let me thank you for this package.

I've been able to run it on android however installing fabric successfully and after adding TwitterSignIn.m and TwitterSignIn.h to Libraries
#import "RCTEventDispatcher.h"
displays error, file not found.
Any idea whats missing? Isn't RCTEventDispatcher from react?

Fabric called multiple times

Nothing happens when i try to login, except the message below in log:
[Fabric] [Fabric +with] called multiple times. Only the first call is honored, please pass all kits you wish to initialize

Earlier everything worked perfectly, but then i had an error in other package and while i was fighting it, i have made npm update , react-native link and also included Pod system

Googling doesn't helped, it seems i'm the first with this error

Cannot read property 'init' of undefined

Hello @GoldenowlConsultingCompany , thanks for the tutorial.
I have one issue. I went through the tutorial and followed all the instruction.

const { RNTwitterSignIn } = NativeModules;
const Constants = {
TWITTER_CONSUMER_KEY: '',
TWITTER_CONSUMER_SECRET: '',
};

RNTwitterSignIn.init(Constants.TWITTER_CONSUMER_KEY, Constants.TWITTER_CONSUMER_SECRET);
While initializing RNTwitterSignIn with TWITTER_CONSUMER_KEY and TWITTER_CONSUMER_SECRET, app got crash. It says

Cannot read property 'init' of undefined

Please check the below screen shot. Please let me know where i am going wrong.
Thanks

simulator screen shot 05-aug-2017 7 30 48 pm

Could not invoke TwitterSignin.logIn

Exception in native call
java.lang.RuntimeException: Could not invoke TwitterSignin.logIn
at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:359)
at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:136)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:148)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:345)
at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:136) 
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
at android.os.Handler.handleCallback(Handler.java:746) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) 
at android.os.Looper.loop(Looper.java:148) 
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196) 
at java.lang.Thread.run(Thread.java:818) 
Caused by: java.lang.NoClassDefFoundError: com.twitter.sdk.android.tweetui.internal.UserSessionProvider
at com.twitter.sdk.android.tweetui.TweetUi.onPreExecute(TweetUi.java:94)
at io.fabric.sdk.android.InitializationTask.onPreExecute(InitializationTask.java:44)
at io.fabric.sdk.android.services.concurrency.AsyncTask.executeOnExecutor(AsyncTask.java:611)
at io.fabric.sdk.android.services.concurrency.PriorityAsyncTask.executeOnExecutor(PriorityAsyncTask.java:43)
at io.fabric.sdk.android.Kit.initialize(Kit.java:69)
at io.fabric.sdk.android.Fabric.initializeKits(Fabric.java:439)
at io.fabric.sdk.android.Fabric.init(Fabric.java:383)
at io.fabric.sdk.android.Fabric.setFabric(Fabric.java:341)
at io.fabric.sdk.android.Fabric.with(Fabric.java:312)
at com.goldenowl.twittersignin.TwitterSigninModule.logIn(TwitterSigninModule.java:58)
at java.lang.reflect.Method.invoke(Native Method) 
at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:345) 
at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:136) 
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
at android.os.Handler.handleCallback(Handler.java:746) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) 
at android.os.Looper.loop(Looper.java:148) 
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196) 
at java.lang.Thread.run(Thread.java:818) 

Java linker issue

Followed all your instructions, and I've integrated with lots of other RN modules.

A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not find com.twitter.sdk.android:twitter:1.13.1.
Searched in the following locations:
file:/Users/webfreelance10/nerdhq/node_modules/react-native/android/com/twitter/sdk/android/twitter/1.13.1/twitter-1.13.1.pom
file:/Users/webfreelance10/nerdhq/node_modules/react-native/android/com/twitter/sdk/android/twitter/1.13.1/twitter-1.13.1.aar
file:/usr/local/opt/android-sdk/extras/android/m2repository/com/twitter/sdk/android/twitter/1.13.1/twitter-1.13.1.pom
file:/usr/local/opt/android-sdk/extras/android/m2repository/com/twitter/sdk/android/twitter/1.13.1/twitter-1.13.1.aar
file:/usr/local/opt/android-sdk/extras/google/m2repository/com/twitter/sdk/android/twitter/1.13.1/twitter-1.13.1.pom
file:/usr/local/opt/android-sdk/extras/google/m2repository/com/twitter/sdk/android/twitter/1.13.1/twitter-1.13.1.aar
Required by:
EAPlay:app:unspecified > EAPlay:react-native-twitter-signin:unspecified

Not used default twitter app loggedIn account in ios

Hi...

This is great package for login with twitter for react native.It is working good.But I have one issue.

Twitter app is installed in my ios device and i logged in with my twitter account in twitter app.After that when I tried to login with twitter using this package in my react native app,it does not use that twitter account and opening login screen.

By default ,it has to use default logged in twitter account of Twitter app just like facebook provides.

i could not follow the whole dependecies

extends SocialButton // Is undefined
Constants.TWITTER_COMSUMER_KEY, Constants.TWITTER_CONSUMER_SECRET // is undefined

or can i create a class extending from React.Component?

or please give un full example...

In your Read Me, I believe you meant MainApplication.java

Not sure how else to contact you guys about this but usually

      @Override
        protected List<ReactPackage> getPackages() {
           return Arrays.<ReactPackage>asList(
             new MainReactPackage(),
             new FacebookLoginPackage(),
             new TwitterSigninPackage(),
             new RNGoogleSigninPackage(this),
             new VectorIconsPackage(),
             new RNSvgPackage()
           );
         }

Resides in android/app/src/…/MainApplication.java file, not MainActivity.java
(at least according to the React Native docs; this is also the place react-native link puts the above code)

Unable to logut folowing example code

if I try to logout in next session after log in I get this:

Must initialize Twitter before using getInstance()
checkInitialized
    Twitter.java:143
getInstance
    Twitter.java:151
getInstance
    TwitterCore.java:88
logOut
    TwitterSigninModule.java:97
invoke
    Method.java
invoke
    Method.java:372
invoke
    JavaMethodWrapper.java:374
invoke
    JavaModuleWrapper.java:162
run
    NativeRunnable.java
handleCallback
    Handler.java:739
dispatchMessage
    Handler.java:95
dispatchMessage
    MessageQueueThreadHandler.java:31
loop
    Looper.java:135
run
    MessageQueueThreadImpl.java:194
run
    Thread.java:818

We should call init before logout perhaps

reproduce:

  • open app
  • log in via twitter
  • close(kill) app
  • open app
  • try to log out

Failed to get request token in android

i'm facing the below issue when i click on twitter-login button
com.twitter.sdk.android.core.TwitterAuthException: Failed to get request token
can some one help me in this, its bit urgent.

Thanks in advance

How to get User's image?

I am using react-native-twitter-signin. I want to receive user's profile picture url. Any ideas?

Not receiving response

I am using react-native-twitter-signin in my react native app. All working fine but after connecting my app with twitter account I am not receiving any response.

I copied whole code, put my api key and ap secret but not getting anything.

Undefined RNTwitterSignIn.init

Hi i just wanna is how can i resolve this issue?

I Got Error when i running the project..

simulator screen shot - iphone 6 - 2017-09-21 at 11 11 35

Here may code:

function twitterPressHandler() {
  
  console.log('Twitter functions goes here!');

  RNTwitterSignIn.init(Constants.TWITTER_COMSUMER_KEY, Constants.TWITTER_CONSUMER_SECRET);
  RNTwitterSignIn.logIn()
    .then((loginData)=>{
      console.log(loginData);
      const { authToken, authTokenSecret } = loginData;
      if (authToken && authTokenSecret) {
        this.setState({
          isLoggedIn: true,
        });
      }
    }).catch((error)=>{
      console.log(error);
    });

}

I hope i can get resolution on this issue thanks alot!

Twitter is not working in Android version 5.0.1

Hey, I have been using this lib with Android version 7.0.0 and 6.0 which was really working fine, but when I tested the same app with Android version 5.0.1 it's not working out when I click on button it loads to twitter sign page (usually it does) and shows the twitter login in android version 6 and 7, but in android version 5 it automatically closes and doesn't show the login page.
Can anyone please tell me, how to resolve this issue??pls,pls!!

Twitter Sign in Error

When I try to move through the auth flow. After I approve the app to have permissions the screen never redirects back to the application. It stays on the twitter screen:

image

The if I click done I get this react error:
image

I use this code as a callback from a button press (the RNTwitterSignIn is imported earlier successfully):

  _twitterSignin() {
    RNTwitterSignIn.init("KEY", "SECRET");
    RNTwitterSignIn.logIn()
     .then((loginData)=>{
       console.warn(loginData);
       const { authToken, authTokenSecret } = loginData;
       if (authToken && authTokenSecret) {
         // TODO
       }
     }).catch(console.error);
  }

Any thoughts on how to get this working? Thanks in advance.

Error while signing in saved account in IOS

Facing error. When twitter sign in uses saved account in ios settings. Please help.

userInfo:
{ NSLocalizedFailureReason: 'Twitter API error : Invalid or expired token. (code 89)',
NSErrorFailingURLKey: null,
NSLocalizedDescription: 'Request failed: unauthorized (401)',
TWTRNetworkingStatusCode: 401 },
domain: 'TwitterAPIErrorDomain' }

A problem occurred configuring project ':app'. > Could not resolve all dependencies for configuration ':app:_debugCompile'. > Could not find com.twitter.sdk.android:twitter:1.13.1.

WARNING [Project: :app] Current NDK support is deprecated. Alternative will be provided in the future.
WARNING [Project: :react-native-share] Current NDK support is deprecated. Alternative will be provided in the future.
Crashlytics was applied to an android-library project.
Android-library support is currently an incubating feature.
Contact [email protected] with any issues.
Crashlytics couldn't find the res folder specified in sourceSets.main.res, please make one. It picked: src/main/res
Crashlytics couldn't find the res folder specified in sourceSets.main.res, please make one. It picked: src/main/res

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':app'.

    Could not resolve all dependencies for configuration ':app:_debugCompile'.
    Could not find com.twitter.sdk.android:twitter:1.13.1.
    Searched in the following locations:
    https://jcenter.bintray.com/com/twitter/sdk/android/twitter/1.13.1/twitter-1.13.1.pom
    https://jcenter.bintray.com/com/twitter/sdk/android/twitter/1.13.1/twitter-1.13.1.aar
    file:/home/waleed/Documents/zig-android/node_modules/react-native/android/com/twitter/sdk/android/twitter/1.13.1/twitter-1.13.1.pom
    file:/home/waleed/Documents/zig-android/node_modules/react-native/android/com/twitter/sdk/android/twitter/1.13.1/twitter-1.13.1.aar
    file:/home/waleed/Android/Sdk/extras/android/m2repository/com/twitter/sdk/android/twitter/1.13.1/twitter-1.13.1.pom
    file:/home/waleed/Android/Sdk/extras/android/m2repository/com/twitter/sdk/android/twitter/1.13.1/twitter-1.13.1.aar
    file:/home/waleed/Android/Sdk/extras/google/m2repository/com/twitter/sdk/android/twitter/1.13.1/twitter-1.13.1.pom
    file:/home/waleed/Android/Sdk/extras/google/m2repository/com/twitter/sdk/android/twitter/1.13.1/twitter-1.13.1.aar
    Required by:
    Zig:app:unspecified > Zig:react-native-twitter-signin:unspecified

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

RNTwitterSignIn.init() does not work on IOS

xcode version 9.1
react-native version 50.4
react-native-twitter-signing version 1.0.2

RNTwitterSignIn.init() error

I don't really understand the error but under debug navigator it shows this:
#0 facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&) at <project-location>/node_modules/react-native/React/CxxModule/RCTNativeModule.mm:114

it says:
Thread 1: EXC_BREAKPOINT (code=1, subcode=0x102aa7c34)

RN 0.29 migration

I migrated my project from RN 0.27 to 0.29,
Please define the structure of MainActivity.java & MainApplication.java

not able to build project

After adding package my build is unsuccessful. below is the error I am getting. please help. Thanks

:app:processDebugResources
/Users/android/workspace/jenkins/workspace/fabric-android-deploy-to-staging/sdk/kits/digits/src/main/res/layout/dgts__activity_contacts.xml:9: AAPT: No resource found that matches the given name (at 'style' with value '@style/tw__Permission_Container').

/Users/android/workspace/jenkins/workspace/fabric-android-deploy-to-staging/sdk/kits/digits/src/main/res/layout/dgts__activity_contacts.xml:24: AAPT: No resource found that matches the given name (at 'style' with value '@style/tw__Permission_Title').

/Users/android/workspace/jenkins/workspace/fabric-android-deploy-to-staging/sdk/kits/digits/src/main/res/layout/dgts__activity_contacts.xml:32: AAPT: No resource found that matches the given name (at 'style' with value '@style/tw__Permission_Description').

/Users/android/workspace/jenkins/workspace/fabric-android-deploy-to-staging/sdk/kits/digits/src/main/res/layout/dgts__activity_contacts.xml:40: AAPT: No resource found that matches the given name (at 'style' with value '@style/tw__ButtonBar').

/Users/android/workspace/jenkins/workspace/fabric-android-deploy-to-staging/sdk/kits/digits/src/main/res/layout/dgts__activity_contacts.xml:47: AAPT: No resource found that matches the given name (at 'layout_marginLeft' with value '@dimen/tw__btn_bar_margin_left').

/Users/android/workspace/jenkins/workspace/fabric-android-deploy-to-staging/sdk/kits/digits/src/main/res/layout/dgts__activity_contacts.xml:47: AAPT: No resource found that matches the given name (at 'layout_marginRight' with value '@dimen/tw__btn_bar_margin_right').

/Users/android/workspace/jenkins/workspace/fabric-android-deploy-to-staging/sdk/kits/digits/src/main/res/layout/dgts__activity_contacts.xml:47: AAPT: No resource found that matches the given name (at 'layout_marginStart' with value '@dimen/tw__btn_bar_margin_left').

/Users/android/workspace/jenkins/workspace/fabric-android-deploy-to-staging/sdk/kits/digits/src/main/res/layout/dgts__activity_contacts.xml:47: AAPT: No resource found that matches the given name (at 'layout_marginEnd' with value '@dimen/tw__btn_bar_margin_right').

/Users/android/workspace/jenkins/workspace/fabric-android-deploy-to-staging/sdk/kits/digits/src/main/res/layout/dgts__activity_contacts.xml:59: AAPT: No resource found that matches the given name (at 'layout_marginLeft' with value '@dimen/tw__btn_bar_margin_left').

/Users/android/workspace/jenkins/workspace/fabric-android-deploy-to-staging/sdk/kits/digits/src/main/res/layout/dgts__activity_contacts.xml:59: AAPT: No resource found that matches the given name (at 'layout_marginRight' with value '@dimen/tw__btn_bar_margin_right').

/Users/android/workspace/jenkins/workspace/fabric-android-deploy-to-staging/sdk/kits/digits/src/main/res/layout/dgts__activity_contacts.xml:59: AAPT: No resource found that matches the given name (at 'layout_marginStart' with value '@dimen/tw__btn_bar_margin_left').

/Users/android/workspace/jenkins/workspace/fabric-android-deploy-to-staging/sdk/kits/digits/src/main/res/layout/dgts__activity_contacts.xml:59: AAPT: No resource found that matches the given name (at 'layout_marginEnd' with value '@dimen/tw__btn_bar_margin_right').

/Users/android/workspace/jenkins/workspace/fabric-android-deploy-to-staging/sdk/kits/digits/src/main/res/layout/dgts__activity_failure.xml:8: AAPT: No resource found that matches the given name (at 'style' with value '@style/tw__Permission_Container').

/Users/android/workspace/jenkins/workspace/fabric-android-deploy-to-staging/sdk/kits/digits/src/main/res/layout/dgts__activity_failure.xml:23: AAPT: No resource found that matches the given name (at 'style' with value '@style/tw__Permission_Title').

/Users/android/workspace/jenkins/workspace/fabric-android-deploy-to-staging/sdk/kits/digits/src/main/res/layout/dgts__activity_failure.xml:32: AAPT: No resource found that matches the given name (at 'style' with value '@style/tw__Permission_Description').

how do I properly link iOS files?

I'm getting this error:

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_TWTRAPIClient", referenced from:
      objc-class-ref in TwitterSignin-DD11A2C65187B8A2.o
  "_OBJC_CLASS_$_Twitter", referenced from:
      objc-class-ref in TwitterSignin-DD11A2C65187B8A2.o
      objc-class-ref in AppDelegate.o
     (maybe you meant: _OBJC_CLASS_$_TwitterSignin)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm used to adding .xcodeproj libraries, but not individual files like this. What I've done is I added the TwitterKit fabric library (something not mentioned in the documentation) and overcame some initial errors, but now I'm getting the above issue, which seems to have to do with linking the binaries, compile sources etc. I added Twitter.framework to Link Binary With Libaries and now I've tried adding Twitter.Signin.m/h to the Compile sources, but no luck.

What am I missing?

App crashes on login

React native 0.38 and 0.39

import React, { Component } from 'react';
import {
  AppRegistry,
  NativeModules,
  Text
} from 'react-native';

const { TwitterSignin } = NativeModules;

export default class Workbench extends Component {
    _twitterSignIn() {
        TwitterSignin.logIn('secret_key', 'secret_key2', (error, loginData) => {
            if (!error) {
            } else {
                alert('asd');
                // Alert.alert('Invalid login', 'Unable to login');
            }
        });
    }

  render() {
    return (

          <Text  onPress={this._twitterSignIn.bind(this)}>Sign in</Text>

    );
  }
}

AppRegistry.registerComponent('Workbench', () => Workbench);

init method return promise, but it is used as sync in example

_twitterSignIn = () => {
RNTwitterSignIn.init(Constants.TWITTER_COMSUMER_KEY, Constants.TWITTER_CONSUMER_SECRET)
RNTwitterSignIn.logIn()
.then(loginData => {
console.log(loginData)
const { authToken, authTokenSecret } = loginData
if (authToken && authTokenSecret) {
this.setState({
isLoggedIn: true
})
}
})
.catch(error => {
console.log(error)
}
)

public void init(String consumerKey, String consumerSecret, Promise promise) {
TwitterConfig config = new TwitterConfig.Builder(this.reactContext)
.logger(new DefaultLogger(Log.DEBUG))
.twitterAuthConfig(new TwitterAuthConfig(consumerKey, consumerSecret))
.debug(true)
.build();
Twitter.initialize(config);
WritableMap map = Arguments.createMap();
promise.resolve(map);
}

I am not sure, but looks like possible issue is here.
Also: better to wrap init into try {} catch() {} to avoid uncathed native crashes

react-native doesn't link ios module

I went through all instructions and run the project but I hadn't find NativeModules in React from 'react-native'. And find that that my link didn't link ios module.

Permission to retrieve user's email?

How to apply for a permission retrieve user's email. Can I get an example please?

Code:

const Constants = {
    TWITTER_COMSUMER_KEY: 'XXXXXXX',
    TWITTER_CONSUMER_SECRET: 'XXXXXXXXXXXX',
};

export default class twitterLogin extends Component {
    constructor(props) {
        super(props);

        this.state = {
            isLoggedIn: false,
        }
        this.handleLogout = this.handleLogout.bind(this);
    }

    _twitterSignIn() {
        RNTwitterSignIn.init(Constants.TWITTER_COMSUMER_KEY, Constants.TWITTER_CONSUMER_SECRET);
        RNTwitterSignIn.logIn()
            .then((loginData)=>{
                console.log(loginData);
                const { authToken, authTokenSecret } = loginData;
                if (authToken && authTokenSecret) {
                    this.setState({
                        isLoggedIn: true,
                    });
                }
            }).catch((error)=>{
            console.log(error);
        });
    }

    handleLogout() {
        console.log('logout');
        RNTwitterSignIn.logOut();
        this.setState({
            isLoggedIn: false,
        });
    }

    render() {
        const { isLoggedIn } = this.state;
    return (
        <View style={{flex: 1}}>
            {
                isLoggedIn
                    ?
                    <TouchableOpacity
                        onPress={this.handleLogout}
                    >
                        <Text>Log out</Text>
                    </TouchableOpacity>
                    :
                    <Icon.Button name='logo-twitter' size={32} color='white' style={styles.icon} onPress={this._twitterSignIn.bind(this)}>
                        Login with Twitter
                    </Icon.Button>
            }
        </View>
    );
  }
}

[iOS] TwitterKit on login click throwing error

[Fabric] [Fabric +with] called multiple times. Only the first call is honored, please pass all kits you wish to initialize


[TwitterKit] No matching scheme found.

[TwitterKit] did encounter error with message "Error obtaining user auth token.": Error Domain=TWTRLogInErrorDomain Code=-1 "{"errors":[{"code":32,"message":"Could not authenticate you."}]}" 
UserInfo={NSLocalizedDescription={"errors":[{"code":32,"message":"Could not authenticate you."}]}}

This is my call in AppDelegate.m
[Fabric with:@[[Twitter class]]];

I tried everything from other issues, did not help me

react-native-cli: 1.0.0
react-native: 0.44.0

Please, contact me if u have some solutions, tyvm
[email protected]

EDIT: Solved! Sry guys!

RNTwitterSignIn.init() falis silently

Using in iOS and RN 47.1 along with Facebook login
No error is thrown, but the promise of this function is never resolved.
What could cause that?

Here is my AppDelegate.m


 #import <TwitterKit/TwitterKit.h>
 #import <FBSDKCoreKit/FBSDKCoreKit.h>
 #import <FBSDKLoginKit/FBSDKLoginKit.h>
 #import "RNTwitterSignIn.h"
 
 #define TWITTER_SCHEME @"twitterkit-myKey"
 #define FACEBOOK_SCHEME  @"fbmyFbKey"
 
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
   //more code
   [[Twitter sharedInstance] startWithConsumerKey:@"myKey" consumerSecret:@"mySecret"];
   [[FBSDKApplicationDelegate sharedInstance] application:application
                            didFinishLaunchingWithOptions:launchOptions];
  //more code
 }

 - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options
 {
 
   return [[FBSDKApplicationDelegate sharedInstance] application:app
                                                         openURL:url
                                               sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                                      annotation:options[UIApplicationOpenURLOptionsAnnotationKey]] ||
         [[Twitter sharedInstance] application:app openURL:url options:options];
   
 }
 

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.