This following tutorial will guide you through the process of creating a new iOS extension and in this case also shows you how to configure your app to communicate with Siri using the Intents framework. This framework is different to some other extensions as it requires special capabilities, provisioning profiles, and privacy-permissions. This document will show you how to do that as well.
The repository for this tutorial can be found open-source on Github .
- Create a native Titanium App with
appc new -p ios,using Appcelerator Studio, or use your existing project.
- The name of the example is TestApp, the
<id>in tiapp.xml will be something like
- Open Xcode and create new project:
- Name it
TestAppfor this tutorial.
File/New/Target/Application Extension/Intents Extensionto create the extension target. By default, Xcode will add some demo code to handle Message Intents, but you can implement whatever Intent extension you want here.
- Name the extension
testappand change the "Organization Identifier" to
com.appc.testappso that the "Bundle Identifier" is
com.appc.testapp.testapp- You can also suffix it to something like
siriextension, but let's keeps it simple for now.
- If you wish, you can activate scheme when prompted, but it doesn't matter because we won't need to open the standalone Xcode-project while building.
- Create a folder called
extensionsin the Titanium project (root) folder and copy the Xcode extension project into it.
tiapp.xml, include the following properties in the
<ios>section of it:
- Create or edit your App-ID in the iOS Developer Center to include the "SiriKit" capability, just like you would do with "Access Groups" or "Push Notifications" for other platform-services. Create one app with a wildcard identifier and one without (e.g.
com.appc.testapp). The first one is linked in the
<provisioning-profiles>section of the target, the latter one is used to build the main target (your app) to the device. Note that SiriKit is supported in the Simulator by Apple, because it doesn't support Siri so far (Status: iOS 10 / November 2016).
- Generate two provisioning profiles (one for your main app and one for the Siri target) in the "Provisioning Profiles" section.
Add the following to the plist-section of your
Create a file called
TestApp.entitlementsin 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 key and paste the following into it:
You made it!! Use
appc run -p ios -T deviceor Appcelerator Studio to run your app on the device. Remember that iOS currently does not support Siri on the Simulator.
You can test the changes by talking to Siri:
Send a Message with TestApp
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 change the UI of the Intent by changing the storyboard in your "testappUI" target or specify multiple intents. Just create another target and link it the same way as we did 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. This guide may be updated with some samples for that as well, but you can also check some of the existing guides for that: