public void SendSms(string recipient, string message)
        {
            if (string.IsNullOrWhiteSpace(recipient))
                throw new ArgumentNullException("recipient");

            if (string.IsNullOrWhiteSpace(message))
                throw new ArgumentNullException("message");

            if (CanSendSms)
            {
                _smsController = new MFMessageComposeViewController();

                _smsController.Recipients = new[] { recipient };
                _smsController.Body = message;

                EventHandler<MFMessageComposeResultEventArgs> handler = null;
                handler = (sender, args) =>
                {
                    _smsController.Finished -= handler;

                    var uiViewController = sender as UIViewController;
                    if (uiViewController == null)
                    {
                        throw new ArgumentException("sender");
                    }

                    uiViewController.DismissViewController(true, () => { });
                };

                _smsController.Finished += handler;

                _smsController.PresentUsingRootViewController();
            }
        }
    public void SendSms(string body, string phoneNumber)
    {
      if (!MFMailComposeViewController.CanSendMail)
        return;

      smsController = new MFMessageComposeViewController();

      smsController.Recipients = new[] { phoneNumber };
      smsController.Body = body;

      EventHandler<MFMessageComposeResultEventArgs> handler = null;
      handler = (sender, args) =>
      {
        smsController.Finished -= handler;

        var uiViewController = sender as UIViewController;
        if (uiViewController == null)
        {
          throw new ArgumentException("sender");
        }

        uiViewController.DismissViewControllerAsync(true);
      };

      smsController.Finished += handler;

      UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewControllerAsync(smsController, true);
    }
Exemple #3
0
        private static Task ShowComposeSmsMessageAsyncImpl(ChatMessage message)
        {
            return(Task.Run(() =>
            {
                try
                {
                    string[] recipients = new string[message.Recipients.Count];
                    message.Recipients.CopyTo(recipients, 0);

                    UIApplication.SharedApplication.BeginInvokeOnMainThread(() =>
                    {
                        MFMessageComposeViewController mcontroller = new MFMessageComposeViewController();
                        mcontroller.Finished += mcontroller_Finished;

                        mcontroller.Recipients = recipients;
                        mcontroller.Body = message.Body;

                        UIViewController currentController = UIApplication.SharedApplication.KeyWindow.RootViewController;
                        while (currentController.PresentedViewController != null)
                        {
                            currentController = currentController.PresentedViewController;
                        }

                        currentController.PresentViewController(mcontroller, true, null);
                    });
                }
                catch (Exception ex)
                {
                    global::System.Diagnostics.Debug.WriteLine(ex);
                    // probably an iPod/iPad
                    throw new PlatformNotSupportedException();
                }
            }));
        }
Exemple #4
0
        public void Send(string body, string phoneNumber)
        {
            if (!MFMailComposeViewController.CanSendMail)
            {
                return;
            }

            MFMessageComposeViewController smsController = new MFMessageComposeViewController();

            smsController.Recipients = new[] { phoneNumber };
            smsController.Body       = body;

            EventHandler <MFMessageComposeResultEventArgs> handler = null;

            handler = (sender, args) =>
            {
                smsController.Finished -= handler;

                var uiViewController = sender as UIViewController;
                if (uiViewController == null)
                {
                    throw new ArgumentException("sender");
                }

                uiViewController.DismissViewControllerAsync(true);
            };

            smsController.Finished += handler;

            UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewControllerAsync(smsController, true);
        }
        public void shareText()
        {
            if (MFMessageComposeViewController.CanSendText)
            {
                MFMessageComposeViewController message =
                    new MFMessageComposeViewController();

                message.Finished += (sender, e) => {
                    message.DismissViewController(true, null);
                };

                message.Body       = "Bust your stress with this new iOS Games!!";
                message.Recipients = new string[] { "", "" };
                View.Window.RootViewController.PresentModalViewController(message, false);

                //this.PresentModalViewController(message, false);
            }



            //			var smsTo = NSUrl.FromString("sms:18015551234");
            //			UIApplication.SharedApplication.OpenUrl(smsTo);
            //			var imessageTo = NSUrl.FromString("sms:[email protected]");
            //			UIApplication.SharedApplication.OpenUrl(imessageTo);
            //
        }
Exemple #6
0
        private void SendInvitationViaSms(UIAlertAction handler)
        {
            CheckPermission(new Action(() =>
            {
                if (MFMessageComposeViewController.CanSendText)
                {
                    UIStoryboard board          = UIStoryboard.FromName("Challenges", null);
                    UIViewController controller = (UIViewController)board.InstantiateViewController("ContactViewController");
                    this.NavigationController.PushViewController(controller, true);

                    var smsController = new MFMessageComposeViewController {
                        Body = $"{_shareTemplateModel.InviteText} {_shareTemplateModel.ActionLink}"
                    };
                    var pickerDelegate = new ContactPickerDelegate();

                    smsController.Finished += (sender, e) =>
                    {
                        NSRunLoop.Main.BeginInvokeOnMainThread(() =>
                        {
                            e.Controller.DismissViewController(true, null);
                        });
                    };

                    (controller as ContactViewController).SelectContacts += ((string[] contactsArr) =>
                    {
                        smsController.Recipients = contactsArr;
                        NSRunLoop.Main.BeginInvokeOnMainThread(() =>
                        {
                            this.PresentViewController(smsController, true, null);
                        });
                    });
                }
            }));
        }
        public virtual bool SendSMS(string message)
        {
            return(CoreUtility.ExecuteFunction("SendSMS", delegate()
            {
                if (MFMessageComposeViewController.CanSendText)
                {
                    this.SMSController = new MFMessageComposeViewController();

                    this.SMSController.Body = message;
                    this.SMSController.Finished += SMSController_Finished;
                    if (this.NavigationController != null)
                    {
                        this.NavigationController.PresentViewController(this.SMSController, true, null);
                    }
                    else
                    {
                        this.PresentViewController(this.SMSController, true, null);
                    }
                    return true;
                }
                else
                {
                    return false;
                }
            }));
        }
        // This function builds email confirmation with attachment
        private void SendEmail(string[] recipients, string messageBody, UIImage attachment)
        {
            try
            {
                var d = new MFMessageComposeViewController();

                var mailController = new MFMailComposeViewController();

                mailController.SetToRecipients(recipients);
                mailController.SetSubject("Email Confirmation By Just Delivered");
                mailController.SetMessageBody(messageBody, false);
                mailController.AddAttachmentData(attachment.AsJPEG(), "image/png", "photo.png");

                mailController.Finished += (object s, MFComposeResultEventArgs args) =>
                {
                    args.Controller.DismissViewController(true, null);
                };

                this.PresentViewController(d, true, null);
            }
            catch (FeatureNotSupportedException ex)
            {
                myPage.DisplayException(ex.Message);
            }
            catch (Exception ex)
            {
                myPage.DisplayException(ex.Message);
            }
        }
