Skip to content
This repository has been archived by the owner on Oct 24, 2022. It is now read-only.

Crash After Login second time #568

Closed
cafeasia3 opened this issue Sep 26, 2017 · 11 comments
Closed

Crash After Login second time #568

cafeasia3 opened this issue Sep 26, 2017 · 11 comments

Comments

@cafeasia3
Copy link

I am using ionic v1, when user login first time its fine, the facebook doesnt ask email and pass it shows popup then its logged in, then I logout using

facebookConnectPlugin.logout(function(){
	          $ionicLoading.hide();
	        });

then when I login again, this time the popup asked email and password, then my ionic app is crashed after log in. facebookConnectPlugin.getLoginStatus(function(response) this status return unknown

any idea whats wrong?

@cafeasia3
Copy link
Author

yes, it returned OK, but the second login crash the ionic app.

any work around this? or just dont need to logout the facebook?

@andevit
Copy link

andevit commented Feb 22, 2018

Has anyone managed to solve this problem?

@masoodusmani
Copy link

@andevit Hi, my PR fixes the crash. I haven't seen any side effects so far, but I'd appreciate @jeduan or someone else checking it.

@peterpeterparker
Copy link
Collaborator

if the getLoginStatus return unknown you have to login again before doing anything

 this.facebook.getLoginStatus().then((success) => {
        if (success.status === 'connected') {
             // cool
        } else {
            this.facebook.login(['public_profile']).then((response) => {
                 // cool
            }, (error) => {
                 // damn
            });
        }
    }, (error) => {
          // damn
    });

could you give a try @cafeasia3 ?

@A110SHT
Copy link

A110SHT commented Apr 25, 2018

@peterpeterparker it's still crash. Can not login again with Facebook after logout. when i try to login second time it return "undefined" and try to login again it crash. Any solution.

@peterpeterparker
Copy link
Collaborator

@A110SHT

there is a lack of details in your question, sorry but I can't give an answer based on "it crash". which os? which os version? which version of the plugin? and important how does your code looks like? could you provide a sample repo? what's the stacktrace? etc.

you could try your luck with the PR #642 if you wish (note: I personally don't plan to merge it, maybe other maintainers will)

@A110SHT
Copy link

A110SHT commented Apr 25, 2018

@peterpeterparker sorry for incomplete question. I try on Android v - 5.1.1. my code look like this
``$(document).on('click', '#facebook', function () {
login = 'fb';
var facebook = facebookConnectPlugin.getLoginStatus();
if (facebook === undefined) {
loginWithFB();
}
else if (facebook.status === 'connected') {
console.log(facebook);
}
});
function loginWithFB() {
facebookConnectPlugin.login(["public_profile", "email"], function (result) {
facebookConnectPlugin.api("/me?fields=email,name,picture",
["public_profile", "email"]
, function (userData) {
console.log(userData);
feedbackTabs.FacebookLogin(userData)
}, function (error) {
console.log(error);
notification("Cannot login from facebook", null, "Login", Ok);
});
}, function (error) {
console.log(error);
notification("Cannot login from facebook", null, "Login", Ok);
});
}

@peterpeterparker
Copy link
Collaborator

@A110SHT spontaneously I would say that the first error is in your code, getLoginStatus return a promise (see my above code example). But to me it then looks like a support inquiry, so plz use channels like Stackoverflow or Ionic forum to solve your issue, thx in advance

@peterpeterparker
Copy link
Collaborator

Finally @joaquinr submitted a sample repo on the Ionic Forum (https://forum.ionicframework.com/t/unable-to-install-cordova-facebook-4-plugin-with-android-7-0-0/118170/8) and therefore I was able to reproduce the problem of app crashing after a second login on Android

I solved the issue with following commit b594d32

This patch v2.0.1 is now released and available in npm, therefore I close this issue

@Ashis27
Copy link

Ashis27 commented Jun 21, 2018

After a long time, finally got a superb solution.
Thanks @peterpeterparker for your help.

Please check if you have not done yet the following process

  1. cordova plugin rm cordova-plugin-facebook4
  2. npm uninstall cordova-plugin-facebook4
  3. cordova plugin add cordova-plugin-facebook4@2.1.0 --save --variable APP_ID="*********" --variable APP_NAME="your app name"
  4. npm install cordova-plugin-facebook4
  5. cordova platform rm android
  6. cordova platform add android (7.0.0)

It's working fine now. Please try.

@JianhuisHuang
Copy link

if the getLoginStatus return unknown you have to login again before doing anything

 this.facebook.getLoginStatus().then((success) => {
        if (success.status === 'connected') {
             // cool
        } else {
            this.facebook.login(['public_profile']).then((response) => {
                 // cool
            }, (error) => {
                 // damn
            });
        }
    }, (error) => {
          // damn
    });

could you give a try @cafeasia3 ?

I have try with plugin version 5.0.0 and on ionic4, iOS 12, but not work. It still login as the same account @peterpeterparker , thanks.

Lindsay-Needs-Sleep pushed a commit to miloproductionsinc/cordova-plugin-facebook-connect that referenced this issue Mar 7, 2020
Lindsay-Needs-Sleep pushed a commit to miloproductionsinc/cordova-plugin-facebook-connect that referenced this issue Mar 7, 2020
Lindsay-Needs-Sleep pushed a commit to miloproductionsinc/cordova-plugin-facebook-connect that referenced this issue Mar 7, 2020
Lindsay-Needs-Sleep pushed a commit to miloproductionsinc/cordova-plugin-facebook-connect that referenced this issue Mar 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants