Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23511] iOS10: Support SiriKit

GitHub Issuen/a
TypeStory
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-12-01T07:44:08.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.0.1
ComponentsiOS
Labelsios10, qe-6.0.1
ReporterHans Knöchel
AssigneeChee Kiat Ng
Created2016-06-13T23:01:55.000+0000
Updated2016-12-21T19:59:12.000+0000

Description

iOS 10 finally exposed SiriKit, the public framework to interact with Siri. It allows the developer to send requests to Siri in order to fetch information from the following services: - Audio or video calling - Messaging - Payments - Searching photos - Workouts - Ride booking Docs: https://developer.apple.com/library/prerelease/content/documentation/Intents/Conceptual/SiriIntegrationGuide/index.html We should expose it as ti.siri with Hyperloop to access the Intents and IntentsUI framework. The big problem to solve here is, that Siri needs to be implemented inside a new target, which currently is only supported by creating a native target manually.

Attachments

FileDateSize
IMG_0177.PNG2016-11-30T17:56:36.000+00001719310
IMG_0178.PNG2016-11-30T17:56:42.000+0000355690
IMG_0179.png2016-11-30T17:56:41.000+0000642785
IMG_0180.png2016-11-30T17:56:40.000+0000704298
sirikit-sample-app.zip2016-11-30T17:59:53.000+00002580207

Comments

  1. Carlos Henrique Zinato 2016-07-13

    That would be awesome! What is a target @hans? Thanks
  2. Hans Knöchel 2016-07-13

    [~chmiiller] A target is configured as part of an Xcode project. Currently, we have one target that represents the (universal) iOS application. Having support for watchOS apps, we can link native targets (aka extensions) to the Titanium application. So in order to support this, we need both some CLI adjustments as well as the receiver in the Titanium application. That's why I did not set a "Release Version" yet.
  3. Hans Knöchel 2016-11-30

    Hey guys, I was able to create a (basic) proof of concept to use Siri to send Messages via the INSendMessageIntent (it's one of the above intents). Following the steps in TIMOB-17335, I did the following: 1. Create a native Titanium App with appc new 2. The name of the example is TestApp, the in tiapp.xml will be something like com.appc.testapp 3. Open Xcode and create new project File->New Project->Other->Empty 4. Name it TestApp 4. Use File->New->Target->Application Extension->Intents Extension to create the target. By default, Xcode will add some demo code to handle Message Intents, but you can use whatever you want there. 5. Name it TestApp and change Organization Identifier to com.appc.testapp so that the Bundle Identifier is com.appc.testapp.testapp - You can also suffix it to something like siriextension, but this is more simple for now 6. If you wish, you can activate scheme when prompted, it doesn't matter. 7. Create folder extensions in Titanium Project (root) folder and copy the Xcode extension project into it. 8. In tiapp.xml, include these properties in section:
       <extensions>
           <extension projectPath="extensions/TestApp/TestApp.xcodeproj">
               <target name="testapp"> <!-- or "siriextension" if you name the target differently -->
                   <provisioning-profiles>
                       <device/>
                       <dist-appstore/>
                       <dist-adhoc/>
                   </provisioning-profiles>
               </target>
           </extension>
       </extensions>
       
    10. Create or edit your App-ID to include the "Siri" capabilities, just like you would do with "Access Groups" or "Push Notifications" in the iOS dev-center 11. Create one app without a wildcard and one with a wildcard (e.g. com.appc.testapp.* and com.appc.testapp). The first one is linked in the provisioning profiles section of the target (<provisioning-profiles>), the latter one is used to build the main target / your app. 12. Add the following to the ios-plist-section of your tiapp.xml (<tiapp> -> <ios> -> <plist>):
       <key>NSSiriUsageDescription</key>
       <string>Can we use Siri to do great stuff?</string>
       
    13. Create a file called TestApp.entitlements in your Titanium project root (Note: if you also use push-entitlements, copy those keys over there as well, since it will override the CLI-generated one) and paste the following into it:
       <?xml version="1.0" encoding="UTF-8"?>
       <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
       <plist version="1.0">
       <dict>
           <key>com.apple.developer.siri</key>
           <true/>
       </dict>
       </plist>
       
    14. You made it!! Use appc run -p ios -T device or Appcelerator Studio to run your app on the device - SiriKit does not work on the Simulator You can test the changes by talking to Siri: {quote}Send a Message with TestApp{quote} It will know that your app uses the Intent Extension for handling messages and will ask you for Siri permissions by displaying the message you specified in your plist. You can also specify multiple intents of course, just create another target and link it the same way as above. And finally, use Hyperloop or a native module to handle the Intent's responses. Since there dozens of classes and delegates to implement here, you should look for the ones your Intent uses and it will be notified by your extension. We may also release a Hyperloop sample app for this, covering a specific Intent use-case, but that's how you can already start using SiriKit today! I also attached some images from my test-app will the app itself as well. Code strong! *EDIT*: Also made a new guide "[Creating iOS Extensions: Siri Intents](https://wiki.appcelerator.org/display/guides2/Creating+iOS+Extensions%3A+Siri+Intents)" with screenshots and more details. Thanks guys!
  4. Brenton House 2016-11-30

    Awesome [~hansknoechel]!!!
  5. Harry Bryant 2016-12-21

    Validated, successfully created a titanium app with support for SiriKit, following the guide provided above. Tested On: iPhone 6 Plus 10.1.2 Device Mac OS Sierra (10.12.2) Ti SDK: 6.0.1.v20161219165108 Appc Studio: 4.8.0.201611121409 Appc NPM: 4.2.8 App CLI: 6.0.0 Xcode 8.2.1 Node v4.4.7 *Closing ticket.*

JSON Source