From f98cd2169ae688ebe8cfcf651431c2bf00c873f9 Mon Sep 17 00:00:00 2001 From: rizky_denianto Date: Thu, 16 Jul 2026 22:24:34 +0700 Subject: [PATCH 1/5] Memperbaiki fungsi invoke --- android/src/main/AndroidManifest.xml | 2 ++ guest-js/index.ts | 7 +++++-- package.json | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 87ebec0..5858219 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,5 +1,7 @@ + + diff --git a/guest-js/index.ts b/guest-js/index.ts index 349f377..9198960 100644 --- a/guest-js/index.ts +++ b/guest-js/index.ts @@ -2,11 +2,13 @@ import { invoke } from "@tauri-apps/api/core"; import { SBlueclasMuatanKirim, SBlueclasResponDaftarPerangkat } from "./models"; export async function cekIzin(): Promise { - return await invoke("plugin:bluclas|cek_izin").then((res: string) => res); + return await invoke("plugin:bluclas|cek_izin", {}).then( + (res: string) => res, + ); } export async function mintaIzin(): Promise { - return await invoke("plugin:bluclas|minta_izin"); + return await invoke("plugin:bluclas|minta_izin", {}); } export async function daftarPerangkat(): Promise< @@ -14,6 +16,7 @@ export async function daftarPerangkat(): Promise< > { return await invoke( "plugin:bluclas|daftar_perangkat", + {}, ).then((res: SBlueclasResponDaftarPerangkat[]) => res); } diff --git a/package.json b/package.json index 10b933c..7cf6f82 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@segubi/tauri-plugin-bluclas-api", - "version": "0.1.1", + "version": "0.1.2", "author": "Rizky Denianto", "description": "", "type": "module", -- 2.54.0 From c195d2bc99a5c95b49d9d0b90c8eb8229c09f46f Mon Sep 17 00:00:00 2001 From: rizky_denianto Date: Thu, 16 Jul 2026 22:46:59 +0700 Subject: [PATCH 2/5] Menghapus cek izin dan minta izin --- build.rs | 2 +- guest-js/index.ts | 11 ---- package.json | 2 +- .../autogenerated/commands/cek_izin.toml | 13 ----- .../autogenerated/commands/minta_izin.toml | 13 ----- permissions/autogenerated/reference.md | 54 ------------------- permissions/default.toml | 2 - permissions/schemas/schema.json | 28 +--------- src/commands.rs | 10 ---- src/desktop.rs | 8 --- src/lib.rs | 9 +--- src/mobile.rs | 14 ----- 12 files changed, 6 insertions(+), 160 deletions(-) delete mode 100644 permissions/autogenerated/commands/cek_izin.toml delete mode 100644 permissions/autogenerated/commands/minta_izin.toml diff --git a/build.rs b/build.rs index 730d157..52293eb 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,4 @@ -const COMMANDS: &[&str] = &["cek_izin", "minta_izin", "daftar_perangkat", "kirim"]; +const COMMANDS: &[&str] = &["daftar_perangkat", "kirim"]; fn main() { tauri_plugin::Builder::new(COMMANDS) diff --git a/guest-js/index.ts b/guest-js/index.ts index 9198960..982b5dd 100644 --- a/guest-js/index.ts +++ b/guest-js/index.ts @@ -1,22 +1,11 @@ import { invoke } from "@tauri-apps/api/core"; import { SBlueclasMuatanKirim, SBlueclasResponDaftarPerangkat } from "./models"; -export async function cekIzin(): Promise { - return await invoke("plugin:bluclas|cek_izin", {}).then( - (res: string) => res, - ); -} - -export async function mintaIzin(): Promise { - return await invoke("plugin:bluclas|minta_izin", {}); -} - export async function daftarPerangkat(): Promise< SBlueclasResponDaftarPerangkat[] > { return await invoke( "plugin:bluclas|daftar_perangkat", - {}, ).then((res: SBlueclasResponDaftarPerangkat[]) => res); } diff --git a/package.json b/package.json index 7cf6f82..c48a68b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@segubi/tauri-plugin-bluclas-api", - "version": "0.1.2", + "version": "0.1.3", "author": "Rizky Denianto", "description": "", "type": "module", diff --git a/permissions/autogenerated/commands/cek_izin.toml b/permissions/autogenerated/commands/cek_izin.toml deleted file mode 100644 index 0e4fefe..0000000 --- a/permissions/autogenerated/commands/cek_izin.toml +++ /dev/null @@ -1,13 +0,0 @@ -# Automatically generated - DO NOT EDIT! - -"$schema" = "../../schemas/schema.json" - -[[permission]] -identifier = "allow-cek-izin" -description = "Enables the cek_izin command without any pre-configured scope." -commands.allow = ["cek_izin"] - -[[permission]] -identifier = "deny-cek-izin" -description = "Denies the cek_izin command without any pre-configured scope." -commands.deny = ["cek_izin"] diff --git a/permissions/autogenerated/commands/minta_izin.toml b/permissions/autogenerated/commands/minta_izin.toml deleted file mode 100644 index e406f3f..0000000 --- a/permissions/autogenerated/commands/minta_izin.toml +++ /dev/null @@ -1,13 +0,0 @@ -# Automatically generated - DO NOT EDIT! - -"$schema" = "../../schemas/schema.json" - -[[permission]] -identifier = "allow-minta-izin" -description = "Enables the minta_izin command without any pre-configured scope." -commands.allow = ["minta_izin"] - -[[permission]] -identifier = "deny-minta-izin" -description = "Denies the minta_izin command without any pre-configured scope." -commands.deny = ["minta_izin"] diff --git a/permissions/autogenerated/reference.md b/permissions/autogenerated/reference.md index c96eeaf..e1ced02 100644 --- a/permissions/autogenerated/reference.md +++ b/permissions/autogenerated/reference.md @@ -4,8 +4,6 @@ Default permissions for the plugin #### This default permission set includes the following: -- `allow-cek-izin` -- `allow-minta-izin` - `allow-daftar-perangkat` - `allow-kirim` @@ -18,32 +16,6 @@ Default permissions for the plugin - - - -`bluclas:allow-cek-izin` - - - - -Enables the cek_izin command without any pre-configured scope. - - - - - - - -`bluclas:deny-cek-izin` - - - - -Denies the cek_izin command without any pre-configured scope. - - - - @@ -93,32 +65,6 @@ Enables the kirim command without any pre-configured scope. Denies the kirim command without any pre-configured scope. - - - - - - -`bluclas:allow-minta-izin` - - - - -Enables the minta_izin command without any pre-configured scope. - - - - - - - -`bluclas:deny-minta-izin` - - - - -Denies the minta_izin command without any pre-configured scope. - diff --git a/permissions/default.toml b/permissions/default.toml index 54eeb34..c7f297b 100644 --- a/permissions/default.toml +++ b/permissions/default.toml @@ -1,8 +1,6 @@ [default] description = "Default permissions for the plugin" permissions = [ - "allow-cek-izin", - "allow-minta-izin", "allow-daftar-perangkat", "allow-kirim" ] diff --git a/permissions/schemas/schema.json b/permissions/schemas/schema.json index 7b7fbec..d166461 100644 --- a/permissions/schemas/schema.json +++ b/permissions/schemas/schema.json @@ -294,18 +294,6 @@ "PermissionKind": { "type": "string", "oneOf": [ - { - "description": "Enables the cek_izin command without any pre-configured scope.", - "type": "string", - "const": "allow-cek-izin", - "markdownDescription": "Enables the cek_izin command without any pre-configured scope." - }, - { - "description": "Denies the cek_izin command without any pre-configured scope.", - "type": "string", - "const": "deny-cek-izin", - "markdownDescription": "Denies the cek_izin command without any pre-configured scope." - }, { "description": "Enables the daftar_perangkat command without any pre-configured scope.", "type": "string", @@ -331,22 +319,10 @@ "markdownDescription": "Denies the kirim command without any pre-configured scope." }, { - "description": "Enables the minta_izin command without any pre-configured scope.", - "type": "string", - "const": "allow-minta-izin", - "markdownDescription": "Enables the minta_izin command without any pre-configured scope." - }, - { - "description": "Denies the minta_izin command without any pre-configured scope.", - "type": "string", - "const": "deny-minta-izin", - "markdownDescription": "Denies the minta_izin command without any pre-configured scope." - }, - { - "description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-cek-izin`\n- `allow-minta-izin`\n- `allow-daftar-perangkat`\n- `allow-kirim`", + "description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-daftar-perangkat`\n- `allow-kirim`", "type": "string", "const": "default", - "markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-cek-izin`\n- `allow-minta-izin`\n- `allow-daftar-perangkat`\n- `allow-kirim`" + "markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-daftar-perangkat`\n- `allow-kirim`" } ] } diff --git a/src/commands.rs b/src/commands.rs index bc5c9c9..ec5f82d 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -4,16 +4,6 @@ use crate::BluclasExt; use crate::Result; use crate::models::*; -#[command] -pub(crate) async fn cek_izin(app: AppHandle) -> Result { - return app.bluclas().cek_izin(); -} - -#[command] -pub(crate) async fn minta_izin(app: AppHandle) -> Result<()> { - return app.bluclas().minta_izin(); -} - #[command] pub(crate) async fn daftar_perangkat( app: AppHandle, diff --git a/src/desktop.rs b/src/desktop.rs index c188a48..5f6ee09 100644 --- a/src/desktop.rs +++ b/src/desktop.rs @@ -14,14 +14,6 @@ pub fn init( pub struct Bluclas(AppHandle); impl Bluclas { - pub fn cek_izin(&self) -> crate::Result { - return Ok(String::new()); - } - - pub fn minta_izin(&self) -> crate::Result<()> { - return Ok(()); - } - pub fn daftar_perangkat(&self) -> crate::Result { return Ok(SBlueclasResponDaftarPerangkat { data: vec![] }); } diff --git a/src/lib.rs b/src/lib.rs index f8f9229..c155540 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -use crate::commands::{cek_izin, daftar_perangkat, kirim, minta_izin}; +use crate::commands::{daftar_perangkat, kirim}; use tauri::{ Manager, Runtime, plugin::{Builder, TauriPlugin}, @@ -36,12 +36,7 @@ impl> crate::BluclasExt for T { /// Initializes the plugin. pub fn init() -> TauriPlugin { Builder::new("bluclas") - .invoke_handler(tauri::generate_handler![ - cek_izin, - minta_izin, - daftar_perangkat, - kirim - ]) + .invoke_handler(tauri::generate_handler![daftar_perangkat, kirim]) .setup(|app, api| { #[cfg(mobile)] let bluclas = mobile::init(app, api)?; diff --git a/src/mobile.rs b/src/mobile.rs index 363a0bd..f976f48 100644 --- a/src/mobile.rs +++ b/src/mobile.rs @@ -25,20 +25,6 @@ pub fn init( pub struct Bluclas(PluginHandle); impl Bluclas { - pub fn cek_izin(&self) -> crate::Result { - return self - .0 - .run_mobile_plugin("checkPermissions", ()) - .map_err(Into::into); - } - - pub fn minta_izin(&self) -> crate::Result<()> { - return self - .0 - .run_mobile_plugin("requestPermissions", ()) - .map_err(Into::into); - } - pub fn daftar_perangkat(&self) -> crate::Result { return self .0 -- 2.54.0 From f881c0947554847408ea2d245c211ad33d59bcc1 Mon Sep 17 00:00:00 2001 From: rizky_denianto Date: Thu, 16 Jul 2026 22:56:47 +0700 Subject: [PATCH 3/5] Mengubah cara mengecek dan meminta izin --- android/src/main/java/BluclasPlugin.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/BluclasPlugin.kt b/android/src/main/java/BluclasPlugin.kt index f9d46d0..ebb2047 100644 --- a/android/src/main/java/BluclasPlugin.kt +++ b/android/src/main/java/BluclasPlugin.kt @@ -45,12 +45,19 @@ class BluclasPlugin(private val activity: Activity) : Plugin(activity) { @Command override fun checkPermissions(invoke: Invoke) { - super.checkPermissions(invoke) + val result = JSObject() + result.put("bluetooth", getPermissionState("bluetooth").toString()) + invoke.resolve(result) } @Command override fun requestPermissions(invoke: Invoke) { - super.requestPermissions(invoke) + requestPermissionForAlias("bluetooth", invoke, "permissionsCallback") + } + + @PermissionCallback + private fun permissionsCallback(invoke: Invoke) { + checkPermissions(invoke) } @Command -- 2.54.0 From 2777aaea841aeb71cf667f9291a7c03e331fc773 Mon Sep 17 00:00:00 2001 From: rizky_denianto Date: Thu, 16 Jul 2026 22:57:15 +0700 Subject: [PATCH 4/5] Menaikkan versi --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c48a68b..827fbc7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@segubi/tauri-plugin-bluclas-api", - "version": "0.1.3", + "version": "0.1.4", "author": "Rizky Denianto", "description": "", "type": "module", -- 2.54.0 From f2dcab4ca453bd5ab223b4e7d70e4fef768767dc Mon Sep 17 00:00:00 2001 From: rizky_denianto Date: Thu, 16 Jul 2026 23:04:04 +0700 Subject: [PATCH 5/5] Menambah izin dan coba menggunakan program kotlin lama --- android/src/main/java/BluclasPlugin.kt | 11 +--- build.rs | 7 ++- package.json | 2 +- .../commands/check_permissions.toml | 13 +++++ .../commands/request_permissions.toml | 13 +++++ permissions/autogenerated/reference.md | 54 +++++++++++++++++++ permissions/default.toml | 2 + permissions/schemas/schema.json | 28 +++++++++- 8 files changed, 117 insertions(+), 13 deletions(-) create mode 100644 permissions/autogenerated/commands/check_permissions.toml create mode 100644 permissions/autogenerated/commands/request_permissions.toml diff --git a/android/src/main/java/BluclasPlugin.kt b/android/src/main/java/BluclasPlugin.kt index ebb2047..f9d46d0 100644 --- a/android/src/main/java/BluclasPlugin.kt +++ b/android/src/main/java/BluclasPlugin.kt @@ -45,19 +45,12 @@ class BluclasPlugin(private val activity: Activity) : Plugin(activity) { @Command override fun checkPermissions(invoke: Invoke) { - val result = JSObject() - result.put("bluetooth", getPermissionState("bluetooth").toString()) - invoke.resolve(result) + super.checkPermissions(invoke) } @Command override fun requestPermissions(invoke: Invoke) { - requestPermissionForAlias("bluetooth", invoke, "permissionsCallback") - } - - @PermissionCallback - private fun permissionsCallback(invoke: Invoke) { - checkPermissions(invoke) + super.requestPermissions(invoke) } @Command diff --git a/build.rs b/build.rs index 52293eb..a486007 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,9 @@ -const COMMANDS: &[&str] = &["daftar_perangkat", "kirim"]; +const COMMANDS: &[&str] = &[ + "check_permissions", + "request_permissions", + "daftar_perangkat", + "kirim", +]; fn main() { tauri_plugin::Builder::new(COMMANDS) diff --git a/package.json b/package.json index 827fbc7..3a9cc51 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@segubi/tauri-plugin-bluclas-api", - "version": "0.1.4", + "version": "0.1.5", "author": "Rizky Denianto", "description": "", "type": "module", diff --git a/permissions/autogenerated/commands/check_permissions.toml b/permissions/autogenerated/commands/check_permissions.toml new file mode 100644 index 0000000..f5af08b --- /dev/null +++ b/permissions/autogenerated/commands/check_permissions.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-check-permissions" +description = "Enables the check_permissions command without any pre-configured scope." +commands.allow = ["check_permissions"] + +[[permission]] +identifier = "deny-check-permissions" +description = "Denies the check_permissions command without any pre-configured scope." +commands.deny = ["check_permissions"] diff --git a/permissions/autogenerated/commands/request_permissions.toml b/permissions/autogenerated/commands/request_permissions.toml new file mode 100644 index 0000000..02dcd62 --- /dev/null +++ b/permissions/autogenerated/commands/request_permissions.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-request-permissions" +description = "Enables the request_permissions command without any pre-configured scope." +commands.allow = ["request_permissions"] + +[[permission]] +identifier = "deny-request-permissions" +description = "Denies the request_permissions command without any pre-configured scope." +commands.deny = ["request_permissions"] diff --git a/permissions/autogenerated/reference.md b/permissions/autogenerated/reference.md index e1ced02..0d7056b 100644 --- a/permissions/autogenerated/reference.md +++ b/permissions/autogenerated/reference.md @@ -4,6 +4,8 @@ Default permissions for the plugin #### This default permission set includes the following: +- `allow-check-permissions` +- `allow-request-permissions` - `allow-daftar-perangkat` - `allow-kirim` @@ -16,6 +18,32 @@ Default permissions for the plugin + + + +`bluclas:allow-check-permissions` + + + + +Enables the check_permissions command without any pre-configured scope. + + + + + + + +`bluclas:deny-check-permissions` + + + + +Denies the check_permissions command without any pre-configured scope. + + + + @@ -65,6 +93,32 @@ Enables the kirim command without any pre-configured scope. Denies the kirim command without any pre-configured scope. + + + + + + +`bluclas:allow-request-permissions` + + + + +Enables the request_permissions command without any pre-configured scope. + + + + + + + +`bluclas:deny-request-permissions` + + + + +Denies the request_permissions command without any pre-configured scope. + diff --git a/permissions/default.toml b/permissions/default.toml index c7f297b..473ca86 100644 --- a/permissions/default.toml +++ b/permissions/default.toml @@ -1,6 +1,8 @@ [default] description = "Default permissions for the plugin" permissions = [ + "allow-check-permissions", + "allow-request-permissions", "allow-daftar-perangkat", "allow-kirim" ] diff --git a/permissions/schemas/schema.json b/permissions/schemas/schema.json index d166461..21b10d7 100644 --- a/permissions/schemas/schema.json +++ b/permissions/schemas/schema.json @@ -294,6 +294,18 @@ "PermissionKind": { "type": "string", "oneOf": [ + { + "description": "Enables the check_permissions command without any pre-configured scope.", + "type": "string", + "const": "allow-check-permissions", + "markdownDescription": "Enables the check_permissions command without any pre-configured scope." + }, + { + "description": "Denies the check_permissions command without any pre-configured scope.", + "type": "string", + "const": "deny-check-permissions", + "markdownDescription": "Denies the check_permissions command without any pre-configured scope." + }, { "description": "Enables the daftar_perangkat command without any pre-configured scope.", "type": "string", @@ -319,10 +331,22 @@ "markdownDescription": "Denies the kirim command without any pre-configured scope." }, { - "description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-daftar-perangkat`\n- `allow-kirim`", + "description": "Enables the request_permissions command without any pre-configured scope.", + "type": "string", + "const": "allow-request-permissions", + "markdownDescription": "Enables the request_permissions command without any pre-configured scope." + }, + { + "description": "Denies the request_permissions command without any pre-configured scope.", + "type": "string", + "const": "deny-request-permissions", + "markdownDescription": "Denies the request_permissions command without any pre-configured scope." + }, + { + "description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-check-permissions`\n- `allow-request-permissions`\n- `allow-daftar-perangkat`\n- `allow-kirim`", "type": "string", "const": "default", - "markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-daftar-perangkat`\n- `allow-kirim`" + "markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-check-permissions`\n- `allow-request-permissions`\n- `allow-daftar-perangkat`\n- `allow-kirim`" } ] } -- 2.54.0