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

x/mobile/webview: is a cross iOS/android web view possible? #10247

Closed
crawshaw opened this issue Mar 25, 2015 · 15 comments
Closed

x/mobile/webview: is a cross iOS/android web view possible? #10247

crawshaw opened this issue Mar 25, 2015 · 15 comments

Comments

@crawshaw
Copy link
Member

Embedding a web browser is a common strategy for apps that are not heavily focused on UI, on both Android and iOS. The web also provides a very easy way to use other UI systems in a Go application.

Is there enough commonality between the embedded web views on Android and iOS to build an API usable entirely from Go? The Android WebView has a wide interface and its not clear what subset lines up with iOS. Still, this would be very nice to have.

Assigning to myself, unless someone else really wants this.

/cc @hyangah @rakyll

@crawshaw crawshaw self-assigned this Mar 25, 2015
@crawshaw crawshaw added this to the Go1.5 milestone Mar 25, 2015
@rakyll
Copy link
Contributor

rakyll commented Mar 25, 2015

I would suggest you to target a small subset first. The initial step should be page loading, intercepting the requests and navigation-related APIs are secondary.

A web view is critical to pop-up a welcome screen with instructions, listing credits, documenting help, etc. I'd like to have the possibility to switch to a web view for text-dominated screens.

Recommended APIs to begin with:

loadDataWithBaseURL (String baseUrl, String data, String mimeType, String encoding, String historyUrl)
- (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *) encodingName baseURL:(NSURL *)baseURL

loadUrl(String url)
- (void)loadRequest:(NSURLRequest *)request

reload()
- (void)reload

stopLoading()
- (void)stopLoading

@timfayz
Copy link

timfayz commented Mar 27, 2015

I'm sorry for off topic, but still.. @crawshaw, thanks for support, it's very pleased that you raised this issue!

@tqangxl
Copy link

tqangxl commented Mar 27, 2015

u r right, Embedding a web browser on Android and IOS will unified development environment ,Let the developers don't focus on os environment!

Android fragmentation is very serious, coupled with highly customized , multi-version (2.4-4.2 now V5), multi-resolution ,this allowing developers a headache , if you can solve this problem , many developers will adopt this platform.

eg. When we release a android app run Android 2.4 or 4.2 and above, A Company and B Company were modified on customized Android system , the situation is often occur in the A Company B model can run , but in the B Company can not run on the C model!

@rsc rsc changed the title mobile/webview: is a cross iOS/android web view possible? x/mobile/webview: is a cross iOS/android web view possible? Apr 14, 2015
@rsc rsc removed the repo-mobile label Apr 14, 2015
@rsc rsc modified the milestones: Unreleased, Go1.5 Apr 26, 2015
@lunny
Copy link

lunny commented May 9, 2015

+1. It's a better idea than a cross-platform UI library.

@neclepsio
Copy link

So, it's done and will be released with Go 1.5?

Go + WebView + Polymer would be a great way to make Android applications; if working also on iOS it would be even better.

@minux
Copy link
Member

minux commented May 16, 2015 via email

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/11980 mentions this issue.

crawshaw added a commit to golang/mobile that referenced this issue Jul 13, 2015
Subclassing NativeActivity makes two things possible. Firstly, we can
implement an InputConnection to offer good support for IMEs,
necessary for good keyboard support. Secondly, we can use it to
overlay WebViews onto the NativeActivity.

But to sublcass NativeActivity, we need to compile Java. To keep the
toolchain go gettable, this is done with go generate.

While here, check the exception after FindClass. Apparently it can
throw an exception.

Updates golang/go#9361.
Updates golang/go#10247.

Change-Id: I672545997f0c9a7580f06988a273c03404772247
Reviewed-on: https://go-review.googlesource.com/11980
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
@joeblew99
Copy link

So i saw the Code at: golang/mobile@8f20c3e

Thansks @crawshaw !

So is this closed ? Does NativeActivity generate Android code thats usable for loading web views ?

@joeblew99
Copy link

@minux @crimshaw

Is this still on the table in terms of an objective ?

There are some good ways to bridge is inside the webview down into the golang code I think.

@crawshaw
Copy link
Member Author

crawshaw commented Jan 4, 2017

Given I have no time to work on this, I'm going to close this issue.

It is still a quite reasonable project, and I believe the gobind bindings are now good enough that this could be built in an external repository by anyone who is interested.

@crawshaw crawshaw closed this as completed Jan 4, 2017
@joeblew99
Copy link

@cramshaw

thanks for update, and yes there seems to be be enough to get the job done.
We are iterating on it over here:
https://github.com/gu-io/gu-x

@microo8
Copy link

microo8 commented Mar 2, 2017

Here is a tool to do an webview app on android from your golang http server (it's not much tested/stable yet) https://github.com/microo8/gowebview

@joeblew99
Copy link

thanks @microo8 . Code looks really good tooo. Like the way you code gen the boiler plate parts.
Any plans for IOS ?

There is a really nice desktop version for webview with golang here:
https://github.com/murlokswarm
It currently supports OSX and Windows, with mobile planned.
It also has an unusual approach in that on the backend (on the client) you can use golang templates for all the rendering with the ability to target the froentend( the webview on the client) HTML DOM nodes. So the FrontEnd is very dumb.
Its a very simple and elegant approach i feel, because all data mutations are sent to the backend, and then all views on the frontend get repopulated automatically if you set things up right.

If your interested i would be happy to visit the idea of collaborating on this

@microo8
Copy link

microo8 commented Mar 2, 2017

Thanks for the praise @joeblew99 :) but it isn't fully tested yet. And also i'm making some changes to it in short. Trying to make it as an tool, not just an project template generator. I don't know if this is the place to discuss it, but I'd like to make some commands, like create, build, debug, install. So that it can generate the template code, or it will build the production/debug apk right away.

IOS is not in plan, android does it for me, but wouldn't mind to pull some changes to support it as well :P

When @murlokswarm will have the mobile support, I'll definitely look at it, but this "framework style" development isn't for me :) I like the minimalistic approach that you are not bound to an framework, but create your own http server as you wish and then just wrap it with some code to create the mobile webview app.
You know: "Less is exponentially more" :)

@joeblew99
Copy link

@microo8 very true about the framework style. Can see your point - just wanted to introduce the pattern they use in case it was useful for you.

Regarding IOS. I am pretty useless at xCode. Over at the murlok team though the first one built was for OSX, and so its going to be likely that they could whip up an IOS version i suspect.
You should ask I reckon. I dont see any reason why it cant work as a base, and they can layer their framework approac on top. Everyone wins.

Regarding the design time tooling of "create, build, debug, install" thats a great idea.

@golang golang locked and limited conversation to collaborators Mar 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests