NativeScript / nativescript-facebook

NativeScript plugin, wrapper of native Facebook SDK for Android and iOS
Apache License 2.0
79 stars 50 forks source link

Logout on iOS #82

Closed b-hobbs closed 6 years ago

b-hobbs commented 6 years ago

I'm trying to implement logout but in iOS it does not seem to work as expected. After logging out I'd expect the next login to require an email and password to be entered but it remembers the last account and just asks to continue, making it impossible to use another facebook account. On android it does request another email and password. Any help would be appreciated.

Which platform(s) does your issue occur on?

iOS

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

I can't get the demo working but I basically followed the custom way of the demo.

Facebook.login((error, data) => {}); Facebook.logout(() => console.log("loggout facebook"));

vmachuca commented 6 years ago

same problem here!

zbranzov commented 6 years ago

@vmachuca @b-hobbs You can change the login behavior in the 'init' function by using the second optional parameter 'LoginBehavior.LoginBehaviorWeb'. This way everytime a user is logged out it will be prompted to input credentials on login. Notice that this applies only when custom button is used.

zbranzov commented 6 years ago

I'm closing this. Please write back if there is anything unclear.

lin-brian-l commented 6 years ago

@zbranzov I've been getting the same problem as @b-hobbs, except it happens on both Android and iOS. Can you give a more explicit explanation about how to use "LoginBehavior.LoginBehaviorWeb"? I've tried implementing variations on the following code to my angular app in app.module.ts, but it either throws an error or has no effect.

let nsFacebook = require('nativescript-facebook');
import * as application from 'application';

application.on(application.launchEvent, function(args) {
    nsFacebook.init("fb_id", LoginBehavior.LoginBehaviorWeb);
});

EDIT: After getting some help, I got LoginBehavior.LoginBehaviorWeb working with the following:

let nsFacebook = require('nativescript-facebook');
import * as application from 'application';
import { LoginBehavior } from "nativescript-facebook";

application.on(application.launchEvent, function(args) {
    nsFacebook.init("fb_id", LoginBehavior.LoginBehaviorWeb);
});

This solves the issue on iOS, but on Android, it now fails to prompt any sign of going through Facebook and instead automatically pulls the previous user's information and proceeds to login. Do you have any ideas about what may be happening?

zbranzov commented 6 years ago

@lin-brian-l The login behavior is only respected by the Custom login button described in the documentation and presented in the demo app. Therefore, check whether you are using it. As for the Android part, we haven't seen such case where the app cannot log out properly. If you have a reproducible case please attach it here and add details about the device you are using.

lin-brian-l commented 6 years ago

@zbranzov thanks for the reply. I've been able to use a custom login function and log out of Facebook. To clarify, users can properly sign in/out of Facebook properly on both Android and iOS, but I have an issue on Android where, after signing in via Facebook once, the phone will always remember that user's information and automatically perform the login process instead of re-prompting the user for their credentials. It isn't a huge issue, but it is inconvenient because it prevents users from logging in to a different account via Facebook. I replicated this issue in the demo app (I only changed the Facebook app ID in app.module.ts) as well; have you seen issue before? If so, do you have any ideas of how to solve it?