Skip to content

Commit 2112d91

Browse files
committed
refactor(geolocation): simplify API, defer permission checks
1 parent 8a45c35 commit 2112d91

File tree

23 files changed

+599
-595
lines changed

23 files changed

+599
-595
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"geolocation": patch
3+
---
4+
5+
No longer request permission automatically and leave to the user how to handle the `checkPermissions` and `requestPermissions` APIs.

.changes/update-geolocation-api.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"geolocation-js": patch
3+
---
4+
5+
Update API to match other plugins.

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/api/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"@tauri-apps/plugin-clipboard-manager": "2.0.0-rc.1",
1717
"@tauri-apps/plugin-dialog": "2.0.0-rc.1",
1818
"@tauri-apps/plugin-fs": "2.0.0-rc.2",
19+
"@tauri-apps/plugin-geolocation": "2.0.0-rc.1",
1920
"@tauri-apps/plugin-global-shortcut": "2.0.0-rc.1",
21+
"@tauri-apps/plugin-haptics": "2.0.0-rc.1",
2022
"@tauri-apps/plugin-http": "2.0.0-rc.2",
2123
"@tauri-apps/plugin-nfc": "2.0.0-rc.1",
2224
"@tauri-apps/plugin-notification": "2.0.0-rc.1",

examples/api/src-tauri/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ tauri-plugin-updater = { path = "../../../plugins/updater", version = "2.0.0-rc.
5858
tauri-plugin-barcode-scanner = { path = "../../../plugins/barcode-scanner/", version = "2.0.0-rc.4" }
5959
tauri-plugin-nfc = { path = "../../../plugins/nfc", version = "2.0.0-rc.3" }
6060
tauri-plugin-biometric = { path = "../../../plugins/biometric/", version = "2.0.0-rc.3" }
61+
tauri-plugin-geolocation = { path = "../../../plugins/geolocation/", version = "2.0.0-rc.3" }
62+
tauri-plugin-haptics = { path = "../../../plugins/haptics/", version = "2.0.0-rc.3" }
6163

6264
[target."cfg(target_os = \"windows\")".dependencies]
6365
window-shadows = "0.2"

examples/api/src-tauri/capabilities/mobile.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
"barcode-scanner:allow-scan",
1212
"barcode-scanner:allow-cancel",
1313
"barcode-scanner:allow-request-permissions",
14-
"barcode-scanner:allow-check-permissions"
14+
"barcode-scanner:allow-check-permissions",
15+
"geolocation:allow-check-permissions",
16+
"geolocation:allow-request-permissions",
17+
"geolocation:allow-watch-position",
18+
"geolocation:allow-get-current-position"
1519
]
1620
}

