BrowserInterop icon indicating copy to clipboard operation
BrowserInterop copied to clipboard

alerts by chrome

Open drma-tech opened this issue 4 years ago • 5 comments
trafficstars

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.

drma-tech avatar Jan 04 '21 15:01 drma-tech

Do you use the position watcher? https://stackoverflow.com/a/47598837/277067 https://remibou.github.io/Track-GPS-with-Blazor-BrowserInterop/

RemiBou avatar Jan 11 '21 13:01 RemiBou

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;
}

drma-tech avatar Jan 11 '21 13:01 drma-tech

From what I've read Chrome prefers when you get it from the watcher, you can have a look at my blog post

RemiBou avatar Jan 11 '21 14:01 RemiBou

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-tech avatar Jan 13 '21 16:01 drma-tech

@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.

RemiBou avatar Jan 14 '21 09:01 RemiBou