Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. iPhone 7 - how to open the built in SMS window?
QtWS25 Last Chance

iPhone 7 - how to open the built in SMS window?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
10 Posts 4 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yumyumyum
    wrote on last edited by yumyumyum
    #1

    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?

    jsulmJ 1 Reply Last reply
    0
    • Y yumyumyum

      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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yumyumyum
        wrote on last edited by
        #3

        But some reference even said you cant even do that at all? http://stackoverflow.com/a/59200/285594, is it true?

        jsulmJ 1 Reply Last reply
        0
        • Y yumyumyum

          But some reference even said you cant even do that at all? http://stackoverflow.com/a/59200/285594, is it true?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @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.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • Y Offline
            Y Offline
            yumyumyum
            wrote on last edited by
            #5

            @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

            jsulmJ 1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              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.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • Y Offline
                Y Offline
                yumyumyum
                wrote on last edited by yumyumyum
                #7

                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.
                  }
                
                
                }
                
                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  You would need to implement a wrapper over the Objective-C equivalent of your swift code.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1
                  • Y yumyumyum

                    @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

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @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.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    2
                    • F Offline
                      F Offline
                      Fankasery
                      wrote on last edited by Fankasery
                      #10

                      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 ,

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved