Software Archive
Read-only legacy content
17061 Discussions

Facebook plugin behavior

Hooman_F_1
Beginner
1,183 Views

I am using the Facebook plugin featured in Intel XDK (v 1826).  The plugin works fine.  I am redirected to a Safari page (on the iPhone) to login.  On subsequent login attempts, the user gets redirected to a Safari page with a message - "You have already authorized [my app name]."  User can press OK or cancel.  Pressing OK redirects back to my app no issues.  Is there a way to avoid this confirmation though?  A setting that I can pass to avoid this?  My code is simply:

$scope.fbLogin = function(){
                
        facebookConnectPlugin.login(["public_profile"],
            fbLoginSuccess,
            function (error) {
                alert("Facebook login error: " + error); 
            }
        );
    };

 

0 Kudos
7 Replies
John_H_Intel2
Employee
1,183 Views

When you log into facebook, you get an accessToken back. Why dont you set a cookie to TRUE when you get a accessToken, then when you go to log into facebook again, first check to see if you have an valid cookie, if so, dont continue the login.

0 Kudos
Hooman_F_1
Beginner
1,183 Views

Well I didn't mean the user is getting this trying to login repeatedly.  The user is logging out in between.  Sequence is:

1) Login to FB (via redirect page).

2) Logout in my app

3) Login to FB (again via redirect page).

During #1, the user sees the facebook login page in safari (as expected).  During #3, the user sees the "You have already authorized [my app]" confirmation page in safari.

 

0 Kudos
John_H_Intel2
Employee
1,183 Views

What do you mean by:

2) Logout in my app

 

Do you have a logout function of your app, or are you just closing your app? I typically test the fb stuff with the logged into the fb app on device. Its a smoother experience and most everyone already has it on their device. Can you test that way and see if it makes a difference?

0 Kudos
Hooman_F_1
Beginner
1,183 Views

Yes I have a log out function in my app that clears the access token.  But the issue is why the FB site I get redirected to likes to let me know that I have already authorized this app.  Something about my call to the FB plugin maybe not quite right?  It should just redirect me back to the app without the confirmation each time no?

0 Kudos
John_H_Intel2
Employee
1,183 Views

That is how this plugin is designed. I google'd this issue and found this

0 Kudos
Hooman_F_1
Beginner
1,183 Views

Bingo.  That got me to avoid the silly confirmation page!  Update code:

 

facebookConnectPlugin.getLoginStatus(function(currentStatus){
                if (currentStatus.status == "connected"){
                    fbLoginSuccess(currentStatus);
                } else {
                    facebookConnectPlugin.login(["public_profile"],
                        fbLoginSuccess,
                        function (error) {
                            alert("Facebook login error: " + error); 
                        }
                    );
                }        
            }, function (error) {
                alert("Facebook login status error: " + error); 
            }
        );          

 

0 Kudos
Leonardo_M_1
Beginner
1,183 Views

Hi Hooman F.

How you include the plugin on your project?

Do you include the plugin that have the XDK?, because  I'm using one plugin that I download and it work in the emulator but not in the device. I don't why.

Thanks.

 

0 Kudos
Reply