Beispiel #1
0
        static Task DoShare(ShareMessage message, string androidChooserTitle, DeviceSharingOption[] _)
        {
            var items = new List <string>();

            if (message.Text.HasValue())
            {
                items.Add(message.Text);
            }

            if (message.Url.HasValue())
            {
                items.Add(message.Url);
            }

            var intent = new Intent(Intent.ActionSend).SetType("text/plain");

            intent.PutExtra(Intent.ExtraText, string.Join(Environment.NewLine, items));
            if (message.Title.HasValue())
            {
                intent.PutExtra(Intent.ExtraSubject, message.Title);
            }

            var chooserIntent = Intent.CreateChooser(intent, androidChooserTitle);

            chooserIntent.SetFlags(ActivityFlags.ClearTop).SetFlags(ActivityFlags.NewTask);
            Application.Context.StartActivity(chooserIntent);

            return(Task.CompletedTask);
        }
 /// <summary>
 /// Share movie with a friend
 /// </summary>
 public async Task InveteFriend()
 {
     var a = new ShareMessage {
         Title = "Upcoming Movie", Text = $"Let's watch the release of {UpcomingMovie.Name} ? {Overview}", Url = UpcomingMovie.PosterImage
     };
     await CrossShare.Current.Share(a, null);
 }
Beispiel #3
0
        /// <summary>
        /// Share a message with compatible services
        /// </summary>
        /// <param name="message">Message to share</param>
        /// <param name="options">Platform specific options</param>
        /// <returns>True if the operation was successful, false otherwise</returns>
        public Task <bool> Share(ShareMessage message, ShareOptions options = null)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            try
            {
                title = message.Title;
                text  = message.Text;
                url   = message.Url;
                if (dataTransferManager == null)
                {
                    dataTransferManager = DataTransferManager.GetForCurrentView();
                    dataTransferManager.DataRequested += new TypedEventHandler <DataTransferManager, DataRequestedEventArgs>(this.ShareTextHandler);
                }
                DataTransferManager.ShowShareUI();

                return(Task.FromResult(true));
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Unable to share: " + ex.Message);
                return(Task.FromResult(false));
            }
        }
Beispiel #4
0
        public async Task <HttpResponseMessage> SendShareMessage(ShareMessage appMessage)
        {
            ResponseBase <IList <micromsg.SendAppMsgResponse> > response = new ResponseBase <IList <micromsg.SendAppMsgResponse> >();

            try
            {
                IList <micromsg.SendAppMsgResponse> list = new List <micromsg.SendAppMsgResponse>();
                string dataUrl          = string.IsNullOrEmpty(appMessage.DataUrl) ? appMessage.Url : appMessage.DataUrl;
                string appMessageFormat = $"<appmsg  sdkver=\"0\"><title>{appMessage.Title}</title><des>{appMessage.Desc}</des><type>{appMessage.Type}</type><showtype>0</showtype><soundtype>0</soundtype><contentattr>0</contentattr><url>{appMessage.Url}</url><lowurl>{appMessage.Url}</lowurl><dataurl>{dataUrl}</dataurl><lowdataurl>{dataUrl}</lowdataurl> <thumburl>{appMessage.ThumbUrl}</thumburl></appmsg>";
                foreach (var item in appMessage.ToWxIds)
                {
                    var result = wechat.SendAppMsg(appMessageFormat, item, appMessage.WxId);
                    list.Add(result);
                }
                response.Data = list;
            }
            catch (ExpiredException ex)
            {
                response.Success = false;
                response.Code    = "401";
                response.Message = ex.Message;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Code    = "500";
                response.Message = ex.Message;
            }
            return(await response.ToHttpResponseAsync());
        }
Beispiel #5
0
        static async Task DoShare(ShareMessage message, string _, DeviceSharingOption[] excludedTypes)
        {
            var items = new List <NSObject>();

            if (message.Text.HasValue())
            {
                items.Add(new ShareItemSource(message.Text.ToNs(), message.Title));
            }
            if (message.Url.HasValue())
            {
                items.Add(new ShareItemSource(NSUrl.FromString(message.Url), message.Title));
            }

            var controller = new UIActivityViewController(items.ToArray(), null);

            if (excludedTypes != null)
            {
                controller.ExcludedActivityTypes = excludedTypes.Select(GetUIActivityType).Trim()
                                                   .Select(x => x.ToNs()).ToArray();
            }

            var vc = GetVisibleViewController();

            if (Device.OS.IsAtLeastiOS(8))
            {
                if (controller.PopoverPresentationController != null)
                {
                    controller.PopoverPresentationController.SourceView = vc.View;
                }
            }

            await vc.PresentViewControllerAsync(controller, animated : true);
        }