Exemple #9
0
        static Task PlatformComposeAsync(SmsMessage message)
        {
            // do this first so we can throw as early as possible
            var controller = Platform.GetCurrentViewController();

            // create the controller
            var messageController = new MFMessageComposeViewController();

            if (!string.IsNullOrWhiteSpace(message?.Body))
            {
                messageController.Body = message.Body;
            }

            messageController.Recipients = message?.Recipients?.ToArray() ?? new string[] { };

            // show the controller
            var tcs = new TaskCompletionSource <bool>();

            messageController.Finished += (sender, e) =>
            {
                messageController.DismissViewController(true, null);
                tcs?.TrySetResult(e.Result == MessageComposeResult.Sent);
            };
            controller.PresentViewController(messageController, true, null);

            return(tcs.Task);
        }
Exemple #10
0
        public void SendSMS(string body, string phoneNumber)
        {
            if (!MFMessageComposeViewController.CanSendText)
            {
                return;
            }

            var sms = new MFMessageComposeViewController
            {
                Body       = body,
                Recipients = new[] { phoneNumber }
            };

            void HandleSmsFinished(object sender, MFMessageComposeResultEventArgs e)
            {
                sms.Finished -= HandleSmsFinished;

                if (sender is UIViewController uiViewController)
                {
                    uiViewController.DismissViewController(true, () => { });
                }
            }

            sms.Finished += HandleSmsFinished;

            UIApplication.SharedApplication.KeyWindow.GetTopModalHostViewController().PresentViewController(sms, true, null);
        }
        public static IAsyncAction ShowComposeSmsMessageAsync(ChatMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

#if __MACCATALYST__ // catalyst https://github.com/xamarin/xamarin-macios/issues/13935
            throw new InvalidOperationException("Not supported on catalyst (https://github.com/xamarin/xamarin-macios/issues/13935)");
#else
            var window     = UIApplication.SharedApplication.KeyWindow;
            var controller = window.RootViewController;

            var messageController = new MFMessageComposeViewController();

            messageController.Body       = message.Body;
            messageController.Recipients = message?.Recipients?.ToArray() ?? new string[] { };

            messageController.Finished += (sender, e) =>
            {
                messageController.DismissViewController(true, null);
            };

            controller.PresentViewController(messageController, true, null);

            return(Task.FromResult(true).AsAsyncAction());
#endif
        }
        public Bullying() : base(UITableViewStyle.Grouped, null)
        {
            Title            = NSBundle.MainBundle.LocalizedString("Bullying", "Bullying");
            TabBarItem.Image = UIImage.FromBundle("bullying");
//			var HelpButton = new UIButton(UIButtonType.RoundedRect);
//			HelpButton.SetTitle("Help Me!", UIControlState.Normal);
            Root = new RootElement("Student Guide")
            {
                new Section("Bullying")
                {
                    new StyledStringElement("Help me!", () => {
                        //AppDelegate.getControl.calling(); //Phones a number all like 'SAVE ME PLS'
                    })
                    {
                        TextColor = UIColor.Red,
                    },
                    new RootElement("Speak Up!")
                    {
                        new Section("Speak up form")
                        {
                            (FullName = new EntryElement("Full Name", "Full Name", "")),
                            (Incident = new EntryElement("Incedent", "Incedent", "", false)),
                            (Location = new EntryElement("Location of Incident", "Location of Incident", "")),
                            (ThoseInvolved = new EntryElement("Persons Involved", "Persons Involved", "")),
                        },
                        new Section()
                        {
                            new StringElement("Submit", delegate {
                                UIAlertView popup = new UIAlertView("Alert", "Do you wish to send an Email, a Text or cancel the form?", null, "Cancel", "Text", "Email");
                                popup.Show();
                                popup.Dismissed += delegate(object sender, UIButtonEventArgs e) {
                                    if (e.ButtonIndex == 1)
                                    {
                                        MFMessageComposeViewController msg = new MFMessageComposeViewController();
                                        msg.Recipients = new string[] { "07624808747" };
                                        msg.Body       = "Hello, I am being bullied by " + ThoseInvolved.Value + " they were " + Incident.Value + " this all happened " + Location.Value + "" + Environment.NewLine + "" + FullName.Value;
                                        this.NavigationController.PresentViewController(msg, true, null);
                                    }
                                    else if (e.ButtonIndex == 2)
                                    {
                                        MFMailComposeViewController email = new MFMailComposeViewController();
                                        email.SetSubject("Help me i'm being bullied");
                                        email.SetToRecipients(new string[] { "*****@*****.**" });
                                        email.SetMessageBody("Hello, I am being bullied by " + ThoseInvolved.Value + " they were " + Incident.Value + " this all happened " + Location.Value + "" + Environment.NewLine + "" + FullName.Value, false);
                                        this.NavigationController.PresentViewController(email, true, null);
                                    }
                                };
                            }),
                        },
                    },
                    new RootElement("Bullying Information")
                    {
                        from x in bullyingInfo
                        select(Section) Generate(x)
                    },
                }
            };
        }
 public void ShareText(string text)
 {
   if (MFMessageComposeViewController.CanSendText)
   {
     var smsController = new MFMessageComposeViewController { Body = text};
     smsController.Finished += (sender, e) => smsController.DismissViewController(true, null);
     UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(smsController, true, null);
   }
 }
 private Element Generate(StudentGuideModel item)
 {
     var root=new RootElement(item.Title);
     var section=new Section(item.Title);
     root.Add (section);
     if (item.Phone!="") {
         var phoneStyle = new StyledStringElement("Contact Number",item.Phone) {
             BackgroundColor=UIColor.FromRGB(71,165,209),
             TextColor=UIColor.White,
             DetailColor=UIColor.White,
         };
         phoneStyle.Tapped+= delegate {
             UIAlertView popup = new UIAlertView("Alert","Do you wish to send a text or diall a number?",null,"Cancel","Text","Call");
             popup.Show();
             popup.Dismissed += delegate(object sender, UIButtonEventArgs e) {
                 if (e.ButtonIndex==1) {
                     MFMessageComposeViewController msg = new MFMessageComposeViewController();
                     msg.Recipients=new string[] {item.Phone};
                     this.NavigationController.PresentViewController(msg,true,null);
                 } else if (e.ButtonIndex==2) {
                     AppDelegate.getControl.calling(item.Phone);
                 };
             };
         };
         section.Add(phoneStyle);
     };
     if (item.Email!="") {
         var style = new StyledStringElement("Contact Email",item.Email) {
             BackgroundColor=UIColor.FromRGB(71,165,209),
             TextColor=UIColor.White,
             DetailColor=UIColor.White,
         };
         style.Tapped += delegate {
             MFMailComposeViewController email = new MFMailComposeViewController();
             email.SetToRecipients(new string[] {item.Email});
             this.NavigationController.PresentViewController(email,true,null);
         };
         section.Add (style);
     }
     if (item.Address!="") {
         section.Add(new StyledMultilineElement(item.Address) {
             BackgroundColor=UIColor.FromRGB(71,165,209),
             TextColor=UIColor.White,
             DetailColor=UIColor.White,
         });
     }
     if (item.Description!="") {
         section.Add (new StyledMultilineElement(item.Description) {
             BackgroundColor=UIColor.FromRGB(71,165,209),
             TextColor=UIColor.White,
             DetailColor=UIColor.White,
             Alignment=UITextAlignment.Center,
         });
     }
     return root;
 }
