iPhone 7 - how to open the built in SMS window?
-
In my iPhone 7 how to open the SMS window to insert phone number in phone field and texts in the texts field? How to handle those windows using Qt?
QDesktopServices::openUrl(QUrl("sms://+123456789"));
But how do i put some texts?
@yumyumyum It looks like you cannot set the text: https://wiki.qt.io/How_to_make_a_call_or_send_a_sms_on_iOS
"Setting the SMS content through this method cannot be done. This would require to use iOS API directly through Objective-C++" - so you you need to use native API. -
But some reference even said you cant even do that at all? http://stackoverflow.com/a/59200/285594, is it true?
-
But some reference even said you cant even do that at all? http://stackoverflow.com/a/59200/285594, is it true?
@yumyumyum As far as I can see it does not say it is not possible. It is not possible without SMS app popping up, but you want it to pop up, so no problem.
-
@jsulm YES - i have no problem if the popup open, but from my Qt5 application i want to send the Phone number which is OK. But now how do i send the content from my Qt straight to the SMS UI of IPhone and push the send button?
"Hey guys, checkout Qt5 is out, it can rock iPhone now" send the SMS
-
Hi,
If you mean fully automated SMS sending without user interaction, then indeed, it's not possible and that's a good thing.
If you would like you to prepare the message for your user then the linked tutorial is a good start.
-
I did this in Swift (1) Go to website (2) read the web content line (3) split the string into telephone number and SMS (4) ask to send or not (5) send it to UI.
how to do this exactly in Qt5/c++? (guys let us contribute lot of Qt5/C++ codes in this forum, make quality answers, also helps search engines to find us)
import UIKit import MessageUI class ViewController: UIViewController, MFMessageComposeViewControllerDelegate { @IBAction func sendMessage(_ sender: AnyObject) { // 1 HTTP GET let url = URL(string: "https://icanhazip.com") var tel_no = "unchanged" let task = URLSession.shared.dataTask(with: url! as URL) { data, response, error in let response = String(data: data!, encoding: String.Encoding(rawValue: String.Encoding.utf8.rawValue)) tel_no = response! as String print(tel_no) var dial_number = tel_no.components(separatedBy: "_") // 2 Clicked let alert = UIAlertController(title: dial_number[0] , message: dial_number[1] , preferredStyle: UIAlertControllerStyle.alert) alert.addAction(UIAlertAction(title: "OK", style: .default) { action in // 3 Forward to SMS let messageVC = MFMessageComposeViewController() messageVC.recipients = [ dial_number[0] ] messageVC.body = dial_number[1] ; messageVC.messageComposeDelegate = self; self.present(messageVC, animated: false, completion: nil) }) alert.addAction(UIAlertAction(title: "EXIT", style: .default) { action in print("Handle Cancel Logic here") exit(0); }) self.present(alert, animated: true) } task.resume() } func messageComposeViewController(_ controller: MFMessageComposeViewController!, didFinishWith result: MessageComposeResult) { } override func viewDidLoad() { super.viewDidLoad() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } }
-
You would need to implement a wrapper over the Objective-C equivalent of your swift code.
-
@jsulm YES - i have no problem if the popup open, but from my Qt5 application i want to send the Phone number which is OK. But now how do i send the content from my Qt straight to the SMS UI of IPhone and push the send button?
"Hey guys, checkout Qt5 is out, it can rock iPhone now" send the SMS
@yumyumyum You can set the content as shown in the link:
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease]; if([MFMessageComposeViewController canSendText]) { controller.body = @"SMS message here"; controller.recipients = [NSArray arrayWithObjects:@"1(234)567-8910", nil]; controller.messageComposeDelegate = self; [self presentModalViewController:controller animated:YES]; }
I'm not an MacOS/iOS expert, but as far as I know you can do it easily with ObjectiveC++ in your Qt project.
-
This is difficult for beginners. You can think about third-party software, but one thing that you need to be careful, the operation can bring dangerous to iPhone messages , so you can transfer iPhone SMS to computer , in this way , the data has been protected on your computer ,