Ejemplo n.º 1
0
            // Display notofication after successfull adding to calendar
            public override void Completed(EKEventEditViewController controller, EKEventEditViewAction action)
            {
                eventController.DismissViewController(true, null);

                if (action == EKEventEditViewAction.Saved)
                {
                    AppNotifications.Display(new DisplayedPromptsModel()
                    {
                        Category = "", Task = "Task has been successfully scheduled"
                    });
                }
            }
Ejemplo n.º 2
0
        // Get prompts in background mode
        public async override void PerformFetch(UIApplication application, Action <UIBackgroundFetchResult> completionHandler)
        {
            //Return no new data by default
            var result = UIBackgroundFetchResult.NoData;

            try
            {
                // Check for new data, and display it
                var    userPromptRepository = new UsersPromptsRepository();
                string userId = NSUserDefaults.StandardUserDefaults.StringForKey("userId");

                var newPrompt = userPromptRepository.GenerateNewPrompt(userId);
                // If prompt succesfully generated, display it in collection view and show notification
                if (newPrompt.Any())
                {
                    AppNotifications.Display(newPrompt.First());
                    await userPromptRepository.SyncCurrentUserPrompts(userId);

                    // Inform system of fetch results
                    result = UIBackgroundFetchResult.NewData;
                }
                else
                {
                    //AppNotifications.Display(new DisplayedPromptsModel() { Category = "", Task = "There is no any prompt to display" });
                    completionHandler(UIBackgroundFetchResult.NoData);
                }
            }
            catch
            {
                //Indicate a failed fetch if there was an exception
                result = UIBackgroundFetchResult.Failed;
            }
            finally
            {
                completionHandler(result);
            }
        }