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.
MIT License
39 stars 20 forks source link

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

Open srt0422 opened 7 years ago

srt0422 commented 7 years ago

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);

andreyluiz commented 7 years ago

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.

vinhtq commented 7 years ago

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

srt0422 commented 7 years ago

@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.

u-kan commented 7 years ago

@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!!

vinhtq commented 7 years ago

@KanUchida Please follow this guide: https://facebook.github.io/react-native/docs/linking.html