Beispiel #6
0
        private async void buttonMenu_Clicked(object sender, EventArgs e)
        {
            try
            {
                var acao = await DisplayActionSheet("Lista Rápida", "Cancelar", null, "Compartilhar App", "Sobre");

                switch (acao)
                {
                case "Compartilhar App":

                    var message = new ShareMessage
                    {
                        Url   = "https://goo.gl/UGkzBL",
                        Title = "Lista Rápida",
                        Text  = "Lista de compras, Material Escolar, Estoque Atual tudo em um só lugar."
                    };

                    await CrossShare.Current.Share(message);

                    break;

                case "Sobre":

                    await Navigation.PushModalAsync(new PageSobre(), false);

                    break;
                }
            }
            catch (Exception erro)
            {
                throw erro;
            }
        }
Beispiel #7
0
        public Task <bool> ShareApp()
        {
            var message      = Constants.GooglePlayAppLink;
            var shareMessage = new ShareMessage {
                Text = message
            };

            return(CrossShare.Current.Share(shareMessage, new ShareOptions()));
        }
Beispiel #8
0
        private async void onShare(object sender, EventArgs args)
        {
            ShareMessage message = new ShareMessage();

            message.Title = dataAnnuoncModel.HeadLines;
            message.Text  = dataAnnuoncModel.HeadLinesDesc;
            message.Url   = "";
            await CrossShare.Current.Share(message);
        }
Beispiel #9
0
        public Task <bool> Share(string text, string title = null, params NSString[] excludedActivityTypes)
        {
            var shareMessage = new ShareMessage();

            shareMessage.Title = title;
            shareMessage.Text  = text;

            return(Share(shareMessage, null, excludedActivityTypes));
        }
Beispiel #10
0
        private void ShareButton_Clicked(object sender, EventArgs e)
        {
            ShareMessage msg = new ShareMessage();

            msg.Title = this.item.Title;
            msg.Url   = this.item.Link;

            CrossShare.Current.Share(msg);
        }
        public async void ExecuteShare()
        {
            ShareMessage msg = new ShareMessage();

            msg.Title = "Share";
            msg.Text  = "Check out this dotnet template";
            msg.Url   = $"http://dotnetnew.azurewebsites.net/pack/{PackageString}";
            await CrossShare.Current.Share(msg);
        }
Beispiel #12
0
        async void OnItemTapped(object sender, ItemTappedEventArgs e)
        {
            var selectedItem = e.Item as ListViewTemplate;

            ((ListView)sender).SelectedItem = null;

            switch (selectedItem.Id)
            {
            case 1:
                var smsSender = CrossMessaging.Current.SmsMessenger;
                if (smsSender.CanSendSmsInBackground)
                {
                    smsSender.SendSmsInBackground(recipient: "0033624033685", message: "Coucou from Xamarin App");
                }
                else
                {
                    await DisplayAlert("Error", "This app cannot send SMS from this device. Try on a real one.", "OK");
                }
                break;

            case 2:
                /*var emailTask = MessagingPlugin.EmailMessenger;
                 * if (emailTask.CanSendEmail)
                 * {
                 *  // Send simple e-mail to single receiver without attachments, CC, or BCC.
                 *  //emailTask.SendEmail("*****@*****.**", "Xamarin Messaging Plugin", "Hello from your XamAPp!");
                 *
                 *  // Send a more complex email with the EmailMessageBuilder fluent interface.
                 *  var email = new EmailMessageBuilder()
                 *    .To("*****@*****.**")
                 *    .Cc("*****@*****.**")
                 *    .Bcc(new[] { "*****@*****.**" })
                 *    .Subject("Xamarin Messaging Plugin")
                 *    .Body("Hello from your XamApp!")
                 *    .Build();
                 *
                 *  emailTask.SendEmail(email);
                 * }*/
                break;

            case 3:
                ShareMessage message = new ShareMessage();
                message.Text  = "Coucou from Xam App";
                message.Title = "Sharing";
                await CrossShare.Current.Share(message);

                break;

            case 4:
                await CrossShare.Current.OpenBrowser("http://munabees.com");

                break;

            default:
                break;
            }
        }
        public Task <bool> ShareApp()
        {
            var message      = "App is shared!";
            var shareMessage = new ShareMessage {
                Text = message
            };

            return(CrossShare.Current.Share(shareMessage, new ShareOptions()));
        }
