JsBridge | A simpler, extendable bidirectional communication Frame between Android WebView and Javascript | Android library
kandi X-RAY | JsBridge Summary
kandi X-RAY | JsBridge Summary
A simpler, extendable bidirectional communication Frame between Android WebView and Javascript.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Load modules
- Creates a JsMethod
- Get all methods
- Get the location
- Get the current location
- Implementation of JavaScript
- Convert java object to JS object
- Take a photo
- Code bitmap to base64 string
- Create a custom web view
- Low - level share the application
- Show an alert dialog
- Returns a set of all keys in this map
- Cleans all exposed methods
- Called when the widget is created
- The default implementation of this class
- Override this method to handle photo
- Get the module name
- This method test hook for return result
- This method is called when the activity is completed
- When a View is clicked the Activity is clicked
- Create the web view
- This method does the actual test
- Take photo
- Handle ajax request
JsBridge Key Features
JsBridge Examples and Code Snippets
Community Discussions
Trending Discussions on JsBridge
QUESTION
I saw above msdn document about HybridWebView of xamarin
I understood the way communicate to c# and vanillajs
HybridWebViewRenderer.cs
...ANSWER
Answered 2021-Oct-26 at 07:57I modified the React part after seeing the comments of the ToolmakerSteve.
At first I thought that the function could not be found because the function was renamed during a production build of react, but I found that it works regardless (It was just my misunderstanding that the method executed in JavaScript and the method executed in C# had the same name.)
Also I didn't know eval() how to do Invoke C# Code
in jsx I was wondering if I could use a method like
Below is an example of the code I have successfully received data from react.
React Part
TestFunctions.ts
QUESTION
Recently I've had the assignment to create a bi-directional interop bridge between a shell app and a webpage in .NET MAUI. Not finding any way to solve this I had the idea of creating it in Xamarin.Forms first seeing as MAUI is a continuation on it.
After having created this app, I've tried to convert it over to MAUI using Microsoft's instructions on the dotnet/maui github wiki.
The main problem i'm encountering right now is that I've been using extensions on Android's WebViewRenderer, WebViewClient and Java.Lang.Object to be able to send and receive javascript to and from the WebView.
...ANSWER
Answered 2021-Aug-21 at 22:28MAUI's default WebView
has the Eval
and EvaluateJavaScriptAsync
functions to call JavaScript code from C#:
Eval
just executes the scriptstring
you pass in a fire-and-forget way.EvaluateJavaScriptAsync
needs to be awaited but also returns astring
with a stringified result of the data that the script returned.
If you want to use callback/bridge methods to automatically receive data from the JavaScript side without any input from the C# side of the app, you will have to extend the default per-platform renderers to add that functionality. The good news is that there is an official tutorial on how to do it for Xamarin Forms at Customizing a WebView which is almost straightforward to port to .NET MAUI - you only have to change how renderers are registered.
QUESTION
Upcalls from JavaScript to JavaFX works fine. But if I add a variable containing the VLCJ player implementation then everything stops working.
Main.java:
...ANSWER
Answered 2021-Mar-02 at 14:07Solved the problem thanks to this answer: https://stackoverflow.com/a/53618875/10946427
It turns out my JSBridge was being destroyed by the garbage collector and because of VLCJ it was faster.
If you create a JSBridge variable inside the class, then the garbage collector will not destroy it and everything will work.
QUESTION
I'm using a webview in xamarin, i followed many tutorials to handle navigation, and all works fine. My issue is : when an anchor tag has a target="_blank" the event Navigating is never fired.
I see arround someone give a javascript solution which remove target=_blank and attach it at the end of href link.
Is really that the right way to do that? Look wired..
Thank you
This is initialization in xamarin.android renderer
...ANSWER
Answered 2020-Nov-05 at 14:35After the great help of Jack Hua i'm able to solve the problem. In OnElementChanged of Hybrid renderer i set support for multiple windows.
QUESTION
I am trying to set a view for a lookup field in Resco using JSBridge But the code does not work. Can you please point out where i am going wrong.
Below is my code --
...ANSWER
Answered 2020-Aug-23 at 02:37So i found the answer to my above query. Below is the working code to set lookup view dynamically in resco.
Posting it so that it helps others.
QUESTION
I will try and explain everything to the best of my ability, but I am new to using Xamarin so please bear with me while I try to give you an understanding of my situation.
I am using Xamarin Forms to build an Android application, I already have a desktop application that uses Electron so I have lots of pre-built user interface in HTML which I am using in a HybridWebView for the interface and JSBridge to call the C# code.
My application will only be installed on a clients network of devices, and we have set up a foreground service, that has a service notification to keep the background jobs running; this is all working as intended.
Calling C# code from the HTML interface is easy enough using the JSBridge / HybridWebView, however, I am unable to find a way that allows my C# functions inside the JSBridge class to talk to my foreground service which has already been started by the MainActivity, this service runs background jobs that return data that my UI will need access to.
My Service is being started in the MainActivity OnCreate like so:
...ANSWER
Answered 2020-Mar-29 at 04:12As suggested by SushiHangover, using a bound service is the way to go.
The documentation isn't very helpful and while it says a bound service calls OnBind() to start, it also mentions that it can also call OnStartCommand. However, the documentation doesn't mention that to have OnStartCommand fire you need to call StartService as well as BindService.
Example:
QUESTION
I followed the post to create a custon WebView to interact with client JavaScript: https://docs.microsoft.com/es-es/xamarin/xamarin-forms/app-fundamentals/custom-renderer/hybridwebview
But when I try to load a page, for example https://www.google.es, the wevView shows an "ERROR_FILE_NOT_FOUND" loading the page "file:///android_asset/Content/https://www.google.es"
This the OnElementChanged of the HybridWebViewRenderer:
...ANSWER
Answered 2020-Mar-25 at 15:47Solved:
Changing the LoadUrl method:
QUESTION
I need to execute a function defined in wpf project, which is called from JS in a https
web page.
The demo project of all codes is here: https://github.com/tomxue/WebViewIssueInWpf
JS part: The web page link is https://cmsdev.lenovo.com.cn/musichtml/leHome/weather/index.html?date=&city=&mark=0&speakerId=&reply=
And it contains below line:
...ANSWER
Answered 2020-Mar-02 at 14:47HTTPS link worked fine for me, maybe the page is too slow to load?
According to Microsoft (source), only ScriptNotify
is supported in WebView
:
Can I inject native objects into my WebViewControl content?
No. Neither the WebBrower (Internet Explorer) ObjectForScripting property nor the WebView (UWP) AddWebAllowedObject method are supported in WebViewControl. As a workaround, you can use window.external.notify/ ScriptNotify and JavaScript execution to communicate between the layers, for example: https://github.com/rjmurillo/WebView_AddAllowedWebObjectWorkaround
But the above suggested workaround solution seems to work differently to your expectation, so I just implement my own solution to emulate the JSBridge convention you have expected.
My custom solution is not battle-tested, it might break in some edge cases but it seems to work fine in few simple tests.
What's supported:
- Multiple bridge objects
- JS to C# method call
- JS to C# get/set property
C# Usage:
QUESTION
I am using Xamarin.Forms with Prism and the Syncfusion RichTextEditor component on an Android device. The issue I am having is that I can't seem to retrieve the edited text back in the view model. I have used a binding to the Text property, which is always null. I have tried to add an event handler for "TextChanged" event in the code behind - this event is never fired. I have attempted to call RichTextEditor.GetHtmlString() in the code behind too - which returns null.
The editor displays correctly in the app and all editing functionality(bold, italic etc.) seem to work just fine, however a warning in the output log shows:
[INFO:CONSOLE(1)] "Uncaught TypeError: jsBridge.invokeAction is not a function", source: (1)12-19 11:10:32.963 I/chromium(13310): [INFO:CONSOLE(1)] "Uncaught TypeError: jsBridge.invokeAction is not a function", source: (1)
Xamarin.Forms - 4.4.0.991265
Syncfusion.Xamarin.SfRichTextEditor - 17.4.0.39
Edit: Syncfusion support have provided an example where the modified text is correctly updated in the view model. The only visible difference is that it is using Unity not DryIoc. I have created a replica sample project using DryIoc and the updated text is still correctly being populated in the view model... must be something to do with the project setup!!
...ANSWER
Answered 2020-Jan-08 at 11:16After removing all nugets and unrelated code from the solution my code still returned null when updating the text.
Looking into the Android project setup vs the newly created sample solution I found that the "Dex Compiler" was set to D8 in my project but DX by default in both test solutions, changing that to DX fixed the issue... Text and HtmlText are now correctly being bound to the viewmodel and I can extract their values!
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install JsBridge
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page