Пример #1
0
        async Task ExecuteRefreshingCommand(bool pullFromCloud = false)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                var service = new ZumoService();

                if (pullFromCloud)
                {
                    IsRefreshing = true;
                    await service.SyncOfflineCache();

                    IsRefreshing = false;
                }

                var results = await service.GetAllToDoItems();

                Items.Clear();
                foreach (var item in results)
                {
                    Items.Add(item);
                }
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #2
0
        private async Task ExecuteSaveCmd()
        {
            try
            {
                if (IsBusy)
                {
                    return;
                }
                IsBusy = true;

                var svc = new ZumoService();
                if (string.IsNullOrEmpty(Item.Id))
                {
                    await svc.CreateToDo(Item);
                }
                else
                {
                    await svc.UpdateToDo(Item);
                }

                MessagingCenter.Send(this, "refresh_list");
            }
            finally
            {
                IsBusy = false;
                await nav.PopAsync();
            }
        }
Пример #3
0
        protected override void OnStart()
        {
            if (!AppCenter.Configured)
            {
                Push.PushNotificationReceived += async(sender, e) =>
                {
                    var zumoService = new ZumoService();
                    await zumoService.SyncOfflineCache();

                    // Add the notification message and title to the message
                    //var summary = $"Push notification received:" +
                    //                    $"\n\tNotification title: {e.Title}" +
                    //                    $"\n\tMessage: {e.Message}";

                    //// If there is custom data associated with the notification,
                    //// print the entries
                    //if (e.CustomData != null)
                    //{
                    //    summary += "\n\tCustom data:\n";
                    //    foreach (var key in e.CustomData.Keys)
                    //    {
                    //        summary += $"\t\t{key} : {e.CustomData[key]}\n";

                    //        Analytics.TrackEvent("Push", new Dictionary<string, string> { { "push-key", $"{key}" } });
                    //    }
                    //}

                    //// Send the notification summary to debug output
                    //System.Diagnostics.Debug.WriteLine(summary);
                };
            }


            AppCenter.Start("ios=dcfb280a-b080-474b-8c3b-38baa5739d0f;"
                            + "android=0418d688-810c-47f6-b532-7dbab8cdab5c",
                            typeof(Analytics),
                            typeof(Crashes),
                            typeof(Push));

            Push.SetEnabledAsync(true);

            OnResume();
        }
Пример #4
0
        public ToDoListPageViewModel(INavigation nav)
        {
            Title = "To Do Items";

            navigation = nav;

            InitialRefreshList();

            var service = new ZumoService();

            Task.Run(async() =>
            {
                await service.RegisterForPushNotifications();
            });

            MessagingCenter.Subscribe <PushToSync>(this, "ItemsChanged", async(obj) =>
            {
                await ExecuteRefreshingCommand(true);
            });
        }