| 1234567891011121314151617181920212223242526272829303132333435 |
- using Microsoft.JSInterop;
- using System.Threading.Tasks;
-
- namespace cwebplusApp.Shared.Services {
-
- public class PermissionsProvider {
-
- public IJSRuntime JSRuntime { get; set; }
-
- public bool IsGeoLocationAllowed { get; set; }
-
- public PermissionsProvider(IJSRuntime _jSRuntime) {
- this.JSRuntime = _jSRuntime;
- initialize();
- }
-
- [JSInvokable]
- public void GeoLocationPermissionChanged(string geoLocationStatus) {
- IsGeoLocationAllowed = (geoLocationStatus.Equals("granted") || geoLocationStatus.Equals("prompt")) ? true : false;
- }
-
- private async void initialize() {
- await GeoLocationAllowed();
- }
-
- private async Task<bool> GeoLocationAllowed() {
- string result = "";
- var dotNetObjRef = DotNetObjectReference.Create(this);
- result = await JSRuntime.InvokeAsync<string>("IsGeoLocationAllowed", dotNetObjRef);
- this.IsGeoLocationAllowed = result.Equals("granted") || result.Equals("prompt");
- return IsGeoLocationAllowed;
- }
-
- }
- }
|