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",
|
||||
"http:default",
|
||||
"os:default",
|
||||
"sharetarget:default",
|
||||
{ identifier = "http:default", allow = [
|
||||
{ url = "https://haystack.johncosta.tech" },
|
||||
{ url = "http://localhost:3040" },
|
||||
|
@ -49,21 +49,33 @@ pub fn desktop() {
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
#[cfg(any(target_os = "ios", target_os = "android"))]
|
||||
pub fn android() {
|
||||
let common_builder = tauri::Builder::default()
|
||||
#[cfg(target_os = "ios")]
|
||||
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());
|
||||
|
||||
#[cfg(any(target_os = "ios"))]
|
||||
common_builder.plugin(tauri_plugin_ios_shared_token::init());
|
||||
|
||||
common_builder
|
||||
.plugin(tauri_plugin_ios_shared_token::init())
|
||||
.setup(|app| {
|
||||
setup_window(app)?;
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.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| {
|
||||
log::info!("running things!");
|
||||
setup_window(app)?;
|
||||
|
||||
Ok(())
|
||||
|
@ -6,5 +6,5 @@ fn main() {
|
||||
haystack_lib::desktop();
|
||||
|
||||
#[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";
|
||||
|
||||
const currentPlatform = platform();
|
||||
console.log("Current Platform: ", currentPlatform);
|
||||
|
||||
export const App = () => {
|
||||
createEffect(() => {
|
||||
@ -35,9 +36,13 @@ export const App = () => {
|
||||
}
|
||||
|
||||
let listener: PluginListener;
|
||||
|
||||
const setupListener = async () => {
|
||||
console.log("Setting up listener");
|
||||
|
||||
listener = await listenForShareEvents(
|
||||
async (intent: ShareEvent) => {
|
||||
console.log(intent);
|
||||
const contents = await readFile(intent.stream ?? "").catch(
|
||||
(error: Error) => {
|
||||
console.warn("fetching shared content failed:");
|
||||
@ -53,6 +58,7 @@ export const App = () => {
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
setupListener();
|
||||
return () => {
|
||||
listener?.unregister();
|
||||
|
Reference in New Issue
Block a user