public ManagerContext(IServiceProvider services, BleConfiguration config, ILogger <IBleManager> logger) { this.Services = services; this.logger = logger; this.managerLazy = new Lazy <CBCentralManager>(() => { if (!AppleExtensions.HasPlistValue("NSBluetoothPeripheralUsageDescription")) { this.logger.LogCritical("NSBluetoothPeripheralUsageDescription needs to be set - you will likely experience a native crash after this log"); } var background = services.GetService(typeof(IBleDelegate)) != null; if (!background) { return(new CBCentralManager(this, null)); } if (!AppleExtensions.HasPlistValue("NSBluetoothAlwaysUsageDescription", 13)) { this.logger.LogCritical("NSBluetoothAlwaysUsageDescription needs to be set - you will likely experience a native crash after this log"); } var opts = new CBCentralInitOptions { ShowPowerAlert = config.iOSShowPowerAlert, RestoreIdentifier = config.iOSRestoreIdentifier ?? "shinyble" }; return(new CBCentralManager(this, null, opts)); }); }
public override async Task <AccessState> RequestAccess() { if (!AppleExtensions.HasBackgroundMode("fetch")) { return(AccessState.NotSetup); } // this always has to be set at least once await this.platform.SetBackgroundFetchInterval(BackgroundFetchInterval); var grantResult = await this.platform.GetBackgroundRefreshStatus(); return(grantResult); }
public override Task <AccessState> RequestAccess() { var result = AccessState.Available; if (!UIDevice.CurrentDevice.CheckSystemVersion(13, 0)) { result = AccessState.NotSupported; } else if (Runtime.Arch == Arch.SIMULATOR) { result = AccessState.NotSupported; } else if (!AppleExtensions.HasBackgroundMode("processing")) { result = AccessState.NotSetup; } return(Task.FromResult(result)); }