Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android - Unable to close webview #3

Open
StephenKDS opened this issue May 16, 2015 · 13 comments
Open

Android - Unable to close webview #3

StephenKDS opened this issue May 16, 2015 · 13 comments

Comments

@StephenKDS
Copy link

I have some code in the onURLChanging event - to retrieve some thing from the web response based on the landing page (i.e. Twitter Auth) - but attempts to call WebView.close(); don't work.

Looked through code - and can see only iOS has this function available. Can we make it available to Android?

Is it the same code to do a close?

@fbricker
Copy link
Contributor

Hi, you're right. We forgot the close on android :(
I'll try to add this soon. Meanwhile, maybe you can use the blacklist parameter to tell the webview that it should automatically close if it gets redirected to that URL.

Thanks for reporting! 👍

@StephenKDS
Copy link
Author

Will it still fire up a onURLChanging event?

I'll give it a go and see how I get on.

Thanks for the heads up! I'll try not to be a pain - this webview is the best one so far for the job! Great work on it :)

@fbricker
Copy link
Contributor

Yes, it'll (or at least, that's the idea :P)

@StephenKDS
Copy link
Author

Any idea how easy it is to add support for Blackberry to do the same thing? Does BB have a "webview" type intent/activity? hmm or do you think it would be easier/simplier to just package an android build for Blackberry, and use that instead? I'm building a game - so trying to get it compatible on all platforms.

@StephenKDS
Copy link
Author

I've just had a browse through the code - for Android, it looks like it makes a callback to onURLChanging before it checks the URL blacklist/whitelist.

for iOS however it looks like it does the whitelist/blacklist checks before making that call to onURLChanging.

Is that how you understand it?

@StephenKDS
Copy link
Author

How do I use the Blacklist feature? I tried creating a Array with 1 entry "http://website.com/callback/" which is the last URL i care about - but it didnt fire.
URL visited is usually "http://website.com/callback/#access_token=abcdef..."

Also, is there any way we can pass in a flag to clear the webview cache/cookies etc?

If I open the webview, login, close, then re-open again, it already remembered my last login attempt - so I don't get the chance to re-login. It only clears itself, if I kill the app and re-open.

@fbricker
Copy link
Contributor

Hi,

About blacklist and whitelist: They have the shape of array of regular expressions.
For example:
For whitelist, you can use:
WebView.open('http://www.puralax.com/help',true,['(http|https)://www.puralax.com/help(.*)','http://www.sempaigames.com/(.*)']);

For blacklist, you can use:
WebView.open('http://www.puralax.com/help',true,null,['(http|https)://(.*)facebook.com(.*)']);

About clear webview content, relogin: You should do that directly on your website (maybe you can append some get parameter to let your server know that it should init a new session).

About cache, you should manage that directly from your web-server cache headers.

About blackberry, Lime uses BlackBerry core API and WebView demands cascades framework. So there's no webview possible on BlackBerry until someone changes some stuff inside Lime.

About Android / iOS handling the whitelist / blacklist in different order we'll check on that. If you can cooperate by sending a pull request, it'll be great :)

Thanks!

@StephenKDS
Copy link
Author

1, Thanks for the reply. That blacklist example is perfect.
2, The Clearing content/cache/cookies thing - this is outside my control (i.e. facebook/twitter auth), I cannot set cookies for their domain etc. There is a setting in the webview control to do this (i'm pretty sure).
3, Blackberry - thats okay, I'll probably just re-package an android release/build.
4, Pull request? for this GIT source code - are you suggesting I make the change and submit a pull request? I guess I could do that - never done it before, but I'm pretty sure I know how (or atleast can google how to)

@StephenKDS
Copy link
Author

As far as # 2 goes - I'm thinking of
http://developer.android.com/reference/android/webkit/WebView.html#clearCache%28boolean%29

public void clearCache (boolean includeDiskFiles)
public void clearFormData ()
and possibly:
public void clearView ()

Not sure if the iOS webview control has the same, most likely does. Thoughts?
Found this link to give ideas - http://stackoverflow.com/questions/5468553/clearing-uiwebview-cache

@fbricker
Copy link
Contributor

Hi, yes... I you can implement some of those features and make a pull request, it'll be great for the extension 👍
We're currently working on many extensions at the same time, so any help will be gladly received.

About the functions you name, looks like the right way to go :)

@StephenKDS
Copy link
Author

I've just done a commit of the change to Android (clear cache) after testing it working.

That commit worked fine, but I cannot see it on the GitHub web site here - no vision of it at all.. If I browse in Git GUI (windows UI git hub client), I can see my commit, along with everyone elses.

Can you check it has come through okay?

@fbricker
Copy link
Contributor

fbricker commented Jun 1, 2015

Great! I'll check and release a new version if everything goes right.

Thanks!!!

@PXshadow
Copy link

Any news on a pull request for onClose with android?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants