Xamarin Forms - Run a hidden WebView without attaching it to the view -
currently code creates instance of hidden class , initializes webview should download javascript server. problem if webview not part of main screen user looking at, doesn't load url.
my simple app:
public partial class app : application { // set hidden webview companysdk.fooclass foo = new companysdk.fooclass(); public app() { initializecomponent(); var page = new contentpage(); page = new demoapppage(); mainpage = page; } protected override void onstart() { // test method call foo.test(); } }
hidden webview class:
public class fooclass { webview browser = new webview(); public fooclass() { browser.source = "https://companyserver.com/xyz"; // make browser invisible browser.setvalue(isvisibleproperty, false); system.diagnostics.debug.writeline("webview started platform: " + device.os.tostring().tolower()); } public void test() { system.diagnostics.debug.writeline("test method "); string js = "alert('test method');"; browser.eval(js); } }
if change fooclass
contentpage
, add main app view, see calls companyserver.com
, can't have webview part of ui, should remain in background / hidden. debug prints show in cases, know code being called.
is there way achieve i'm after?
Comments
Post a Comment