examples/api/src-tauri/gen/android/.idea/misc.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/api/src-tauri/gen/schemas/mobile-schema.json

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6747,6 +6747,158 @@
67476747
"fs:write-files"
67486748
]
67496749
},
6750+
{
6751+
"type": "string",
6752+
"enum": [
6753+
"geolocation:default"
6754+
]
6755+
},
6756+
{
6757+
"description": "geolocation:allow-check-permissions -> Enables the check_permissions command without any pre-configured scope.",
6758+
"type": "string",
6759+
"enum": [
6760+
"geolocation:allow-check-permissions"
6761+
]
6762+
},
6763+
{
6764+
"description": "geolocation:allow-clear-permissions -> Enables the clear_permissions command without any pre-configured scope.",
6765+
"type": "string",
6766+
"enum": [
6767+
"geolocation:allow-clear-permissions"
6768+
]
6769+
},
6770+
{
6771+
"description": "geolocation:allow-clear-watch -> Enables the clear_watch command without any pre-configured scope.",
6772+
"type": "string",
6773+
"enum": [
6774+
"geolocation:allow-clear-watch"
6775+
]
6776+
},
6777+
{
6778+
"description": "geolocation:allow-get-current-position -> Enables the get_current_position command without any pre-configured scope.",
6779+
"type": "string",
6780+
"enum": [
6781+
"geolocation:allow-get-current-position"
6782+
]
6783+
},
6784+
{
6785+
"description": "geolocation:allow-request-permissions -> Enables the request_permissions command without any pre-configured scope.",
6786+
"type": "string",
6787+
"enum": [
6788+
"geolocation:allow-request-permissions"
6789+
]
6790+
},
6791+
{
6792+
"description": "geolocation:allow-watch-position -> Enables the watch_position command without any pre-configured scope.",
6793+
"type": "string",
6794+
"enum": [
6795+
"geolocation:allow-watch-position"
6796+
]
6797+
},
6798+
{
6799+
"description": "geolocation:deny-check-permissions -> Denies the check_permissions command without any pre-configured scope.",
6800+
"type": "string",
6801+
"enum": [
6802+
"geolocation:deny-check-permissions"
6803+
]
6804+
},
6805+
{
6806+
"description": "geolocation:deny-clear-permissions -> Denies the clear_permissions command without any pre-configured scope.",
6807+
"type": "string",
6808+
"enum": [
6809+
"geolocation:deny-clear-permissions"
6810+
]
6811+
},
6812+
{
6813+
"description": "geolocation:deny-clear-watch -> Denies the clear_watch command without any pre-configured scope.",
6814+
"type": "string",
6815+
"enum": [
6816+
"geolocation:deny-clear-watch"
6817+
]
6818+
},
6819+
{
6820+
"description": "geolocation:deny-get-current-position -> Denies the get_current_position command without any pre-configured scope.",
6821+
"type": "string",
6822+
"enum": [
6823+
"geolocation:deny-get-current-position"
6824+
]
6825+
},
6826+
{
6827+
"description": "geolocation:deny-request-permissions -> Denies the request_permissions command without any pre-configured scope.",
6828+
"type": "string",
6829+
"enum": [
6830+
"geolocation:deny-request-permissions"
6831+
]
6832+
},
6833+
{
6834+
"description": "geolocation:deny-watch-position -> Denies the watch_position command without any pre-configured scope.",
6835+
"type": "string",
6836+
"enum": [
6837+
"geolocation:deny-watch-position"
6838+
]
6839+
},
6840+
{
6841+
"type": "string",
6842+
"enum": [
6843+
"haptics:default"
6844+
]
6845+
},
6846+
{
6847+
"description": "haptics:allow-impact-feedback -> Enables the impact_feedback command without any pre-configured scope.",
6848+
"type": "string",
6849+
"enum": [
6850+
"haptics:allow-impact-feedback"
6851+
]
6852+
},
6853+
{
6854+
"description": "haptics:allow-notification-feedback -> Enables the notification_feedback command without any pre-configured scope.",
6855+
"type": "string",
6856+
"enum": [
6857+
"haptics:allow-notification-feedback"
6858+
]
6859+
},
6860+
{
6861+
"description": "haptics:allow-selection-feedback -> Enables the selection_feedback command without any pre-configured scope.",
6862+
"type": "string",
6863+
"enum": [
6864+
"haptics:allow-selection-feedback"
6865+
]
6866+
},
6867+
{
6868+
"description": "haptics:allow-vibrate -> Enables the vibrate command without any pre-configured scope.",
6869+
"type": "string",
6870+
"enum": [
6871+
"haptics:allow-vibrate"
6872+
]
6873+
},
6874+
{
6875+
"description": "haptics:deny-impact-feedback -> Denies the impact_feedback command without any pre-configured scope.",
6876+
"type": "string",
6877+
"enum": [
6878+
"haptics:deny-impact-feedback"
6879+
]
6880+
},
6881+
{
6882+
"description": "haptics:deny-notification-feedback -> Denies the notification_feedback command without any pre-configured scope.",
6883+
"type": "string",
6884+
"enum": [
6885+
"haptics:deny-notification-feedback"
6886+
]
6887+
},
6888+
{
6889+
"description": "haptics:deny-selection-feedback -> Denies the selection_feedback command without any pre-configured scope.",
6890+
"type": "string",
6891+
"enum": [
6892+
"haptics:deny-selection-feedback"
6893+
]
6894+
},
6895+
{
6896+
"description": "haptics:deny-vibrate -> Denies the vibrate command without any pre-configured scope.",
6897+
"type": "string",
6898+
"enum": [
6899+
"haptics:deny-vibrate"
6900+
]
6901+
},
67506902
{
67516903
"description": "http:default -> This permission set configures what kind of\nfetch operations are available from the http plugin.\n\nThis enables all fetch operations but does not\nallow explicitly any origins to be fetched. This needs to\nbe manually configured before usage.\n\n#### Granted Permissions\n\nAll fetch operations are enabled.\n\n",
67526904
"type": "string",

examples/api/src-tauri/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ pub fn run() {
5353
app.handle().plugin(tauri_plugin_barcode_scanner::init())?;
5454
app.handle().plugin(tauri_plugin_nfc::init())?;
5555
app.handle().plugin(tauri_plugin_biometric::init())?;
56+
app.handle().plugin(tauri_plugin_geolocation::init())?;
57+
app.handle().plugin(tauri_plugin_haptics::init())?;
5658
}
5759

5860
let mut webview_window_builder =

0 commit comments

Comments
 (0)