简体   繁体   English

在Webview中清除用户的Facebook会话

[英]Clearing user's Facebook session in Webview

I have a WebView which allows a user to share an image to facebook. 我有一个WebView,允许用户将图像共享到Facebook。 This process involves them logging into FB. 此过程涉及他们登录FB。 After they're done I destroy the WebView and the app resets and a different user is offered the same functionality. 完成后我销毁WebView并重置应用程序,并为不同的用户提供相同的功能。 The intention is for the WebView to not to remain logged in from one session to the next, however, I'm unclear on how to either manually log the user out at the end of their session (calling http://www.facebook.com/logout.php no longer works, apparently), and grabbing new instances of WebView and WebChromeClient doesn't do it either. 目的是让WebView不要从一个会话继续登录到下一个会话,但是,我不清楚如何在会话结束时手动登录用户(调用http://www.facebook。 com / logout.php显然不再有效,并且抓取WebView和WebChromeClient的新实例也不会这样做。

However, I notice that when I reinstall the application (as I modify it) the log in is cleared, so, I'm assuming that *somehow Webkit can tell that this is a different app (as it is uninstalled and re-installed) and I'm hoping I can leverage this (or any other) mechanism to clear whatever it is that holds the user's login info... I'm guessing it's a cookie, but I'm not entirely certain that it is. 但是,我注意到当我重新安装应用程序时(因为我修改它)登录被清除,因此,我假设*某种程度上Webkit可以告诉这是一个不同的应用程序(因为它已卸载并重新安装)而且我希望我可以利用这个(或任何其他)机制来清除保存用户登录信息的任何内容......我猜它是一个cookie,但我并不完全确定它是。

I'm sure I'm not the first person to need to log the user out of FB manually, but not via my own oAuth (since I'm not the one logging them in). 我确定我不是第一个需要手动将用户从FB中注销的人,而不是通过我自己的oAuth(因为我不是记录它们的人)。

It's set by cookie. 它是由cookie设置的。 Prior to API 21 use: API 21之前使用:

android.webkit.CookieManager.getInstance().removeAllCookie();

now this method has been replaced with removeAllCookies which is basically the same but asynchronous with a callback. 现在这个方法已经被removeAllCookies所取代,它基本上是相同的,但与回调是异步的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM