BrowserInterop
BrowserInterop copied to clipboard
alerts by chrome
I am trying to recover my GPS position and receive these alerts from the chrome browser.
scripts.js:183 [Deprecation] 'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.
scripts.js:238 [Violation] Only request geolocation information in response to a user gesture.
Do you use the position watcher? https://stackoverflow.com/a/47598837/277067 https://remibou.github.io/Track-GPS-with-Blazor-BrowserInterop/
No. My code is as follows:
@using BrowserInterop.Extensions
...
private GeoLocation GPS = new();
...
var window = await JsRuntime.Window();
var navigator = await window.Navigator();
var position = await navigator.Geolocation.GetCurrentPosition();
if (position.Error != null)
{
Toast.ShowWarning(position.Error.Message, "alerta");
}
else if (position.Location != null)
{
GPS.Latitude = position.Location.Coords.Latitude;
GPS.Longitude = position.Location.Coords.Longitude;
GPS.Accuracy = position.Location.Coords.Accuracy;
}
From what I've read Chrome prefers when you get it from the watcher, you can have a look at my blog post
Well, about the second error:
it doesn't have to do with the type of resource we access from chrome, but rather the way we access it. chrome doesn’t like that we access it on the page load. it has to be explicitly requested by the user, like clicking a button. So I already know how to solve it.
But the first error continues to occur and I think it is some outdated code that is being called by the component.
@drma-dev yes the first error is just a warning because BrowserInterop browse the whole object tree in order to serialize it and send it to C#, I'll have a look to see if I can avoid this.