Esempio n. 1
0
        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;
        }
Esempio n. 2
0
 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;
 }
Esempio n. 4
0
        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;
             * }
             */
        }
Esempio n. 5
0
        public HomePageViewModel(INavigationService navigationService)
            : base(navigationService)
        {
            Title          = AppResources.HomePageTitle;
            _beaconService = Xamarin.Forms.DependencyService.Resolve <IBeaconService>();
            // Only Call InitializeService! Start automagically!
            _beaconService.InitializeService();

            SetData();
        }
Esempio n. 6
0
        protected override void OnResume()
        {
            UserDataService userDataService = Xamarin.Forms.DependencyService.Resolve <UserDataService>();

            if (userDataService.IsExistUserData)
            {
                _beaconService = Xamarin.Forms.DependencyService.Resolve <IBeaconService>();
                _beaconService.OnResume();
            }
            base.OnResume();
        }
Esempio n. 7
0
        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);
            }
        }
Esempio n. 8
0
        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();
            }
        }
Esempio n. 9
0
        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();
            }
        }
Esempio n. 10
0
 public BeaconController(IBeaconService beaconService)
 {
     _beaconService = beaconService;
 }
Esempio n. 11
0
 public BeaconsController(IBeaconService beaconService)
 {
     this.beaconService = beaconService ?? throw new ArgumentNullException(nameof(beaconService));
 }