Exemplo n.º 1
0
 public MFComposeResultEventArgs(MFMailComposeViewController controller, MFMailComposeResult result, NSError error)
 {
     Result     = result;
     Error      = error;
     Controller = controller;
 }
Exemplo n.º 2
0
        //sharing options
        private void shareAlert(string title, string message)
        {
            UIAlertController shareController = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert);


            //facebook servers
            UIAlertAction facebookAction = UIAlertAction.Create("Facebook", UIAlertActionStyle.Default, (Action) => {
                NSUrl facebookURL = NSUrl.FromString("");

                if (UIApplication.SharedApplication.CanOpenUrl(facebookURL) == true)
                {
                    UIApplication.SharedApplication.OpenUrl(facebookURL);
                    shareController.Dispose();
                }
                else if (UIApplication.SharedApplication.CanOpenUrl(facebookURL) == false)
                {
                    AI.AIEnglish("Cannot connect you to the facebook servers. Check your internet connection", "en-US", 2.0f, 1.0f, 1.0f);
                    shareController.Dispose();
                }
            });

            //twitter servers
            UIAlertAction twitterAction = UIAlertAction.Create("Twitter", UIAlertActionStyle.Default, (Action) =>
            {
                NSUrl twitterURL = NSUrl.FromString("");

                if (UIApplication.SharedApplication.CanOpenUrl(twitterURL) == true)
                {
                    UIApplication.SharedApplication.OpenUrl(twitterURL);
                    shareController.Dispose();
                }
                else if (UIApplication.SharedApplication.CanOpenUrl(twitterURL) == false)
                {
                    AI.AIEnglish("Cannot connect you to the twitter servers. Check your internet connection", "en-US", 2.0f, 1.0f, 1.0f);
                    shareController.Dispose();
                }
            });

            //email a friend option
            UIAlertAction emailFriend = UIAlertAction.Create("\ud83d\udc8c Email a Friend", UIAlertActionStyle.Default, (Action) =>
            {
                MFMailComposeViewController mailEmail = new MessageUI.MFMailComposeViewController();

                if (MFMailComposeViewController.CanSendMail == true)
                {
                    this.PresentViewController(mailEmail, true, null);
                }

                else
                {
                    if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                    {
                        AI.AIEnglish("Error cannot open mail box. Check if the mail box is enabled on your iPad", "en-US", 2.0f, 1.0f, 1.0f);
                    }
                    else if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
                    {
                        AI.AIEnglish("Error cannot open mail box. Check if the mail box is enabled on your iPhone", "en-US", 2.0f, 1.0f, 1.0f);
                    }
                }

                mailEmail.Finished += (sender, e) =>
                {
                    //mail closes
                    mailEmail.DismissViewController(true, null);
                };
            });

            //text a friend option
            UIAlertAction textFriend = UIAlertAction.Create("\ud83d\udcf2 Text a friend", UIAlertActionStyle.Default, (Action) => {
                NSUrl textFriendURL = NSUrl.FromString("sms:");

                if (UIApplication.SharedApplication.CanOpenUrl(textFriendURL) == true)
                {
                    UIApplication.SharedApplication.OpenUrl(textFriendURL);
                }
                else if (UIApplication.SharedApplication.CanOpenUrl(textFriendURL) == false)
                {
                    if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                    {
                        AI.AIEnglish("Error cannot open text message box. Check if the text messages are enabled on your iPad", "en-US", 2.0f, 1.0f, 1.0f);
                    }
                    else if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
                    {
                        AI.AIEnglish("Error cannot open text message box. Check if the text messages are enabled on your iPhone", "en-US", 2.0f, 1.0f, 1.0f);
                    }
                }
            });

            UIAlertAction rateOnAppStore = UIAlertAction.Create("\ud83d\udc4d Rate on App Store", UIAlertActionStyle.Default, (Action) =>
            {
                NSUrl urlRateAppURL = NSUrl.FromString("");                 //url of application on app store

                if (UIApplication.SharedApplication.CanOpenUrl(urlRateAppURL) == true)
                {
                    UIApplication.SharedApplication.OpenUrl(urlRateAppURL);
                }

                else
                {
                    if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                    {
                        AI.AIEnglish("No internet connection detected. Cannot connect to the App Store", "en-US", 2.5f, 1.0f, 1.0f);
                    }
                    else if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
                    {
                        AI.AIEnglish("No internet connection detected.  Cannot connect to the App Store", "en-US", 2.5f, 1.0f, 1.0f);
                    }
                    shareController.Dispose();
                }
            });

            UIAlertAction denied = UIAlertAction.Create("Maybe Later", UIAlertActionStyle.Destructive, (Action) =>
            {
                shareController.Dispose();
            });

            shareController.AddAction(facebookAction);
            shareController.AddAction(twitterAction);
            shareController.AddAction(emailFriend);
            shareController.AddAction(textFriend);
            shareController.AddAction(rateOnAppStore);
            shareController.AddAction(denied);

            if (this.PresentedViewController == null)
            {
                this.PresentViewController(shareController, true, null);
            }

            else if (this.PresentedViewController != null)
            {
                this.PresentedViewController.DismissViewController(true, () =>
                {
                    this.PresentedViewController.Dispose();
                    this.PresentViewController(shareController, true, null);
                });
            }
        }