Ios – How to launch SMS Message app

iosswift

I want to open SMS Message App to copy some text from friends. I am not creating SMS.

How to launch iphone SMS Message app using Swift code?
I come across this code below for launching Mail app but not working.


[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:"]];

I changed it to and the same not working

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:"]];

appreciate your help. TIA

Best Answer

// Swift 3
UIApplication.sharedApplication().openURL(NSURL(string: "sms:")!)

// Swift 4
UIApplication.shared.open(URL(string: "sms:")!, options: [:], completionHandler: nil)
Related Topic