Exemple #15
0
        public override void Finished(MFMessageComposeViewController controller, MessageComposeResult result)
        {
            Console.WriteLine("Custom, Finished");
            BatchMFMessageComposeViewController c = controller as BatchMFMessageComposeViewController;

            if (c != null && c.LeftRecipients.Count == 0)
            {
                c.Dispose();
            }
        }
        public void SendSMS(string phoneNumber, string text)
        {
            var composerViewController = new MFMessageComposeViewController()
            {
                Recipients = new[] { phoneNumber },
                Body       = text,
            };

            UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(composerViewController, true, null);
        }
        public void SendSMS(string body, string phoneNumber)
        {
            if (!MFMessageComposeViewController.CanSendText)
                return;

            _sms = new MFMessageComposeViewController {Body = body, Recipients = new[] {phoneNumber}};
            _sms.Finished += HandleSmsFinished;

            _modalHost.PresentModalViewController(_sms, true);
        }
Exemple #18
0
 /// <summary>
 /// Composes the SM.
 /// </summary>
 /// <param name="controller">Controller.</param>
 /// <param name="recipients">Recipients.</param>
 /// <param name="message">Message.</param>
 public static void ComposeSMS(UINavigationController controller, string[] recipients, string message)
 {
     MFMessageComposeViewController smsController = new MFMessageComposeViewController();
     smsController.Recipients = recipients;
     smsController.Body = message;
     smsController.Finished += (sender, e) => {
         smsController.DismissViewController(true, null);
     };
     controller.PresentViewController(smsController, true, null);
 }
Exemple #19
0
 public void ShareText(string text)
 {
     if (MFMessageComposeViewController.CanSendText)
     {
         var smsController = new MFMessageComposeViewController {
             Body = text
         };
         smsController.Finished += (sender, e) => smsController.DismissViewController(true, null);
         UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(smsController, true, null);
     }
 }
 /// <summary>
 /// Sends the SMS.
 /// </summary>
 /// <param name="to">To.</param>
 /// <param name="body">The body.</param>
 public void SendSMS(string to, string body)
 {
     if (CanSendSMS)
     {
         var smsController = new MFMessageComposeViewController {
             Body = body, Recipients = new[] { to }
         };
         smsController.Finished += (sender, e) => smsController.DismissViewController(true, null);
         UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(smsController, true, null);
     }
 }
        public void MessageComposeDelegate()
        {
            if (!MFMessageComposeViewController.CanSendText)
            {
                Assert.Inconclusive("Not configured to send text");
            }

            using (var mail = new MFMessageComposeViewController()) {
                Assert.Null(mail.MessageComposeDelegate, "MessageComposeDelegate");
                mail.Finished += (sender, e) => { };
                Assert.NotNull(mail.MessageComposeDelegate, "MessageComposeDelegate");
            }
        }
Exemple #22
0
        public void SendSMS(string to, string body)
        {
            if (this.CanSendSMS)
            {
                var smsController = new MFMessageComposeViewController()
                {
                    Body       = body,
                    Recipients = new[] { to }
                };

                UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(smsController, true, null);
            }
        }
Exemple #23
0
        public bool SendSms(string phoneNumber)
        {
            MFMessageComposeViewController controller = new MFMessageComposeViewController();

            if (MFMessageComposeViewController.CanSendText)
            {
                controller.Body       = @"";
                controller.Recipients = new string[] { phoneNumber };
                RootViewController.PresentViewController(controller, true, null);
                controller.Finished += (sender, e) => RootViewController.DismissViewController(true, null);
                return(true);
            }
            return(false);
        }
Exemple #24
0
        public void SendSMS(string body, string phoneNumber)
        {
            if (!MFMessageComposeViewController.CanSendText)
            {
                return;
            }

            _sms = new MFMessageComposeViewController {
                Body = body, Recipients = new[] { phoneNumber }
            };
            _sms.Finished += HandleSmsFinished;

            UIApplication.SharedApplication.KeyWindow.GetTopModalHostViewController().PresentViewController(_sms, true, null);
        }
Exemple #25
0
        public void SendSMS(string body, string phoneNumber)
        {
            if (!MFMessageComposeViewController.CanSendText)
            {
                return;
            }

            _sms = new MFMessageComposeViewController {
                Body = body, Recipients = new[] { phoneNumber }
            };
            _sms.Finished += HandleSmsFinished;

            _modalHost.PresentModalViewController(_sms, true);
        }
