feat: android version correctly working alongside iOS version
This commit is contained in:
8
frontend/src-tauri/capabilities/android.toml
Normal file
8
frontend/src-tauri/capabilities/android.toml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
identifier = "android"
|
||||||
|
description = "Capabilities for Android platforms"
|
||||||
|
windows = ["main"]
|
||||||
|
platforms = ["android"]
|
||||||
|
|
||||||
|
permissions = [
|
||||||
|
"sharetarget:default"
|
||||||
|
]
|
@ -8,7 +8,6 @@ permissions = [
|
|||||||
"fs:default",
|
"fs:default",
|
||||||
"http:default",
|
"http:default",
|
||||||
"os:default",
|
"os:default",
|
||||||
"sharetarget:default",
|
|
||||||
{ identifier = "http:default", allow = [
|
{ identifier = "http:default", allow = [
|
||||||
{ url = "https://haystack.johncosta.tech" },
|
{ url = "https://haystack.johncosta.tech" },
|
||||||
{ url = "http://localhost:3040" },
|
{ url = "http://localhost:3040" },
|
||||||
|
@ -49,21 +49,33 @@ pub fn desktop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
#[cfg(any(target_os = "ios", target_os = "android"))]
|
#[cfg(target_os = "ios")]
|
||||||
pub fn android() {
|
pub fn mobile() {
|
||||||
let common_builder = tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_os::init())
|
.plugin(tauri_plugin_os::init())
|
||||||
.plugin(tauri_plugin_fs::init())
|
.plugin(tauri_plugin_fs::init())
|
||||||
.plugin(tauri_plugin_store::Builder::new().build())
|
.plugin(tauri_plugin_store::Builder::new().build())
|
||||||
.plugin(tauri_plugin_http::init())
|
.plugin(tauri_plugin_http::init())
|
||||||
.plugin(tauri_plugin_sharetarget::init());
|
.plugin(tauri_plugin_ios_shared_token::init())
|
||||||
|
.setup(|app| {
|
||||||
#[cfg(any(target_os = "ios"))]
|
setup_window(app)?;
|
||||||
common_builder.plugin(tauri_plugin_ios_shared_token::init());
|
|
||||||
|
Ok(())
|
||||||
common_builder
|
})
|
||||||
|
.run(tauri::generate_context!())
|
||||||
|
.expect("error while running ios tauri application");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
pub fn mobile() {
|
||||||
|
tauri::Builder::default()
|
||||||
|
.plugin(tauri_plugin_os::init())
|
||||||
|
.plugin(tauri_plugin_fs::init())
|
||||||
|
.plugin(tauri_plugin_store::Builder::new().build())
|
||||||
|
.plugin(tauri_plugin_http::init())
|
||||||
|
.plugin(tauri_plugin_sharetarget::init())
|
||||||
.setup(|app| {
|
.setup(|app| {
|
||||||
log::info!("running things!");
|
|
||||||
setup_window(app)?;
|
setup_window(app)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -6,5 +6,5 @@ fn main() {
|
|||||||
haystack_lib::desktop();
|
haystack_lib::desktop();
|
||||||
|
|
||||||
#[cfg(any(target_os = "ios", target_os = "android"))]
|
#[cfg(any(target_os = "ios", target_os = "android"))]
|
||||||
haystack_lib::android();
|
haystack_lib::mobile();
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import {
|
|||||||
import { readFile } from "@tauri-apps/plugin-fs";
|
import { readFile } from "@tauri-apps/plugin-fs";
|
||||||
|
|
||||||
const currentPlatform = platform();
|
const currentPlatform = platform();
|
||||||
|
console.log("Current Platform: ", currentPlatform);
|
||||||
|
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
@ -35,9 +36,13 @@ export const App = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let listener: PluginListener;
|
let listener: PluginListener;
|
||||||
|
|
||||||
const setupListener = async () => {
|
const setupListener = async () => {
|
||||||
|
console.log("Setting up listener");
|
||||||
|
|
||||||
listener = await listenForShareEvents(
|
listener = await listenForShareEvents(
|
||||||
async (intent: ShareEvent) => {
|
async (intent: ShareEvent) => {
|
||||||
|
console.log(intent);
|
||||||
const contents = await readFile(intent.stream ?? "").catch(
|
const contents = await readFile(intent.stream ?? "").catch(
|
||||||
(error: Error) => {
|
(error: Error) => {
|
||||||
console.warn("fetching shared content failed:");
|
console.warn("fetching shared content failed:");
|
||||||
@ -53,6 +58,7 @@ export const App = () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
setupListener();
|
setupListener();
|
||||||
return () => {
|
return () => {
|
||||||
listener?.unregister();
|
listener?.unregister();
|
||||||
|
Reference in New Issue
Block a user