PWA Fundvelo der Caritas.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

PermissionsProvider.cs 1.1KB

1234567891011121314151617181920212223242526272829303132333435
  1. using Microsoft.JSInterop;
  2. using System.Threading.Tasks;
  3. namespace cwebplusApp.Shared.Services {
  4. public class PermissionsProvider {
  5. public IJSRuntime JSRuntime { get; set; }
  6. public bool IsGeoLocationAllowed { get; set; }
  7. public PermissionsProvider(IJSRuntime _jSRuntime) {
  8. this.JSRuntime = _jSRuntime;
  9. initialize();
  10. }
  11. [JSInvokable]
  12. public void GeoLocationPermissionChanged(string geoLocationStatus) {
  13. IsGeoLocationAllowed = (geoLocationStatus.Equals("granted") || geoLocationStatus.Equals("prompt")) ? true : false;
  14. }
  15. private async void initialize() {
  16. await GeoLocationAllowed();
  17. }
  18. private async Task<bool> GeoLocationAllowed() {
  19. string result = "";
  20. var dotNetObjRef = DotNetObjectReference.Create(this);
  21. result = await JSRuntime.InvokeAsync<string>("IsGeoLocationAllowed", dotNetObjRef);
  22. this.IsGeoLocationAllowed = result.Equals("granted") || result.Equals("prompt");
  23. return IsGeoLocationAllowed;
  24. }
  25. }
  26. }