Last active
February 12, 2019 04:05
-
-
Save ewieberappc/267dc348a714f0c58a950b2b8e9e4cfc to your computer and use it in GitHub Desktop.
Shortcuts in iOS 12 give Siri the hooks to incorporate deep app features into your Shortcut workflows. Here is an example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win = Ti.UI.createWindow({ | |
backgroundColor: '#fff' | |
}); | |
var lbl = Ti.UI.createLabel({ | |
top: 150, | |
text: "I am waiting to do something." | |
}); | |
var itemAttr = Ti.App.iOS.createSearchableItemAttributeSet({ | |
itemContentType: Ti.App.iOS.UTTYPE_IMAGE, | |
title: 'Titanium Siri Shortcut Tutorial', | |
contentDescription: 'Tech Example \nOn: ' + (new Date().toLocaleString()), | |
}); | |
var activity = Ti.App.iOS.createUserActivity({ | |
activityType: "com.appc.shortcut", | |
title: 'Siri shortcut activity', | |
userInfo: { | |
msg: 'I did something!' | |
}, | |
eligibleForSearch: true, | |
eligibleForPrediction: true, | |
persistentIdentifier: 'titanium_siri_identifier' | |
}); | |
activity.addContentAttributeSet(itemAttr); | |
if (!activity.isSupported()) { | |
alert('User Activities are not supported on this device!'); | |
} else { | |
activity.becomeCurrent(); | |
Ti.App.iOS.addEventListener('continueactivity', function(e) { | |
Ti.API.info('continueactivity called'); | |
if (e.activityType === "com.appc.shortcut" && e.userInfo.msg) { | |
alert(e.userInfo.msg); | |
} | |
}); | |
} | |
win.add(lbl); | |
win.open(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shortcuts in iOS 12 give Siri the hooks to incorporate deep app features into your Shortcut workflows. Here is an example. | |
1. Make sure you configure your tiapp.xml | |
2. You can then create a shortcut in Settings -> Siri & Search to perform an action in your app. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ios> | |
<plist> | |
<dict> | |
<key>NSUserActivityTypes</key> | |
<array> | |
<string>com.appc.shortcut</string> | |
</array> | |
</dict> | |
</plist> | |
</ios> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment