Is it possible to clear cache in iOS and Android webkit? - android

The sdk I am using for my app calls up a webview that loads Facebook's login oauth login screen. I can't find a way of logging the user out so that they can login as a different Facebook user as the view always loads with the credentials of the first user. My only solution is to uninstall the app.
I have been using 'https://graph.facebook.com/me/permissions?method=delete&access_token=', which does in fact remove the user from my app, by I think the webkit cache keeps the last access_token around and just tries to reauthenticate it.
I haven't seen any apps so far that let you fully logout and login as a different user when using Facebook to authenticate.

you can use this at time of logout
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (NSHTTPCookie *each in cookieStorage.cookies) {
// put a check here to clear cookie url which starts with twitter and then delete it
if ([[each valueForKey:#"domain"] isEqualToString:#".facebook.com"])
{ [cookieStorage deleteCookie:each]; }
else
{
[cookieStorage deleteCookie:each];
}
}

Related

Keep User logged in on android webview (wordpress site)

i have developed a wordpress website and I used webview for the android app.
now my concern is that whenever a user log in to the app and opens the app after closing the app.I want to keep them logged in !
I was having the same issue and I solved it by enabling a cache for the App. You might be able to do so by adding this to your Webview instance in MainActivity.java:
//enable in-app cache
myWebView.getSettings().setAppCacheEnabled(true);
Hope this works for you too.
This is to be managed by wordpress side, and not in Android.
two ways either save your user login username and password to sharedprefrence and check it everytime or save your user login username and password to sqlite and check if cursor count is 1 then redirect to webview else type username and password.
cache is no good about security also if user when the close app on ios, the cache gonna be delete

How to remove all application data on react native?

How to remove all application data on react native?
Not only AsyncStorage.clear().
I mean deleting application data like through settings > application.
I have faced EUNSPECIFIED error code with react-native-fbsdk.
First I logged in with my facebook account,
Second I logged out from it,
Third I relogin with this account (It works well)
And then I logged out again,
And I tried to log in with another facebook account,
But I faced EUNSPECIFIED error.
But after deleting all app data (not uninstall) through settings > application,
I can login with another facebook account.
I have to delete all applilcation data when logged out from my react native application.
OR
I have to fix this react-native-fbsdk's bug (or I guess fbsdk is caching some data....)
Already I put AsyncStorage.clear() when logout, No changes..
Appreciate for your help...
I had this problem with FBSDK as well and the problem is that when you login with facebook, the SDK creates an AccessToken linked to the old user. Therefore, when you try to login with another account, it throws this weird error message.
What you have to do is to logout the user on the fbAPI. The code below is how you do it:
// Remove FbAccessToken when the user logout.
logoutFromFB(){
if (AccessToken.getCurrentAccessToken() != null) {
LoginManager.logOut()
}
}
I hope it helps!

Facebook Login with Read and Publish(Write) permissions

I am trying Facebook Login in Android with LoginManager class. I want read and write permissions during login only. The issue I am facing is , If I try with
LoginManager.getInstance().loginWithReadPermissions();
LoginManager.getInstance().loginWithPublishPermissions();
If Facebook App is not installed, Facebook WebView loads up, I enter credentials, I see two permissions screen (One for Read and One for write) and then again Login Screen.Which basically, creates bad user experience.
It happens because, both loginWithxxxPermissions() methods,starts a new login flow.But actually, It should not show Login Screen for already logged in user.
I am not able to find any method to pass the accessToken to let me the method know that, the new permission query is for already logged in user.
Anyone, Please help me out or suggest some other alternative, But the requirement is clear. I need Read/Write permissions without showing Login screen twice.

Twitter no longer authorizes old Android devices / webview?

I noticed this when I re-ran my app on 2.2 and 2.3.4 devices. Basically I have a WebView which is loaded with twitter4j's client getAuthenticationURL.
If everything is correct and "Sign In" is clicked, webview will load another page asking for user's authorization. From there, "Authorize app" will return the app's custom callback and user tokens.
Clicking that "Sign In" button will no longer send the webview to the authorization page. It will just stay there. When I debugged my WebViewClient and probed onPageStarted, I noticed that a request was sent. But there's just no response from Twitter. Also, in my 4.4 Nexus tablet, there's no authorization page. "Sign in" will both authorize and immediately return the callback.
So far I found three workarounds for it (all these tests were done from clean install):
Click cancel, restart the app, and reload the same url + request token. This time there's no login. It will get webview to directly load the Authorization page.
This is the complete hack of all. Basically I need to enter a wrong password and I will get sent to a Password reconfirm page. If I enter the right password this time, I will see that authorization page. In fact the second snapshot above was obtained this way.
If I paste that url + request token on a browser, it will also skip the authorization page and immediately return my callback. I haven't made a thorough research if this works on startActivity-for-browser scheme, not embedded webview.
EDIT : it works, upon Sign In, browser will fire a warning and then return the callback which my app intercepts in onNewIntent. There is no authorization page. Also callback url needs to have callback host like bla://callback
I am pretty sure I was able to navigate the login pages including authorization with my older devices not long ago. Is this authorization thing broken or obsolete ?
In the absence of better answer then the current solution will have to do: separate login methods. I use Intent to browser for pre-ICS and WebView for the rest.

Switch user or re authenticate with Instagram

Following the Instagram documentation I'm able to authenticate a user and retrieve an access_token easily
But now I want to change of Instagram account which is impossible since the browser automatically call my callback URL because I'm already signed in with an account (there is no login / authorization form again)
To explain what happen here is the authenticate / authorization flow :
Open a browser asking user to log and authorize
User fill up form and submit (this step is skipped when user is already signed in !)
Browser redirect to callback URL
You see step 2 is skipped so we can't login with another user
Does the Instagram have a parameter to force relogin ?
Justin Powell answer is working for log out but I need to be also able to log in just after
and it's quite anoying for Android
But it points me in the right direction : Instagram (like other website) maintains our login with session variable (so with cookies)
So to avoid to be always loged in, we just have to find and remove the correct cookie, here is how to do it with Android :
String cookieString = "sessionid=''";
CookieManager.getInstance().setCookie("instagram.com", cookieString);
With this I set the Instagram sessionid cookie to en empty string so Instagram doesn't recognize me anymore
You could call the Instagram logout url (https://instagram.com/accounts/logout/) in the background before asking for access again. See this question and answers.
I believe the only other option is to leave it up to the user to logout of their Instagram account before loading your access url.
solved the same issue by deleting Access-Token from the app and loading url https://instagram.com/accounts/logout in webview without attaching it to any rootview.

Categories

Resources