Ejemplo n.º 1
0
        public AccessViewModel(IJobManager jobs,
                               INotificationManager notifications = null,
                               ISpeechRecognizer speech = null,
                               IGeofenceManager geofences = null,
                               IGpsManager gps = null,
                               ICentralManager bluetooth = null,
                               IBeaconManager beacons = null)
        {
            this.Append("Jobs", AccessState.Unknown, () => jobs.RequestAccess());

            if (notifications != null)
                this.Append("Notifications", AccessState.Unknown, () => notifications.RequestAccess());

            if (speech != null)
                this.Append("Speech", AccessState.Unknown, () => speech.RequestAccess().ToTask(CancellationToken.None));

            if (gps != null)
                this.Append("GPS", gps.Status, () => gps.RequestAccess(true));

            if (geofences != null)
                this.Append("Geofences", geofences.Status, () => geofences.RequestAccess());

            if (bluetooth != null)
                this.Append("BluetoothLE Central", bluetooth.Status, () => bluetooth.RequestAccess().ToTask(CancellationToken.None));

            if (beacons != null)
                this.Append("iBeacons", beacons.Status, () => beacons.RequestAccess(true));
        }
Ejemplo n.º 2
0
        public AccessViewModel(IJobManager jobs,
                               INotificationManager notifications = null,
                               ISpeechRecognizer speech           = null,
                               IGeofenceManager geofences         = null,
                               IGpsManager gps           = null,
                               ICentralManager bluetooth = null,
                               IBeaconManager beacons    = null,
                               IPushManager push         = null,
                               INfcManager nfc           = null)
        {
            this.Append("Jobs", AccessState.Unknown, () => jobs.RequestAccess());

            if (notifications != null)
            {
                this.Append("Notifications", AccessState.Unknown, () => notifications.RequestAccess());
            }

            if (speech != null)
            {
                this.Append("Speech", AccessState.Unknown, () => speech.RequestAccess());
            }

            if (gps != null)
            {
                this.Append("GPS (Background)", gps.GetCurrentStatus(true), () => gps.RequestAccess(true));
            }

            if (geofences != null)
            {
                this.Append("Geofences", geofences.Status, () => geofences.RequestAccess());
            }

            if (bluetooth != null)
            {
                this.Append("BluetoothLE Central", bluetooth.Status, () => bluetooth.RequestAccess().ToTask(CancellationToken.None));
            }

            if (beacons != null)
            {
                this.Append("iBeacons (Monitoring)", beacons.GetCurrentStatus(true), () => beacons.RequestAccess(true));
            }

            if (push != null)
            {
                this.Append("Push", AccessState.Unknown, async() =>
                {
                    var status = await push.RequestAccess();
                    return(status.Status);
                });
            }

            if (nfc != null)
            {
                this.Append("NFC", AccessState.Unknown, () => nfc.RequestAccess().ToTask(CancellationToken.None));
            }
        }
Ejemplo n.º 3
0
        public async Task CheckPermissions()
        {
            var status = await _centralManager.RequestAccess();

            if (status == AccessState.Denied)
            {
                await App.Current.MainPage.DisplayAlert("Permissions", "You need to have your Bluetooth ON to use this feature", "Ok");

                Xamarin.Essentials.AppInfo.ShowSettingsUI();
            }
            else
            {
                SetAdapterCommand.Execute(null);
            }
        }