diff --git a/packages/desktop/src/protocol.rs b/packages/desktop/src/protocol.rs index a9fc54fb2..c35a29306 100644 --- a/packages/desktop/src/protocol.rs +++ b/packages/desktop/src/protocol.rs @@ -7,7 +7,10 @@ use wry::{ RequestAsyncResponder, }; -#[cfg(any(target_os = "android", target_os = "windows"))] +#[cfg(target_os = "android")] +const EVENTS_PATH: &str = "https://dioxus.index.html/__events"; + +#[cfg(target_os = "windows")] const EVENTS_PATH: &str = "http://dioxus.index.html/__events"; #[cfg(not(any(target_os = "android", target_os = "windows")))] diff --git a/packages/desktop/src/webview.rs b/packages/desktop/src/webview.rs index 01f0c6123..14489a2bd 100644 --- a/packages/desktop/src/webview.rs +++ b/packages/desktop/src/webview.rs @@ -317,7 +317,10 @@ impl WebviewInstance { .with_navigation_handler(move |var| { // We don't want to allow any navigation // We only want to serve the index file and assets - if var.starts_with("dioxus://") || var.starts_with("http://dioxus.") { + if var.starts_with("dioxus://") + || var.starts_with("http://dioxus.") + || var.starts_with("https://dioxus.") + { // After the page has loaded once, don't allow any more navigation let page_loaded = page_loaded.swap(true, std::sync::atomic::Ordering::SeqCst); !page_loaded @@ -333,6 +336,14 @@ impl WebviewInstance { }) // prevent all navigations .with_asynchronous_custom_protocol(String::from("dioxus"), request_handler); + // Enable https scheme on android, needed for secure context API, like the geolocation API + #[cfg(target_os = "android")] + { + use wry::WebViewBuilderExtAndroid as _; + + webview = webview.with_https_scheme(true); + }; + // Disable the webview default shortcuts to disable the reload shortcut #[cfg(target_os = "windows")] {