HaxeExtension/extension-webview

Android - Unable to close webview

StephenKDS opened this issue · 13 comments

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?

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! 👍

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 :)

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

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.

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?

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.

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!

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)

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

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 :)

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?

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

Thanks!!!

Any news on a pull request for onClose with android?