Ejemplo n.º 1
0
        private void OnDownloadCompleted(bool hasError, string filePath, ActionFileDownload action, object data, bool isSlient)
        {
            var fileSaved = !hasError;

            if (hasError)
            {
                if (!isSlient)
                {
                    UserDialogs.Instance.Alert("Download Error");
                }
            }
            else
            {
                // TODO do open file here
                switch (action)
                {
                case ActionFileDownload.Open:
                    FileService.OpenFile(filePath);
                    break;

                case ActionFileDownload.Download:
                    UserDialogs.Instance.Toast("File is Downloaded");
                    var notification = new Plugin.LocalNotification.NotificationRequest
                    {
                        NotificationId = 101,
                        Title          = "An item has downloaded ",
                        Description    = "Click to view more detail",
                        ReturningData  = filePath
                    };
                    NotificationCenter.Current.Show(notification);
                    break;
                }
            }

            if (OnFileDownloaded != null)
            {
                OnFileDownloaded.Invoke(this, new DownloadEventArgs(fileSaved, filePath, data));
            }
        }
 /// <summary>
 /// Initializes NotificationRequestBuilder with default value.
 /// </summary>
 public NotificationRequestBuilder()
 {
     _request = new NotificationRequest();
 }