void OnStartStopClicked(object sender, EventArgs e) { IBeaconService beaconService = DependencyService.Get <IBeaconService>(); if (!IsStartedRanging) { _sendTaskCancellationTokenSource = new CancellationTokenSource(); Device.StartTimer(TimeSpan.FromSeconds(60), () => { if (_sendTaskCancellationTokenSource != null && _sendTaskCancellationTokenSource.IsCancellationRequested) { return(false); } Task.Factory.StartNew(async() => await TimerCallback()); return(true); }); beaconService.Start(); this.startStopButton.Text = "Detener"; } else { _sendTaskCancellationTokenSource.Cancel(); beaconService.Stop(); receivedBeacons.Clear(); this.startStopButton.Text = "Iniciar"; } IsStartedRanging = !IsStartedRanging; }
private async void BackgroundService() { await Task.Run(() => { try { while (true) { InvokeOnMainThread(delegate { _beaconService = DependencyService.Resolve <IBeaconService>(); _userDataService = DependencyService.Resolve <UserDataService>(); if (_userDataService.IsExistUserData) { _beaconService.StartAdvertisingBeacons(_userDataService.Get()); } }); System.Threading.Thread.Sleep(60000); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message + System.Environment.NewLine + ex.StackTrace); } }).ConfigureAwait(false); }
public NotificationController(INotificationMessageService notificationMessageService, IUnitOfWork unitOfWorkAsync, ISettingsService settingsService, IBeaconService beaconService) { _notificationMessageService = notificationMessageService; _settingsService = settingsService; _beaconService = beaconService; _unitOfWorkAsync = unitOfWorkAsync; }
public BeaconPageViewModel(INavigationService navigationService, IBeaconService beaconService) : base(navigationService) { _navigationService = navigationService; _beaconService = beaconService; Title = "Beacon Page"; AppUtils.CheckPermission(); _beaconService.InitializeService(); _beaconService.StartBeacon(); UserData userData = new UserData(); userData.Uuid = AppConstants.AppUUID; userData.Major = "23"; userData.Minor = "45"; _beaconService.StartAdvertising(userData); /* * try * { * beaconService =DependencyService.Get<IBeaconService>(); * } * catch (Exception e) * { * Console.WriteLine(e); * } */ //beaconService.StartBeacon(); //beaconService.StopAdvertising(); var beaconList = _beaconService.GetBeaconData(); //var list = beaconService.GetBeaconData(); var dummyCell = new BeaconViewCell(); dummyCell.UUID.Value = "AAAAAAAAAA"; //beaconList.Add(dummyCell); //beaconList.Add(dummyCell); // Create User // TODO Check Register User (UUID.Major.Minor) or New // POST New User and Store local properities /* * if (!Application.Current.Properties.ContainsKey("UserData")) * { * // Access REST API and new id case * UserData userData = new UserData(); * userData.Uuid = AppConstants.AppUUID; * userData.Major = "23"; * userData.Minor = "45"; * Application.Current.Properties["UserData"] = userData; * } */ }
public HomePageViewModel(INavigationService navigationService) : base(navigationService) { Title = AppResources.HomePageTitle; _beaconService = Xamarin.Forms.DependencyService.Resolve <IBeaconService>(); // Only Call InitializeService! Start automagically! _beaconService.InitializeService(); SetData(); }
protected override void OnResume() { UserDataService userDataService = Xamarin.Forms.DependencyService.Resolve <UserDataService>(); if (userDataService.IsExistUserData) { _beaconService = Xamarin.Forms.DependencyService.Resolve <IBeaconService>(); _beaconService.OnResume(); } base.OnResume(); }
protected override void OnStart() { ImageService.Instance.Config.Logger = Container.Resolve <IMiniLogger>(); UserDataService userDataService = Xamarin.Forms.DependencyService.Resolve <UserDataService>(); if (userDataService.IsExistUserData) { UserDataModel _userData = userDataService.Get(); _beaconService = Xamarin.Forms.DependencyService.Resolve <IBeaconService>(); _beaconService.StartRagingBeacons(_userData); _beaconService.StartAdvertisingBeacons(_userData); } }
protected override async void OnInitialized() { InitializeComponent(); LogUnobservedTaskExceptions(); Distribute.ReleaseAvailable = OnReleaseAvailable; Push.PushNotificationReceived += OnPushNotificationReceived; AppCenter.Start($"android={AppConstants.AppCenterTokensAndroid};ios={AppConstants.AppCenterTokensIOS};", typeof(Analytics), typeof(Crashes), typeof(Distribute), typeof(Push)); Container.Resolve <ILogger>().Log("Started App Center"); INavigationResult result; // Check user data and skip tutorial UserDataService userDataService = Xamarin.Forms.DependencyService.Resolve <UserDataService>(); if (userDataService.IsExistUserData) { UserDataModel _userData = userDataService.Get(); _beaconService = Xamarin.Forms.DependencyService.Resolve <IBeaconService>(); // Only Call InitializeService! Start automagically! AppUtils.CheckPermission(); _beaconService.InitializeService(); result = await NavigationService.NavigateAsync("NavigationPage/HomePage"); } else { result = await NavigationService.NavigateAsync("NavigationPage/StartTutorialPage"); } if (!result.Success) { MainPage = new ExceptionPage { BindingContext = new ExceptionPageViewModel() { Message = result.Exception.Message } }; System.Diagnostics.Debugger.Break(); } }
protected override async void OnInitialized() { InitializeComponent(); INavigationResult result; // Check user data and skip tutorial UserDataService userDataService = Xamarin.Forms.DependencyService.Resolve <UserDataService>(); //UserDataModel userData =await userDataService.Register(); if (userDataService.IsExistUserData()) { _userData = userDataService.Get(); _beaconService = Xamarin.Forms.DependencyService.Resolve <IBeaconService>(); // Only Call InitializeService! Start automagically! AppUtils.CheckPermission(); _beaconService.InitializeService(); result = await NavigationService.NavigateAsync("NavigationPage/HomePage"); } else { result = await NavigationService.NavigateAsync("NavigationPage/StartTutorialPage"); } if (!result.Success) { MainPage = new ExceptionPage { BindingContext = new ExceptionPageViewModel() { Message = result.Exception.Message } }; System.Diagnostics.Debugger.Break(); } }
public BeaconController(IBeaconService beaconService) { _beaconService = beaconService; }
public BeaconsController(IBeaconService beaconService) { this.beaconService = beaconService ?? throw new ArgumentNullException(nameof(beaconService)); }