Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No value return from Promise after logged in #6

Closed
keeratita opened this issue Dec 19, 2017 · 9 comments
Closed

No value return from Promise after logged in #6

keeratita opened this issue Dec 19, 2017 · 9 comments
Labels

Comments

@keeratita
Copy link

LineLogin.login()
    .then((user) => {
      console.log(user.profile.displayName)
    })
    .catch((err) => {
      console.log(err)
    })

When clicked my button, It was redirected to Line. And after logged-in successful, it returned back to my application but no any value return.

Any suggestions, please?
Cheers!

@mcousillas6
Copy link
Contributor

Hey there!

Can you give me any more details about your setup?
Which platform are you having this issue?

You could try checking if you have all configs set properly, since Line requires a bit of setup on both iOS and Android and also on their own website.

@keeratita
Copy link
Author

keeratita commented Dec 19, 2017

hi @mcousillas6 ,

Oops! I'm so sorry. I was too hurry to write, I didn't notice that I didn't put my environment info. 🙇

I just tested on my android platform only.

  • Android Google APIs Version 23

What I did.

  1. npm install react-native-line-sdk
  2. react-native link react-native-line-sdk
  3. Download Android SDK as your manual and move it to libs folder.
  4. update app's build.gradle
    repositories {
    flatDir {
    dirs 'libs'
    }
    }
  5. Change my channel ID in res\values\strings.xml
  6. react-native run-android

My App can run and show my login screen, when I click login it will call my login function that contains code like this.

LineLogin.login()
    .then((user) => {
      console.log(user.profile.displayName)
    })
    .catch((err) => {
      console.log(err)
    })

It can load and show a Line login website on my android simulator. I can login by using my Line id, and it shows an authorization page. After I clicked an authorize button, it came back to my application but no values return on this state. I mean, no return data on Promise (both success and failed).

I think the onActivityResult is not called, i'm not sure i missed anything.

My dependencies as below:

        "expo": "23.0.0",
        "mobx": "^3.1.9",
        "mobx-react": "^4.1.8",
        "moment": "^2.18.1",
        "react": "16.0.0",
        "react-native": "0.50.0",
        "react-native-line-sdk": "^1.0.3",
        "react-navigation": "1.0.0-beta.19"

Thanks in advance! :)

@mcousillas6
Copy link
Contributor

mcousillas6 commented Dec 19, 2017

The problem is that you are using Expo.

This means that you can't use dependencies that have native code on your project (like this one) unless you eject the project.

You can try that, or you can also submit a request so expo adds the library to their system (so it works out of the box).

Hope this helps.

@keeratita
Copy link
Author

Hi @mcousillas6 I did eject the project before asking in this thread. If I didn't do that, why I can tell you that I did 2,3,4 and 5?

@mcousillas6
Copy link
Contributor

Oh you're right, my bad.

We've been using it with no issues on our apps, but without expo. I'll try to test it on a dummy project this week using expo to see if I can find the problem.

I'll let you know as soon as I have any news. Sorry again for the misunderstanding.

@keeratita
Copy link
Author

@mcousillas6 ok guys, I figured it out.. expo uses another method and class to register a callback.
Sorry for causing the problem.

But now, i got a new issue. It seems like your logout method in Java is not correct. It didn't call logout but getProfile.

@mcousillas6 mcousillas6 added the bug label Jan 3, 2018
@mcousillas6
Copy link
Contributor

mcousillas6 commented Jan 3, 2018

Hey there!

Glad to hear that you could fix the issue. Do you mind leaving here any references/links that you used to fix it? So other people also have the solution 😄

About the logout issue, you´re right. I have the fix on review #8 you can test that branch to see if that works for you.
Thanks!

@keeratita
Copy link
Author

Hi there,

Thank you!
And the below code is how I fix the issue with Expo.

LineLogin.java

Firstly add this code import host.exp.expoview.Exponent;.

Change code from

private final ActivityEventListener mActivityEventListener = new BaseActivityEventListener() {
     @Override
     public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {

to

private final host.exp.exponent.ActivityResultListener mActivityEventListener = new host.exp.exponent.ActivityResultListener() {
       @Override
       public void onActivityResult(int requestCode, int resultCode, Intent data) {

and from

    public LineLogin(ReactApplicationContext reactContext) {
        super(reactContext);
        reactContext.addActivityEventListener(mActivityEventListener);
    }

to

    public LineLogin(ReactApplicationContext reactContext) {
        super(reactContext);
        Exponent.getInstance().addActivityResultListener(mActivityEventListener);
    }

Cheers!

@mcousillas6
Copy link
Contributor

mcousillas6 commented Jan 6, 2018

Thanks for all the info!
Looks like if we want to support expo we´ll need to handle both implementations. I´ll give some thought to it and see how we can do it.

I´ll close the issue since you got everything working now.

@mcousillas6 mcousillas6 mentioned this issue Jan 6, 2018
BondPiyapan pushed a commit to BondPiyapan/react-native-line-ex that referenced this issue May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants