8 Replies
      Latest reply on Oct 30, 2019 12:16 AM by ragulfromnilgiris
      Ivan Vassilev Level 1 Level 1 (5 points)

        Can I send message using SiriKit or SiriKit could send messages only by using external services?

         

        In method handle(sendMessage intent: INSendMessageIntent, completion: @escaping (INSendMessageIntentResponse) -> Void)

        there is a comment saying // Implement your application logic to send a message here.

         

        In my case I want to send a message the same way the MFMessageComposeViewController does

         

        Is that possible?

        • Re: SiriKit Sending Message
          edford Apple Staff Apple Staff (785 points)

          If you're trying to implement sending e-mail specifically, please see this previous thread.

            • Re: SiriKit Sending Message
              Ivan Vassilev Level 1 Level 1 (5 points)

              I would like to send a message to a phone number using Messages App via SiriKit, not an email.

              In my case I would like to send a message to a phone number that does not exiss in my phone book,

              that's why I am creating custom INPerson object and fill it with custom data

               

              Everything is working, Siri detects my intent and setup hardcoded message using resolveContent method,

              but once handle is executed nothing happen. Siri only response with "Message sent"

               

              The question is: Is it possible SiriKit to send message (not email) via Messaging App.

               

              In my case I would like to send messages to a short-code (which is paid). All short-codes will be configured in my App.

               

              Here is the code that I am using:

              import Foundation
              import Intents
              class MyIntent: NSObject, INSendMessageIntentHandling {
              
                  // Implement resolution methods to provide additional information about your intent (optional).
                  func resolveRecipients(for intent: INSendMessageIntent, with completion: @escaping ([INPersonResolutionResult]) -> Void) {
                   
                      if let recipients = intent.recipients {
                          if recipients.count == 0 {
                              let recipient = INPerson(personHandle: INPersonHandle(value: "1234", type: .phoneNumber, label: INPersonHandleLabel(rawValue: "PhoneNumber") ),
                                                        nameComponents: nil,
                                                        displayName: "CustomTitle",
                                                        image: nil,
                                                        contactIdentifier: nil,
                                                        customIdentifier: "customIdentifier")
                           
                              var resolutionResults = [INPersonResolutionResult]()
                              resolutionResults += [INPersonResolutionResult.success(with: recipient)]
                              completion(resolutionResults)
                          }
                      }
                  }
              
                  func resolveContent(for intent: INSendMessageIntent, with completion: @escaping (INStringResolutionResult) -> Void) {
                      completion(INStringResolutionResult.success(with: "Hello World"))
                  }
              
                  func handle(intent: INSendMessageIntent, completion: @escaping (INSendMessageIntentResponse) -> Void) {
                      //  Implement your application logic to send a message here.
                      let userActivity = NSUserActivity(activityType: NSStringFromClass(INSendMessageIntent.self))
                      let response = INSendMessageIntentResponse(code: .success, userActivity: userActivity)
                      completion(response)
                  }
              }
              
                • Re: SiriKit Sending Message
                  Zaid Level 2 Level 2 (70 points)

                  You Asked: "The question is: Is it possible SiriKit to send message (not email) via Messaging App."

                   

                  No. SiriKit was designed for your app to send a message using your server. SiriKit was not designed to integrate with other apps such as the iOS Messages app.

                  • Re: SiriKit Sending Message
                    edford Apple Staff Apple Staff (785 points)

                    In your first post, I misread MFMessageComposeViewController as MFMailComposeViewController - sorry about that.

                     

                    As Zaid said, this isn't possible. Siri will handle sending messages with the system's Messages app as a built in service, so there is no SiriKit API available for this.

                      • Re: SiriKit Sending Message
                        Ivan Vassilev Level 1 Level 1 (5 points)

                        Where may I post a few suggestions to Apple related to internal messaging system?

                        I would be happy iOS/watchOS to support the following thing:

                        - (iOS) To be able to send a message/SMS via SiriKit to contacts/persons by using predefined recipients.

                        - (iOS) To be able to customize UI of MFMessageComposeViewController. In some cases I don't want to open conversation composer. I want just to present a custom view to a client where he have to confirm the message he would like to send.

                        - (watchOS) To be able to send a message/SMS by using predefined recipients.

                         

                        All suggestions are currently missing and all of them require user confirmation.

                        I see no reason why Apple can't add such functionality

                      • Re: SiriKit Sending Message
                        ragulfromnilgiris Level 1 Level 1 (0 points)

                        Any solution for this??