Exemple #26
0
 public void CreateSms(Sms sms)
 {
     if (CanSendSms())
     {
         var smsController = new MFMessageComposeViewController();
         smsController.Body       = sms.Body;
         smsController.Recipients = sms.Recipients.ToArray();
         smsController.Finished  += (s, args) => args.Controller.DismissViewController(true, null);
         var rootViewController = UIApplication.SharedApplication.KeyWindow.RootViewController;
         rootViewController.PresentViewController(smsController, true, null);
     }
     else
     {
         App.CurrentApp.MainPage.DisplayAlert("No SMS App Available", "Unable to send SMS.", "OK");
     }
 }
 public Bullying()
     : base(UITableViewStyle.Grouped, null)
 {
     Title = NSBundle.MainBundle.LocalizedString ("Bullying", "Bullying");
     TabBarItem.Image = UIImage.FromBundle("bullying");
     //			var HelpButton = new UIButton(UIButtonType.RoundedRect);
     //			HelpButton.SetTitle("Help Me!", UIControlState.Normal);
     Root = new RootElement ("Student Guide") {
         new Section("Bullying"){
             new StyledStringElement ("Help me!", () => {
                 //AppDelegate.getControl.calling(); //Phones a number all like 'SAVE ME PLS'
             }){ TextColor=UIColor.Red,},
             new RootElement("Speak Up!") {
                 new Section("Speak up form") {
                     (FullName = new EntryElement("Full Name","Full Name","")),
                     (Incident = new EntryElement("Incedent","Incedent","",false)),
                     (Location = new EntryElement("Location of Incident","Location of Incident","")),
                     (ThoseInvolved = new EntryElement("Persons Involved","Persons Involved","")),
                 },
                 new Section() {
                     new StringElement("Submit", delegate {
                         UIAlertView popup = new UIAlertView("Alert","Do you wish to send an Email, a Text or cancel the form?",null,"Cancel","Text","Email");
                         popup.Show();
                         popup.Dismissed += delegate(object sender, UIButtonEventArgs e) {
                             if (e.ButtonIndex==1) {
                                 MFMessageComposeViewController msg = new MFMessageComposeViewController();
                                 msg.Recipients= new string[] {"07624808747"};
                                 msg.Body="Hello, I am being bullied by " + ThoseInvolved.Value + " they were " + Incident.Value + " this all happened " + Location.Value + "" + Environment.NewLine + "" + FullName.Value;
                                 this.NavigationController.PresentViewController(msg,true,null);
                             } else if (e.ButtonIndex==2) {
                                 MFMailComposeViewController email = new MFMailComposeViewController();
                                 email.SetSubject("Help me i'm being bullied");
                                 email.SetToRecipients(new string[] {"*****@*****.**"});
                                 email.SetMessageBody("Hello, I am being bullied by " + ThoseInvolved.Value + " they were " + Incident.Value + " this all happened " + Location.Value + "" + Environment.NewLine + "" + FullName.Value,false);
                                 this.NavigationController.PresentViewController(email,true,null);
                             }
                         };
                     }),
                 },
             },
             new RootElement("Bullying Information") {
                 from x in bullyingInfo
                     select (Section)Generate (x)
             },
         }
     };
 }
Exemple #28
0
        public virtual Task ComposeSMS(string recipient, string message = null)
        {
            if (!CanComposeSMS)
            {
                throw new FeatureNotAvailableException();
            }

            var mailer = new MFMessageComposeViewController();
            mailer.Recipients = new[] {recipient};
            mailer.Body = message ?? string.Empty;

            mailer.Finished += (s, e) => ((MFMessageComposeViewController) s).DismissViewController(true, () => { });

            UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(mailer, true, null);

            return Task.FromResult(true);
        }
Exemple #29
0
        public virtual Task ComposeSMS(string recipient, string message = null)
        {
            if (!CanComposeSMS)
            {
                throw new FeatureNotAvailableException();
            }

            var mailer = new MFMessageComposeViewController();

            mailer.Recipients = new[] { recipient };
            mailer.Body       = message ?? string.Empty;

            mailer.Finished += (s, e) => ((MFMessageComposeViewController)s).DismissViewController(true, () => { });

            UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(mailer, true, null);

            return(Task.FromResult(true));
        }
 public LatePage()
     : base(UITableViewStyle.Grouped, null)
 {
     TabBarItem.Image = UIImage.FromBundle("clock");
     Title = NSBundle.MainBundle.LocalizedString ("Late/Ill", "Late/Ill");
     Root = new RootElement ("Student Guide") {
         new Section (){
             new StringElement ("I'm Late", () => {
                 if (!AppDelegate.getControl.settings.Contains("lateMessages"))
                 {
                     AppDelegate.getControl.settings.Add ("lateMessages",0);
                 }
                 UIAlertView popup = new UIAlertView("Alert","You have been late a total of " + AppDelegate.getControl.settings["lateMessages"].ToString() + " times. Do you wish to continue?",null,"No","Yes");
                 popup.Show();
                 popup.Dismissed += delegate(object sender, UIButtonEventArgs e) {
                     if (e.ButtonIndex==1) {
                         MFMessageComposeViewController msg = new MFMessageComposeViewController();
                         msg.Recipients=new string[] {"07624810342"};
                         msg.Body="Hello, my name is " + AppDelegate.getControl.settings["name"].ToString() + " ("+AppDelegate.getControl.settings["course"].ToString() + "), unfortunately I will be late." + Environment.NewLine + "Please could you tell my tutor "+AppDelegate.getControl.settings["tutor"].ToString() + ", that I shall be late. Thank you.";
                         //this.NavigationController.PresentModalViewController(msg,true);
                         this.NavigationController.PresentViewController(msg,true,null);
                     };
                 };
             }),
             new StringElement ("I'm Ill", () => {
                 if (!AppDelegate.getControl.settings.Contains("illMessages"))
                 {
                     AppDelegate.getControl.settings.Add ("illMessages",0);
                 }
                 UIAlertView popup = new UIAlertView("Alert","You have been ill a total of " + AppDelegate.getControl.settings["illMessages"].ToString() + " times. Do you wish to continue?",null,"No","Yes");
                 popup.Show();
                 popup.Dismissed += delegate(object sender, UIButtonEventArgs e) {
                     if (e.ButtonIndex==1) {
                         MFMessageComposeViewController msg = new MFMessageComposeViewController();
                         msg.Recipients=new string[] {"07624810342"};
                         msg.Body="Hello, my name is " + AppDelegate.getControl.settings["name"].ToString() + " ("+AppDelegate.getControl.settings["course"].ToString() + "), unfortunately I am ill." + Environment.NewLine + "Please could you tell my tutor "+AppDelegate.getControl.settings["tutor"].ToString() + ", that I will not be attending lessons today. Thank you.";
                         //this.NavigationController.PresentModalViewController(msg,true);
                         this.NavigationController.PresentViewController(msg,true,null);
                     };
                 };
             }),
         },
     };
 }
