Add secure context on android (#4428)

* Add secure context on android

* Remove location permission in AndroidManifest.xml.hbs
This commit is contained in:
Olivier Lemoine authored and GitHub committed 2025-07-22 13:12:30 -07:00
1 parent 6524f55462
commit 196db43e23
2 files changed
+16 -2

No files matched your search

+4 -1
View File
@@ -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")))]
+12 -1
View File
@@ -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")]
{