App crashed on twitter login

i am using twitter login in ionic 2 application and following this link–>

i have issue with app is crashed after the twitterlogin() method . can anyone suggest me that why my app is crashed after hitting the twitterlogin() method. i am using the follwing code:

** twitterlogin() {

let loading = this.loadingCtrl.create({
  content: 'Please wait...'
});

loading.present();
//Request for login
this.tw.login().then(result => {
  //Get user data
  console.log('result',result)
  this.tw.showUser().then(user =>{

    console.log('user',user)
    //Save the user data in NativeStorage

  }, function(error){
    loading.dismiss();
  });
});

}**

please help me asap because i already spent 2 to 3 days. its urgent. anyone help is truly appretiated.

Can you share your console screenshot and the code you have modified it a bit??
what error do you get in your console??
Or are using the app in device??

Did you remote debug the problem on the device already?
Follow these instructions here to debug the problem in Safari dev tools:
https://ionic.zone/debug/remote-debug-your-app#ios
Follow these instructions here to debug the problem in Chrome dev tools:
https://ionic.zone/debug/remote-debug-your-app#android
Look at the console and network tabs for errors.

i am using in device and no error console will be shown. only app crashes immediately. twitter login method causes this crash.

no, remote debugging is not the problem, device is debugged perfectly . i have an issue with twitter login method.

I see that you’re dismissing the loader if there’s an error but I don’t see it dismiss if you log in successfully.

Side note - consider refactoring with async/await and try/catch to handle errors. It’s a lot cleaner to read and you won’t end up with nested promises.

Ok in that case you’ll have to provide the code that you are using…

This is probably something where reasonable people can disagree, but I don’t like async/await, largely for the same reason I don’t like magical get and set functions. I think they are gimmicks that obscure what is actually happening and make code less readable. Promise chains can be flattened without them. I’m also not a fan of try/catch in general, but especially here, because Promises already provide a natural way to handle exceptions.

1 Like

Fair enough. I’m happy to obscure what’s actually happening :slight_smile:

1 Like

hi sir,
i did use try catch block for handling the error but no error will be catches in catch block but it will give the log message in finally block still app crashes.