How to start the SMS Message app
I want to open SMS Message app to copy text from friends. I am not creating SMS.
How to launch iphone SMS Message app using Swift code? I find this code below to launch Mail app but doesn't work.
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "mailto:"]];
I changed it and didn't work
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "sms:"]];
appreciate your help. TIA
+4
MilkBottle
source
to share
3 answers
// Swift 3
UIApplication.sharedApplication().openURL(NSURL(string: "sms:")!)
// Swift 4
UIApplication.shared.open(URL(string: "sms:")!, options: [:], completionHandler: nil)
+16
Reming Hsu
source
to share
I'm not sure why you want to explicitly use the SMS app, and I'm not sure if this is possible. On the other hand, iOS offers by default MFMessageComposeViewController
to send SMS from the iOS app.
Check this example for more details.
Edit: I found this wiki page that may contain an answer to your question. Please be aware that I have not tested it.
let number = "sms:+12345678901"
UIApplication.sharedApplication().openURL(NSURL(string: number)!)
+3
Josip B.
source
to share
Swift 5:
let sms: String = "sms:+1234567890&body=Hello Abc How are You I am ios developer."
let strURL: String = sms.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
UIApplication.shared.open(URL.init(string: strURL)!, options: [:], completionHandler: nil)
0
oskarko
source
to share