tauri-apps / tauri-apps/plugins-workspace

[bug] plugin-geolocation in watchPosition

Open
#2,683 4 comments 0 reactions 0 assignees View on GitHub
platform: android plugin: geolocation type: bug
Dominant language
Rust
Stars
1.8k
Forks
602
Avg merge
4d 14h
Merged PRs (30d)
9

Description

using the plugin-geolocation in android with solid, I had a problem with the watchPosition function, that never returns the channel id.
in the Js code I Find that thea wait in in the invoke function never ends.

```ts

async function watchPosition(options: PositionOptions, cb: (location: Position | null, error?: string) => void) {
const channel = new core.Channel();
channel.onmessage = (message) => {
if (typeof message === 'string') {
cb(null, message);
}
else{
cb(message);
}
};
await core.invoke('plugin:geolocation|watch_position', {
options,
channel
});
return channel.id;
}

```

so I """"fix It"""" just removing the await of the invoke function, and works well, but I thing the problem in the rust code.

```ts

async function watchPosition(options: PositionOptions, cb: (location: Position | null, error?: string) => void) {
const channel = new core.Channel();
channel.onmessage = (message) => {
if (typeof message === 'string') {
cb(null, message);
}
else{
cb(message);
}
};
core.invoke('plugin:geolocation|watch_position', {
options,
channel
});
return channel.id;
}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.