xamarin / XamarinCommunityToolkit

The Xamarin Community Toolkit is a collection of Animations, Behaviors, Converters, and Effects for mobile development with Xamarin.Forms. It simplifies and demonstrates common developer tasks building iOS, Android, and UWP apps with Xamarin.Forms.
MIT License
1.58k stars 471 forks source link

[Enhancement] HybridWebview(Invoke C# from JavaScript) #821

Closed jingliancui closed 3 years ago

jingliancui commented 3 years ago

Summary

docs here , like MediaElement , HybridWebview maybe will be made as an Control in XCT.

jingliancui commented 3 years ago

Mark cordova-ios and cordova-android, Maybe we can move the logic from these models to xct's controls.

jingliancui commented 3 years ago

What's the challenge is how to dynamic map/register the customize js method to the c# code.

jingliancui commented 3 years ago

After work above are finished. Then we can plan the work about use hybrid (blazor + native).

jfversluis commented 3 years ago

Hey there, thanks for the suggestion. Can we, instead of only mentioning the Docs, talk about why you want to use this? What benefit will it bring you? How do you want to use this and what scenarios?

To be honest, and that's my personal opinion, I feel that WebViews are great to just show some webpage or thing, but nothing more beyond that. I don't like working on hybrid apps or even with hybrid apps. If I can understand your motivation better then I think we can make a better decision on how to move forward with this

jingliancui commented 3 years ago

@jfversluis Yep, Of course scenarios: 1.My Some clients have a WebUI + .net Server team , not have the mobile team but want the native mobile api like location、contact info etc ...... So they want use the WebUI team to fast build UI and let my team to help implement the native mobile feature. 2.Blazor feature just the new idea I thought.While .net 5 have the powerful blazor feature , it help lots of .net developers to fast build UI use h5+css+c#/.net

HeikkiDev commented 3 years ago

I found Hybrid WebView requirement more than once in my projects, so I guess it may be usual.

But my opinion is to not add this control because Microsoft docs about Hybrid WebView is clear and easy enough to implement.

IeuanWalker commented 3 years ago

@jfversluis @jingliancui We've been using this for a few years and been perfect - https://github.com/SKLn-Rad/Xam.Plugin.Webview

We use it because we have an internal mapping system that is only web-based. So using this webview I'm able to pass the GPS location on page load trigging a JS function to centre the map, and then when the user selects a location the javascript calls the C# method to pass the location info back to the app.

jingliancui commented 3 years ago

@HeikkiDev Yep , but docs' register method is easy, now I use the method string + parameters string to deal. So maybe https://github.com/SKLn-Rad/Xam.Plugin.Webview or Cordova's logic have good solution for this situation.

AndreiMisiukevich commented 3 years ago

iOS: https://github.com/AndreiMisiukevich/Xamarin.HybridWebView/blob/master/iOSRenderer.cs Android: https://github.com/AndreiMisiukevich/Xamarin.HybridWebView/blob/master/AndroidRenderer.cs

jingliancui commented 3 years ago

So , Do you consider make it to xct ? If yes I could prepare the work : ) @jfversluis @AndreiMisiukevich @IeuanWalker

AndreiMisiukevich commented 3 years ago

CC @jfversluis

brminnick commented 3 years ago

Thanks! However, we are no longer adding new features to Xamarin Community Toolkit, focusing on the .NET MAUI Community Toolkit.

Please open a New Feature Discussion to implement this feature in the .NET MAUI Community Toolkit.

I've posted more information about the Future Of Xamarin Community Toolkit here: https://devblogs.microsoft.com/xamarin/the-future-of-xamarin-community-toolkit/?WT.mc_id=mobile-0000-bramin