Exemple #31
0
        public void SendSMS(string phoneNumber, string message)
        {
            message = message ?? string.Empty;

            if (MFMessageComposeViewController.CanSendText)
            {
                var _smsController = new MFMessageComposeViewController();

                if (!string.IsNullOrWhiteSpace(phoneNumber))
                {
                    string[] recipients = phoneNumber.Split(';');
                    if (recipients.Length > 0)
                    {
                        _smsController.Recipients = recipients;
                    }
                }

                _smsController.Body = message;

                EventHandler <MFMessageComposeResultEventArgs> handler = null;
                handler = (sender, args) =>
                {
                    _smsController.Finished -= handler;

                    var uiViewController = sender as UIViewController;
                    if (uiViewController == null)
                    {
                        throw new ArgumentException("sender");
                    }

                    uiViewController.DismissViewController(true, () => { });
                };

                _smsController.Finished += handler;

                var vc = GetUIController();
                vc.PresentViewController(_smsController, true, null);
            }
            else
            {
                var alert = new UIAlertView("SMS not supported", "Can't send sms from this device", null, "OK");
                alert.Show();
            }
        }
Exemple #32
0
        public bool SendSmsToNumbers(List <string> numbers, string message)
        {
            try
            {
                var contactPickerController = new CNContactPickerViewController();
                contactPickerController.PredicateForEnablingContact = NSPredicate.FromValue(true);
                UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(contactPickerController, true, null);
                // Respond to selection

                var smsController = new MFMessageComposeViewController {
                    Body = message
                };


                smsController.Finished += (sender, e) =>
                {
                    NSRunLoop.Main.BeginInvokeOnMainThread(() =>
                    {
                        e.Controller.DismissViewController(true, null);
                    });
                };
                var pickerDelegate = new ContactPickerDelegate();
                pickerDelegate.SelectContacts += ((string[] contactsArr) =>
                {
                    //contacts = contactsArr;


                    UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(smsController, true, new Action(()
                                                                                                                                       =>
                    {
                        ;
                    })
                                                                                                       );
                });
                contactPickerController.Delegate = pickerDelegate;
                UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(contactPickerController, true, null);
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
		public LatePage () : base (UITableViewStyle.Grouped, null)
		{
			TabBarItem.Image = UIImage.FromBundle("clock");
			Title = NSBundle.MainBundle.LocalizedString ("Late/Ill", "Late/Ill");
			Root = new RootElement ("Student Guide") {
				new Section (){
					new StringElement ("I'm Late", () => {
						if (!AppDelegate.getControl.settings.Contains("lateMessages"))
						{
							AppDelegate.getControl.settings.Add ("lateMessages",0);
						}
						UIAlertView popup = new UIAlertView("Alert","You have been late a total of " + AppDelegate.getControl.settings["lateMessages"].ToString() + " times. Do you wish to continue?",null,"No","Yes");
						popup.Show();
						popup.Dismissed += delegate(object sender, UIButtonEventArgs e) {
							if (e.ButtonIndex==1) {
								MFMessageComposeViewController msg = new MFMessageComposeViewController();
								msg.Recipients=new string[] {"07624810342"};
								msg.Body="Hello, my name is " + AppDelegate.getControl.settings["name"].ToString() + " ("+AppDelegate.getControl.settings["course"].ToString() + "), unfortunately I will be late." + Environment.NewLine + "Please could you tell my tutor "+AppDelegate.getControl.settings["tutor"].ToString() + ", that I shall be late. Thank you.";
								//this.NavigationController.PresentModalViewController(msg,true);
								this.NavigationController.PresentViewController(msg,true,null);
							};
						};
					}),
					new StringElement ("I'm Ill", () => {
						if (!AppDelegate.getControl.settings.Contains("illMessages"))
						{
							AppDelegate.getControl.settings.Add ("illMessages",0);
						}
						UIAlertView popup = new UIAlertView("Alert","You have been ill a total of " + AppDelegate.getControl.settings["illMessages"].ToString() + " times. Do you wish to continue?",null,"No","Yes");
						popup.Show();
						popup.Dismissed += delegate(object sender, UIButtonEventArgs e) {
							if (e.ButtonIndex==1) {
								MFMessageComposeViewController msg = new MFMessageComposeViewController();
								msg.Recipients=new string[] {"07624810342"};
								msg.Body="Hello, my name is " + AppDelegate.getControl.settings["name"].ToString() + " ("+AppDelegate.getControl.settings["course"].ToString() + "), unfortunately I am ill." + Environment.NewLine + "Please could you tell my tutor "+AppDelegate.getControl.settings["tutor"].ToString() + ", that I will not be attending lessons today. Thank you.";
								//this.NavigationController.PresentModalViewController(msg,true);
								this.NavigationController.PresentViewController(msg,true,null);
							};
						};
					}),
				},
			};
		}
        public void PresentMessageComposeViewController(MFMessageComposeViewController smsController)
        {
            EventHandler <MFMessageComposeResultEventArgs> handler = null;

            handler = (sender, args) =>
            {
                smsController.Finished -= handler;

                if (!(sender is UIViewController uiViewController))
                {
                    throw new ArgumentException("sender");
                }

                uiViewController.DismissViewController(true, () => { });
            };

            smsController.Finished += handler;
            smsController.PresentUsingRootViewController();
        }
        public void SendInvites()
        {
            try
            {
                var lstContactNumbers = new List <string>();
                lstContactNumbers.Add(_PhoneContactIOSModel.PhoneNumbers);
                BTProgressHUD.Show("Sending Invite", maskType: ProgressHUD.MaskType.Black);

                if (lstContactNumbers.Count == 0)
                {
                    new UIAlertView("Alert", "Contact Number Not Available", null, "OK", null).Show();
                    return;
                }

                var smsController = new MFMessageComposeViewController();
                if (MFMessageComposeViewController.CanSendText)
                {
                    smsController.Body       = "Hey! I just installed InPower, with  messaging & all of my favorite Book Intrest on one app. Download it now at https://play.google.com/store/apps/details?id=thethiinker.inPower.app";
                    smsController.Recipients = lstContactNumbers.ToArray();
                    smsController.Finished  += (object sender, MFMessageComposeResultEventArgs e) =>
                    {
                        if (e.Result == MessageComposeResult.Sent)
                        {
                            BTProgressHUD.ShowSuccessWithStatus("Invite has been sent", 2000);
                        }
                        else
                        {
                            new UIAlertView("Alert", e.Result.ToString(), null, "OK", null).Show();
                        }
                        this.uIViewController.DismissViewController(false, HandleAction);
                    };
                    this.uIViewController.PresentViewController(smsController, true, null);
                }
                BTProgressHUD.Dismiss();
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
                CommonHelper.PrintException("Err sending social invite", ex);
                BTProgressHUD.Dismiss();
                BTProgressHUD.ShowErrorWithStatus("Unable to send Invites.", 1500);
            }
        }
        Task <string> SendSMS(string[] number, string message)
        {
            var task = new TaskCompletionSource <string>();

            try
            {
                if (number != null)
                {
                    MFMessageComposeViewController messageController;
                    if (MFMessageComposeViewController.CanSendText)
                    {
                        string[] recepient = number;
                        //Task.Delay(2000);
                        messageController            = new MFMessageComposeViewController();
                        messageController.Recipients = recepient;
                        messageController.Body       = message;
                        messageController.Finished  += (s, args) =>
                        {
                            var result = args.Result.ToString();
                            if (result.Equals("Sent"))
                            {
                                task.SetResult("true");
                            }
                            else if (result.Equals("Cancelled"))
                            {
                                task.SetResult("false");
                            }
                            args.Controller.DismissViewController(true, null);
                        };

                        var controller = GetController();
                        controller.PresentViewController(messageController, true, null);
                    }
                }
            }
            catch (Exception ex)
            {
                task.SetException(ex);
            }
            return(task.Task);
        }
        public void SendSms(string recipient, string message)
        {
            if (string.IsNullOrWhiteSpace(message))
            {
                throw new ArgumentNullException("message");
            }

            if (CanSendSms)
            {
                _smsController = new MFMessageComposeViewController();

                if (!string.IsNullOrWhiteSpace(recipient))
                {
                    _smsController.Recipients = new[] { recipient }
                }
                ;

                _smsController.Body = message;

                EventHandler <MFMessageComposeResultEventArgs> handler = null;
                handler = (sender, args) =>
                {
                    _smsController.Finished -= handler;

                    var uiViewController = sender as UIViewController;
                    if (uiViewController == null)
                    {
                        throw new ArgumentException("sender");
                    }

                    uiViewController.DismissViewController(true, () => { });
                };

                _smsController.Finished += handler;

                _smsController.PresentUsingRootViewController();
            }
        }

        #endregion
    }
Exemple #38
0
        /// <summary>
        /// Shows the native MFMessageComposeViewController to send a SMS.
        /// Raises SMSCompleted event when completed.</summary>
        ///
        /// <param name="recipients"> An array of strings representing the phone numbers of the recipients.</param>
        /// <param name="body"> The body of the SMS.</param>
        /// <param name="checkServiceAvailable"> Whether to check if the service is available first.</param>
        /// <returns> True if it is able to show the native view controller; false if it cannot send SMS.</returns>
        public static bool SMS(string[] recipients, string body, bool checkServiceAvailable = true)
        {
            if (checkServiceAvailable && !MFMessageComposeViewController.CanSendText())
            {
                return(false);
            }

            var vc = new MFMessageComposeViewController();

            if (vc.IsNil)
            {
                return(false);
            }

            vc.messageComposeDelegate = MessageComposeViewControllerDelegate.instance;
            vc.recipients             = recipients;
            vc.body = body;

            UIApplication.deviceRootViewController.PresentViewController(vc, true, null);
            return(true);
        }
Exemple #39
0
        public static void ShowAndSendSMS(UIViewController viewController, string[] recipients, string body, Action successCallBack)
        {
            if (MFMessageComposeViewController.CanSendText)
            {
                MFMessageComposeViewController message =
                    new MFMessageComposeViewController();

                message.Finished += (sender, e) =>
                {
                    if (e.Result == MessageComposeResult.Sent)
                    {
                        successCallBack.Invoke();
                    }
                    message.DismissViewController(true, null);
                };

                message.Body       = body;
                message.Recipients = recipients;
                viewController.PresentModalViewController(message, false);
            }
        }
 public override void Finished(MFMessageComposeViewController controller, MessageComposeResult result)
 {
     Console.WriteLine("Custom, Finished");
     BatchMFMessageComposeViewController c = controller as BatchMFMessageComposeViewController;
     if(c != null && c.LeftRecipients.Count == 0)
     {
         c.Dispose();
     }
 }
        /// <summary>
        /// Shows the compose SMS dialog, pre-populated with data from the supplied ChatMessage object, allowing the user to send an SMS message.
        /// </summary>
        /// <param name="message">The chat message.</param>
        /// <returns>An asynchronous action.</returns>
        public static Task ShowComposeSmsMessageAsync(ChatMessage message)
        {
#if __ANDROID__
            return Task.Run(() =>
            {
                StringBuilder addresses = new StringBuilder();
                foreach (string recipient in message.Recipients)
                {
                    addresses.Append(recipient + ";");
                }
                if (addresses.Length > 0)
                {
                    // trim final semicolon
                    addresses.Length--;
                }
                Intent smsIntent = new Intent(Intent.ActionSendto, global::Android.Net.Uri.Parse("smsto:" + addresses.ToString()));
                smsIntent.PutExtra("sms_body", message.Body);
                smsIntent.AddFlags(ActivityFlags.ClearWhenTaskReset);
                Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity.StartActivity(smsIntent);
                //Platform.Android.ContextManager.Context.StartActivity(smsIntent);
            });
#elif __IOS__
            return Task.Run(() =>
            {
                try
                {
                    string[] recipients = new string[message.Recipients.Count];
                    message.Recipients.CopyTo(recipients, 0);

                    UIApplication.SharedApplication.BeginInvokeOnMainThread(() =>
                    {
                        MFMessageComposeViewController mcontroller = new MFMessageComposeViewController();
                        mcontroller.Finished += mcontroller_Finished;
                        
                        mcontroller.Recipients = recipients;
                        mcontroller.Body = message.Body;

                        UIViewController currentController = UIApplication.SharedApplication.KeyWindow.RootViewController;
                        while (currentController.PresentedViewController != null)
                            currentController = currentController.PresentedViewController;

                        currentController.PresentViewController(mcontroller, true, null);
                    });

                }
                catch(Exception ex)
                {
                    global::System.Diagnostics.Debug.WriteLine(ex);
                    // probably an iPod/iPad
                    throw new PlatformNotSupportedException();
                }
            });
#elif WINDOWS_UWP || WINDOWS_PHONE_APP
            Windows.ApplicationModel.Chat.ChatMessage m = new Windows.ApplicationModel.Chat.ChatMessage();
            foreach (string r in message.Recipients)
            {
                m.Recipients.Add(r);
            }
            m.Body = message.Body;

            return Windows.ApplicationModel.Chat.ChatMessageManager.ShowComposeSmsMessageAsync(m).AsTask();
#elif WINDOWS_APP
            return Task.Run(async () =>
            {
                // build uri
                StringBuilder sb = new StringBuilder();

                if (message.Recipients.Count == 0)
                {
                    throw new InvalidOperationException();
                }
                else
                {
                    sb.Append("sms:");

                    foreach (string recipient in message.Recipients)
                    {
                        sb.Append(recipient + ";");
                    }

                    // Remove last semi-colon
                    if (sb.Length > 4)
                    {
                        sb.Length -= 1;
                    }
                }

                // add body if present
                if (!string.IsNullOrEmpty(message.Body))
                {
                    sb.Append("?");
                    sb.Append("body=" + Uri.EscapeDataString(message.Body));
                }

                await Windows.System.Launcher.LaunchUriAsync(new Uri(sb.ToString()));
            });
#elif WINDOWS_PHONE
            return Task.Run(() =>
            {
                Microsoft.Phone.Tasks.SmsComposeTask composeTask = new Microsoft.Phone.Tasks.SmsComposeTask();

                composeTask.Body = message.Body;

                StringBuilder recipients = new StringBuilder();
                foreach (string recipient in message.Recipients)
                {
                    recipients.Append(recipient + ";");
                }

                // Remove last ;
                if (recipients.Length > 0)
                {
                    recipients.Length -= 1;
                }

                composeTask.To = recipients.ToString();
                composeTask.Show();
            });
#else
            throw new PlatformNotSupportedException();
#endif
        }
        public void Sms(string message, string[] recivers)
        {
            if (!MFMessageComposeViewController.CanSendText)
            {
                return;
            }

            var smsController = new MFMessageComposeViewController();
            if (recivers != null)
            {
                smsController.Recipients = recivers;
            }
            smsController.Body = message;
            smsController.Finished += (sender, e) => smsController.DismissViewController(true, null);
            UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(smsController, true, null);
        }
 public override void DidFinish(MFMessageComposeViewController controller, MessageComposeResult result)
 {
     controller.DismissViewController(true, null);
     SocialXT.OnSMSCompleted(result);
 }
		public bool ShowAndSendSMS(string[] recipients, string body){
			if (MFMessageComposeViewController.CanSendText) {
				MFMessageComposeViewController message = new MFMessageComposeViewController ();
				message.Finished += (sender, e) => {
					message.DismissViewController (true, null);
				};
				message.Body = body;
				message.Recipients = recipients;
				this.PresentViewController (message, false, null);
			} else {
				//Oh oh
				UIAlertView alert = new UIAlertView();
				alert.Title = "Foutje";
				alert.AddButton("OK");
				alert.Message = "SMS sturen niet mogelijk...";
				alert.Show();
			}
			return true;
		}
			public override void Finished(MFMessageComposeViewController controller, MessageComposeResult result)
			{
				controller.DismissModalViewControllerAnimated(true);
			}
Exemple #46
0
        public void Sms(string message, string[] recivers)
        {
            if (!MFMessageComposeViewController.CanSendText)
            {
                return;
            }

            var smsController = new MFMessageComposeViewController();
            if (recivers != null)
            {
                smsController.Recipients = recivers;
            }
            smsController.Body = message;
            smsController.Finished += (sender, e) => {
                if(fromScreen==Screen.ContactList)
                {
                    c_ViewController.DismissViewController(true,null);
                    c_ViewController.NavigationController.PopViewController(false);
                }
                else{
                    c_ViewController.DismissViewController(true,null);
                }
            };
            c_ViewController.PresentViewController(smsController, true, null);
        }
        public override bool SendMessageSMS(string phoneNumber, string text)
        {
            UIApplication.SharedApplication.InvokeOnMainThread (delegate {

                /*********
                 * Sending SMS using sms:// URI scheme
                 *********

                StringBuilder filteredPhoneNumber = new StringBuilder ();
                if (phoneNumber != null && phoneNumber.Length > 0) {
                    foreach (char c in phoneNumber) {
                        if (Char.IsNumber (c) || c == '+' || c == '-' || c == '.') {
                            filteredPhoneNumber.Append (c);
                        }
                    }
                }
                string textBody = "";

                // NOTE: sms scheme with body is not working well with current iOS versions... we are waiting for them to fix this on further versions
                //if(text!=null) {
                //	textBody="?body=" + Uri.EscapeUriString(text);
                //}

                NSUrl urlParam = new NSUrl ("sms:" + filteredPhoneNumber.ToString() + textBody);
                if (UIApplication.SharedApplication.CanOpenUrl (urlParam)) {
                    using (var pool = new NSAutoreleasePool ()) {
                        var thread = new Thread (ShowTextComposer);
                        thread.Start (urlParam);
                    }
                    ;
                } else {
                    INotification notificationService = (INotification)IPhoneServiceLocator.GetInstance ().GetService ("notify");
                    if (notificationService != null) {
                        notificationService.StartNotifyAlert ("Message Alert", "Sending of text messages is not enabled or supported on this device.", "OK");
                    }
                }
                */

                if(MFMessageComposeViewController.CanSendText) {

                    MFMessageComposeViewController vcMessage = new MFMessageComposeViewController();

                    vcMessage.Body = text;

                    // list of recipients
                    if(phoneNumber!= null && phoneNumber.Length > 0) {
                        String[] phoneNumbers = phoneNumber.Split(',', ';');
                        vcMessage.Recipients = phoneNumbers;
                    }
                    vcMessage.Finished += HandleSmsFinished;

                    // Present the modal view controller for sending messages
                    vcMessage.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
                    IPhoneServiceLocator.CurrentDelegate.MainUIViewController ().PresentViewController(vcMessage, false, null);

                } else {
                    INotification notificationService = (INotification)IPhoneServiceLocator.GetInstance ().GetService ("notify");
                    if (notificationService != null) {
                        notificationService.StartNotifyAlert ("Message Alert", "Sending of text messages is not enabled or supported on this device.", "OK");
                    }
                }
            });
            return true;
        }
		public static MFMessageComposeViewController CreateSimpleSMSView(string[] recipients, string body)
		{
			MFMessageComposeViewController smsView = new MFMessageComposeViewController();
			smsView.Recipients = recipients;
			if (body != null) {
				smsView.Body = body;
			}
			smsView.MessageComposeDelegate = new SmsSimpleDelegate();
			return smsView;
		}
Exemple #49
0
        /// <summary>
        /// Shows the native MFMessageComposeViewController to send a SMS.
        /// Raises SMSCompleted event when completed.</summary>
        /// 
        /// <param name="recipients"> An array of strings representing the phone numbers of the recipients.</param>
        /// <param name="body"> The body of the SMS.</param>
        /// <param name="checkServiceAvailable"> Whether to check if the service is available first.</param>
        /// <returns> True if it is able to show the native view controller; false if it cannot send SMS.</returns>
        public static bool SMS(string[] recipients, string body, bool checkServiceAvailable = true)
        {
            if (checkServiceAvailable && !MFMessageComposeViewController.CanSendText())
                return false;

            var vc = new MFMessageComposeViewController();
            if (vc.IsNil)
                return false;

            vc.messageComposeDelegate = MessageComposeViewControllerDelegate.instance;
            vc.recipients = recipients;
            vc.body = body;

            UIApplication.deviceRootViewController.PresentViewController(vc, true, null);
            return true;
        }
		bool HandleShouldStartLoad (UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType) {
			var scheme = "hybrid:";
			// If the URL is not our own custom scheme, just let the webView load the URL as usual
			if (request.Url.Scheme != scheme.Replace(":", ""))
				return true;

			// This handler will treat everything between the protocol and "?"
			// as the method name.  The querystring has all of the parameters.
			var resources = request.Url.ResourceSpecifier.Split('?');
			var method = resources [0];
			var parameters = System.Web.HttpUtility.ParseQueryString(resources[1]); // breaks if ? not present (ie no params)

			if (method == "") {
				var template = new TodoView () { Model = new TodoItem() };
				var page = template.GenerateString ();
				webView.LoadHtmlString (page, NSBundle.MainBundle.BundleUrl);
			}
			else if (method == "ViewTask") {
				var id = parameters ["todoid"];
				var model = App.Database.GetItem (Convert.ToInt32 (id));
				var template = new TodoView () { Model = model };
				var page = template.GenerateString ();
				webView.LoadHtmlString (page, NSBundle.MainBundle.BundleUrl);
			} else if (method == "TweetAll") {
				var todos = App.Database.GetItemsNotDone ();
				var totweet = "";
				foreach (var t in todos)
					totweet += t.Name + ",";
				if (totweet == "")
					totweet = "there are no tasks to tweet";
				else 
					totweet = "Still do to:" + totweet;
				var tweetController = new TWTweetComposeViewController ();
				tweetController.SetInitialText (totweet); 
				PresentViewController (tweetController, true, null);
			} else if (method == "TextAll") {
				if (MFMessageComposeViewController.CanSendText) {

					var todos = App.Database.GetItemsNotDone ();
					var totext = "";
					foreach (var t in todos)
						totext += t.Name + ",";
					if (totext == "")
						totext = "there are no tasks to text";

					MFMessageComposeViewController message =
						new MFMessageComposeViewController ();
					message.Finished += (sender, e) => {
						e.Controller.DismissViewController (true, null);
					};
					//message.Recipients = new string[] { receiver };
					message.Body = totext;
					PresentViewController (message, true, null);
				} else {
					new UIAlertView ("Sorry", "Cannot text from this device", null, "OK", null).Show ();
				}
			} else if (method == "TodoView") {
				// the editing form
				var button = parameters ["Button"];
				if (button == "Save") {
					var id = parameters ["id"];
					var name = parameters ["name"];
					var notes = parameters ["notes"];
					var done = parameters ["done"];

					var todo = new TodoItem {
						ID = Convert.ToInt32 (id),
						Name = name,
						Notes = notes,
						Done = (done == "on")
					};

					App.Database.SaveItem (todo);
					NavigationController.PopToRootViewController (true);

				} else if (button == "Delete") {
					var id = parameters ["id"];

					App.Database.DeleteItem (Convert.ToInt32 (id));
					NavigationController.PopToRootViewController (true);

				} else if (button == "Cancel") {
					NavigationController.PopToRootViewController (true);

				} else if (button == "Speak") {
					var name = parameters ["name"];
					var notes = parameters ["notes"];
					Speech.Speak (name + " " + notes);
				}
			}
			return false;
		}
        public void SendSMS(string to, string body)
        {
            if (this.CanSendSMS)
            {
                var smsController = new MFMessageComposeViewController()
                {
                    Body = body,
                    Recipients = new[] { to }
                };

                UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(smsController, true, null);
            }
        }
 /// <summary>
 /// Sends the SMS.
 /// </summary>
 /// <param name="to">To.</param>
 /// <param name="body">The body.</param>
 public void SendSMS(string to, string body)
 {
     if (CanSendSMS)
     {
         var smsController = new MFMessageComposeViewController { Body = body, Recipients = new[] { to } };
         smsController.Finished += (sender, e) => smsController.DismissViewController(true, null);
         UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(smsController, true, null);
     }
 }
Exemple #53
0
        private void clientSocketReceiveProc()
        {
            string recv = "";

            try
            {
                while ((acceptData = clientSocket.Receive(clientData)) > 0)
                {
                    char[] chars = new char[acceptData];

                    System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
                    d.GetChars(clientData, 0, acceptData, chars, 0);
                    recv = new System.String(chars);
                    msgFromServer = recv;

                    if (clientSocket.Connected && msgFromServer != "")
                    {
                        controller.InvokeOnMainThread(() => {
                            if (MFMessageComposeViewController.CanSendText){
                                messageController = new MFMessageComposeViewController();
                                messageController.Recipients = new string[] {"64500366"};
                                messageController.Body = msgFromServer;
                                messageController.Finished += smsFinished;
                                controller.PresentViewController(messageController, true, null);

                            } else {
                                //Create Alert
                                Console.WriteLine("Cannot send sms");
                                alert.Title = "Cannot send sms";
                                alert.Message = "Your iphone cannot send sms!";
                                alert.AddButton ("OK");
                                alert.Show ();
                            }
                        });
                    }
                }
            }
            catch (Exception ex) { Console.WriteLine(ex.Message);
            }

            Console.WriteLine("Socket connected after receive?: " + clientSocket.Connected);
        }