public override StartCommandResult OnStartCommand(Intent intent, [GeneratedEnum] StartCommandFlags flags, int startId)
        {
            try
            {
                Log.Info("DroidPlatform", "HOPEPH OnStartCommand running (PostFeed Service).");
                Contract.ContactK currentUser = ExtendedDataHolder.Instance.HasExtra("CurrentUser") ?
                                                JsonConvert.DeserializeObject <Contract.ContactK>(ExtendedDataHolder.Instance.GetExtra("CurrentUser").ToString()) : null;
                Contract.PostFeedK currentPost = ExtendedDataHolder.Instance.HasExtra("CurrentPost") ?
                                                 JsonConvert.DeserializeObject <Contract.PostFeedK>(ExtendedDataHolder.Instance.GetExtra("CurrentPost").ToString()) : null;

                string operation = "";

                if (ExtendedDataHolder.Instance.HasExtra("Operation"))
                {
                    operation = ExtendedDataHolder.Instance.GetExtra("Operation").ToString();
                }
                else
                {
                    throw new ArgumentNullException("Operation in PostFeedService android is null.");
                }

                Task.Run(async() =>
                {
                    switch (operation.ToLower())
                    {
                    case "deletepostfeed":
                        await PostFeedSpokeStatic.DeleteSelfPostToRemote(currentPost.PostFeedID);
                        break;

                    case "likeorunlikepost":
                        await PostFeedSpokeStatic.LikeOrUnlikePost(true, currentPost.PostFeedID, currentUser.Id);
                        break;

                    case "addupdatepost":
                        await PostFeedSpokeStatic.AddOrUpdatePostFeed(currentPost);
                        break;

                    case "logontohub":
                    default:
                        await PostFeedSpokeStatic.LogonToHub(currentUser.UserName, currentUser.Password);
                        break;
                    }
                });
            }
            catch (System.OperationCanceledException ex)
            {
                ProcessErrorReportingForHockeyApp(ex);
            }
            catch (System.Exception ex)
            {
                ProcessErrorReportingForHockeyApp(ex);
            }

            return(StartCommandResult.Sticky);
        }
        public async Task Start(Contract.PostFeedK currentPost, Contract.ContactK currentUser, string operation)
        {
            Console.WriteLine("HOPEPH Creating task id for background ios");
            _cts = new CancellationTokenSource();

            try
            {
                switch (operation.ToLower())
                {
                case "deletepostfeed":
                    Console.WriteLine("HOPEPH Deleting Post Feed");
                    _taskId = UIApplication.SharedApplication.BeginBackgroundTask("DeletingPostFeed", OnExpiration);
                    await PostFeedSpokeStatic.DeleteSelfPostToRemote(currentPost.PostFeedID);

                    UIApplication.SharedApplication.EndBackgroundTask(_taskId);
                    break;

                case "likeorunlikepost":
                    Console.WriteLine("HOPEPH Liking or Unliking Post Feed");
                    _taskId = UIApplication.SharedApplication.BeginBackgroundTask("LikingOrUnlikingPost", OnExpiration);
                    await PostFeedSpokeStatic.LikeOrUnlikePost(true, currentPost.PostFeedID, currentUser.Id);

                    UIApplication.SharedApplication.EndBackgroundTask(_taskId);
                    break;

                case "addupdatepost":
                    Console.WriteLine("HOPEPH Adding or Updating Post Feed");
                    _taskId = UIApplication.SharedApplication.BeginBackgroundTask("AddingUpdatingPostFeed", OnExpiration);
                    await PostFeedSpokeStatic.AddOrUpdatePostFeed(currentPost);

                    UIApplication.SharedApplication.EndBackgroundTask(_taskId);
                    break;

                case "logontohub":
                default:
                    _taskId = UIApplication.SharedApplication.BeginBackgroundTask("LogonToHub", OnExpiration);
                    await PostFeedSpokeStatic.LogonToHub(currentUser.UserName, currentUser.Password);

                    UIApplication.SharedApplication.EndBackgroundTask(_taskId);
                    break;
                }
            }
            catch (OperationCanceledException oex)
            {
                Console.WriteLine(string.Format("HOPEPH An error occured in backgrounding IOS {0}.", oex.Message));
            }
            finally
            {
                if (_cts.IsCancellationRequested)
                {
                    Console.WriteLine("HOPEPH Cancelled token.");
                }
            }
        }