I have a requirements to show 3 options in an alert say Call / Text/ Cancel for iOS. As displayAlert cannot be used for 3 options I have created platform specific tweak and using UIAlertView in iOS. I have created an interface to show UIAlertView for the same and implementing in iOS project.
However now when user selects Text option in alertView I need to launch MFMessageComposeViewController and I am using below code in my iOS project.
However UIApplication.SharedApplication.KeyWindow.RootViewController is returned as UIAlertView due to which MessageComposer is never shown.
I tried using InvokeOnMainThread , however still the issue is not resolved.
How to resolve this ?
if (userMobileNumberList != null && userMobileNumberList.Count > 0 && CanSend) {
var smsController = new MFMessageComposeViewController () {
Recipients = userMobileNumberList.ToArray ()
};
smsController.Finished += (s, e) =>
((MFMessageComposeViewController)s).DismissViewController (true, () => {
});
**** UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController (smsController, true, null);****
}