Piroro-hs / react-native-twitter

A Twitter API client library for React Native. Currently not maintained as my main motivation of creating this library was to use the User Streams API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clarification on auth(tokens, callbackUrl[, options])

srt0422 opened this issue · comments

Hello,

I appreciate the time you put into this module. It looks like it will be a big help on my project, but I'm confused about the use of the above method.

according to your "readme" file it returns this "

 Returns: Promise of {accessToken, accessTokenSecret, id, name}

 accessToken Access token
 accessTokenSecret Access token secret
 id User id
 name Screen name

When I call "auth" in my app, it properly redirects to the twitter login page. When I authorize the app, it redirects back to the app, but the ".then" function never gets called.

My code is something like this:

let twitterAccessToken;

auth({tokens, redirectUrl}).then((accessToken)=> twitterAccessToken = accessToken);

You are probably missing the launchMode attribute on the activity as described here.

You need to add in your AndroidManifest.xml:

<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize"
    android:launchMode="singleTask"> <!-- THIS LINE -->

This will make the browser redirect back right where you called the auth method, in the same app instance, and then the promise will resolve successfully. :)

I hope it helps for your case.

Seem like Linking.addEventListener('url', callback) not working anymore.

@andreyluiz
Thanks for the tip. I'll make sure I take care of that on the android version.

I apologize for not clarifying in my post that I'm currently working on the IOS version.

In my case, the problem was that I had to properly setup deep linking, and I have several plugins that handle opening urls in AppDelegate.m. I had to update the code so that they work together properly in the "openurl" method in AppDelagate.m.

The plugin works for me now.

commented

@srt0422

Hi, thanks for creating issue.

I'm really new to react-native and ios app building, and I do not understand how I can setup Deeplink stuff.

Could you please give me some example??

Thanks for reading!!