Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Messaging view with back button in iOS?

$
0
0

I'm working on a Forms app, that should send an SMS with a certain generated content to a remote server. I've built a ISMSService interface, which is implemented in Android, WP and iOS, and used from the Forms project SMS generator.

So far, so good. The messages are generated and sent as expected. However, in iOS, the app displays the Messaging app interface, and there is no back button. (In fact, there is no navigation bar.) The only way to return to my application main page, is by closing the app and starting it anew. As I understand it, the back button should be added automatically, but it isn't, and I cannot seem to get it added manually either.

Would someone a little more knowledgeable care to comment? Here's my SMS sending code:

public class SmsService : UIViewController, ISmsService
{
    public bool SendSms(string[] recipients, string message)
    {
        if (MFMessageComposeViewController.CanSendText)
        {
            var messageController = new MFMessageComposeViewController
            {
                Recipients = recipients,
                Body = message
            };

            var ctrl = UIApplication.SharedApplication.KeyWindow.RootViewController;

            ctrl.NavigationItem.BackBarButtonItem = new UIBarButtonItem("Send message", UIBarButtonItemStyle.Plain, null); // Trying to add back button
            ctrl.PresentViewController(messageController, true, null);
        }
        else
        {
            return false;
        }

        return true;
    }
}

Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>