Beispiel #14
0
        public Task <bool> Share(string text, string title = null)
        {
            var shareMessage = new ShareMessage();

            shareMessage.Title = title;
            shareMessage.Text  = text;

            return(Share(shareMessage));
        }
Beispiel #15
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            var sharePlugin = CrossShare.Current;
            var message     = new ShareMessage()
            {
                Text = "Share Plugin!", Title = "Testing"
            };

            sharePlugin.Share(message);
        }
 private async void ShareApp(object obj)
 {
     ShareMessage newmsg = new ShareMessage()
     {
         Text  = "Hey GoT fan, Checkout this awesome GoT trumpCards App I've been playing ",
         Title = "Download Game of Cards",
         Url   = "https://play.google.com/store/apps/details?id=com.yekarlo.gameofcards"
     };
     await CrossShare.Current.Share(newmsg);
 }
Beispiel #17
0
        public Task <bool> ShareLink(string url, string message = null, string title = null, params NSString[] excludedActivityTypes)
        {
            var shareMessage = new ShareMessage();

            shareMessage.Title = title;
            shareMessage.Text  = message;
            shareMessage.Url   = url;

            return(Share(shareMessage, null, excludedActivityTypes));
        }
Beispiel #18
0
        public Task <bool> ShareLink(string url, string message = null, string title = null)
        {
            var shareMessage = new ShareMessage();

            shareMessage.Title = title;
            shareMessage.Text  = message;
            shareMessage.Url   = url;

            return(Share(shareMessage));
        }
Beispiel #19
0
        static Task DoShare(ShareMessage message, string _, DeviceSharingOption[] __)
        {
            if (DataTransferManager == null)
            {
                DataTransferManager = DataTransferManager.GetForCurrentView();
                DataTransferManager.DataRequested += new TypedEventHandler <DataTransferManager, DataRequestedEventArgs>((sender, eventArgse) => ShareTextHandler(sender, eventArgse, message));
            }

            DataTransferManager.ShowShareUI();
            return(Task.CompletedTask);
        }
Beispiel #20
0
        public void Share(string shareMessage, string title = null, string url = null)
        {
            ShareMessage message = new ShareMessage {
                Text = shareMessage, Title = title, Url = url
            };
            ShareOptions options = new ShareOptions {
                ChooserTitle = "share the care"
            };

            CrossShare.Current.Share(message, options);
        }
Beispiel #21
0
        //Compartilha o site e informações do fornecedor
        private void CompartilharFornecedor()
        {
            var          site           = _fornecedor.Site;
            var          nomeFornecedor = $"{_fornecedor.NomeFantasia } compartilhado pelo app Guia OndeVamos Mairiporã.";
            var          titulo         = "Guia OndeVamos Mairiporã";
            ShareMessage mensagem       = new ShareMessage();

            mensagem.Url   = site;
            mensagem.Title = titulo;
            mensagem.Text  = nomeFornecedor;
            Compartilhar(mensagem);
        }
        public Task <bool> Share(string text, string title = null)
        {
            var shareMessage = new ShareMessage();

            shareMessage.Title = title;
            shareMessage.Text  = text;

            var shareOptions = new ShareOptions();

            shareOptions.ChooserTitle = title;

            return(Share(shareMessage, shareOptions));
        }
        public Task <bool> Share(string message)
        {
            var shareMessage = new ShareMessage();
            var shareOptions = new ShareOptions();

            message +=
                $"{Environment.NewLine}-------------------{Environment.NewLine}Shared by ProductsScanner";

            shareMessage.Text  = message;
            shareMessage.Title = "ProductsScanner";

            return(CrossShare.Current.Share(shareMessage, shareOptions));
        }
        public Task <bool> ShareLink(string url, string message = null, string title = null)
        {
            var shareMessage = new ShareMessage();

            shareMessage.Title = title;
            shareMessage.Text  = message;
            shareMessage.Url   = url;

            var shareOptions = new ShareOptions();

            shareOptions.ChooserTitle = title;

            return(Share(shareMessage, shareOptions));
        }
