react-native-twitter icon indicating copy to clipboard operation
react-native-twitter copied to clipboard

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

Open srt0422 opened this issue 8 years ago • 5 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);

srt0422 avatar Mar 03 '17 04:03 srt0422

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.

andreyluiz avatar Mar 05 '17 01:03 andreyluiz

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

vinhtq avatar May 05 '17 08:05 vinhtq

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

srt0422 avatar May 09 '17 03:05 srt0422

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

u-kan avatar May 23 '17 14:05 u-kan

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

vinhtq avatar May 24 '17 11:05 vinhtq