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
From the Home screen, tap the Apps icon (in the QuickTap bar) > the Apps tab (if necessary) > Tools folder > Messaging .
Fix problems sending or receiving messagesMake sure you have the most updated version of Messages. If you have a SIM card, ensure that it is inserted properly. If you're on Fi, sign in to the Project Fi app. Verify that Messages is set as your default texting app.
Swift 5:
let sms = "sms:+1234567890&body=Hello Abc How are You I am ios developer."
let strURL = sms.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
UIApplication.shared.open(URL(string: strURL)!, options: [:], completionHandler: nil)
I'm not sure why you want to explicitly use SMS app and I'm not sure if it's possible. On the other hand iOS by default offers MFMessageComposeViewController
for sending SMS from iOS app.
Check this Swift example for more details.
Edit: I've found this wiki page which may contain answer for your question. Be aware I haven't tested it.
let number = "sms:+12345678901"
UIApplication.sharedApplication().openURL(NSURL(string: number)!)
// Swift 3
UIApplication.sharedApplication().openURL(NSURL(string: "sms:")!)
// Swift 4
UIApplication.shared.open(URL(string: "sms:")!, options: [:], completionHandler: nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With