Beispiel #25
0
        private async void ShareAsync(object romObject)
        {
            if (romObject != null)
            {
                var note        = romObject as NoteViewModel;
                var shareObject = new ShareMessage()
                {
                    Title = note.ListViewModel.SelectedNote.Title,
                    Text  = note.ListViewModel.SelectedNote.Description,
                };

                // Share message and an optional title.
                await CrossShare.Current.Share(shareObject);
            }
        }
Beispiel #26
0
        public void ShareMessage(string txtMessage, string link = "", string title = "", string chooserTitle = "Share using")
        {
            ShareMessage message = new ShareMessage()
            {
                Text = txtMessage, Url = link
            };
            ShareOptions options = new ShareOptions()
            {
                ChooserTitle = chooserTitle
            };

            if (CrossShare.IsSupported)
            {
                CrossShare.Current.Share(message, options);
            }
        }
 async Task ShareCocktail()
 {
     try
     {
         var message = new ShareMessage()
         {
             Title = "Pocket Bar",
             Text  = $"Check this awesome drink at Pocket Bar: {Cocktail.DrinkName} \n Instructions: {Cocktail.Instructions} \n For more information Go to Pocket Bar App"
         };
         await CrossShare.Current.Share(message);
     }
     catch (Exception e)
     {
         await ShowMessage(Constants.ErrorMessages.ErrorOccured, e.Message, Constants.ErrorMessages.Ok);
     }
 }
        public void Share(string shareMessage, string title = null, string url = null)
        {
            if (!CrossShare.IsSupported)
            {
                return;
            }

            ShareMessage message = new ShareMessage {
                Text = shareMessage, Title = title, Url = url
            };
            ShareOptions options = new ShareOptions {
                ChooserTitle = "share the awesomeness!"
            };

            CrossShare.Current.Share(message, options);
        }
        /// <summary>
        /// Método para compartilhar as piadas
        /// </summary>
        private async void ShareJoke(object sender, ItemTappedEventArgs e)
        {
            //Atribui o item selecionado ao objeto "Joke"
            Joke joke = (Joke)e.Item;

            //Variável para guardar a opção selecionada
            string opcao = "";

            try
            {
                //Exibe um ActionSheet para o usuário escolher a ação a ser realizada
                var action = await DisplayActionSheet("Compartilhe a piada - " + joke.title, "Cancelar", null, "Compartilhar", "Copiar o texto");

                opcao = action.ToString();
                //Faz um switch entre as opções
                switch (opcao)
                {
                //Se o usuário clicou em "compartilhar"
                case "Compartilhar":
                    //Instancia o objeto ShareMessage que será responsável por
                    //abstrair os métodos de compartilhamento do dispositivo
                    ShareMessage msg = new ShareMessage();
                    //Atribui o titulo
                    msg.Title = joke.title;
                    //Atribui o texto
                    msg.Text = joke.title + Environment.NewLine + joke.body;

                    //Variavel de opções de compartilhamento
                    var opt = new ShareOptions();

                    //Exibe a janela de compartilhamento do Sistema
                    await CrossShare.Current.Share(msg, opt);

                    break;

                case "Copiar o texto":
                    //Copia o texto da piada para a área de transferência
                    await CrossShare.Current.SetClipboardText(joke.title + Environment.NewLine + joke.body);

                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #30
0
        static void Main(string[] args)
        {
            try
            {
                ShareMessage objShareMsg = new ShareMessage();
                Thread thread = new Thread(objShareMsg.shareMessage);
                thread.Start();

                #region For Testing
                //objShareMsg.shareMessage(); 
                #endregion
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }
        }
Beispiel #31
0
        static void Main(string[] args)
        {
            try
            {
                ShareMessage objShareMsg = new ShareMessage();
                Thread       thread      = new Thread(objShareMsg.shareMessage);
                thread.Start();

                #region For Testing
                //objShareMsg.shareMessage();
                #endregion
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }
        }