[TIMOB-26312] iOS 12 : Expose new NSUserActivity APIs for Siri Intents
| GitHub Issue | n/a |
|---|---|
| Type | New Feature |
| Priority | None |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2018-08-28T15:52:18.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 7.4.0 |
| Components | iOS |
| Labels | n/a |
| Reporter | Vijay Singh |
| Assignee | Vijay Singh |
| Created | 2018-08-17T08:35:05.000+0000 |
| Updated | 2018-08-31T13:21:30.000+0000 |
Description
In iOS 12, Apple has given some new APIs in
NSUserActivity. These APIs can be used for Siri shortcut supports as well. It will be good to expose these APIs to developers.
PR (Master) - https://github.com/appcelerator/titanium_mobile/pull/10288 PR (7_4_X) - https://github.com/appcelerator/titanium_mobile/pull/10292 Test Case -
var win = Ti.UI.createWindow({ backgroundColor: '#fff' }); var identifierBtn = Ti.UI.createButton({ top: 100, title: 'Persistent Identifier' }); var btn = Ti.UI.createButton({ top: 200, title: 'Delete UserActivity for identifier' }); var deleteBtn = Ti.UI.createButton({ top: 300, title: 'Delete All UserActivity' }); 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.appcelerator.titanium', title: 'Siri shortcut activity', userInfo: { msg: 'hello world' }, 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.appcelerator.titanium' && e.userInfo.msg) { alert(e.userInfo.msg); } }); } activity.addEventListener('useractivitydeleted', function(e) { Ti.API.info('useractivitydeleted called'); alert('user activity deleted'); }); btn.addEventListener('click', function() { activity.deleteSavedUserActivitiesForPersistentIdentifiers(['titanium_siri_identifier']); }); identifierBtn.addEventListener('click', function() { Ti.API.info('persistent identfier is: ' +activity.persistentIdentifier); Ti.API.info('\neligibleForPrediction is: ' +activity.eligibleForPrediction); }); deleteBtn.addEventListener('click', function() { activity.deleteAllSavedUserActivities(); }); win.add(identifierBtn); win.add(btn); win.add(deleteBtn); win.open();*Closing ticket.* Verified fix in SDK version:
7.4.0.v20180829013317and SDK Version:7.5.0.v20180829030547Able to use Siri shortcuts to trigger a User Activity in a application. *FR Passed (Test Steps):*Created a new Titanium application
Added the code above in to the application
Installed app on to the device
On the device I went to the following location
Settings/Siri & Search/Found the application I just created
Pressed the
+button to create a User Activity (Application is set up for a hello world test)Recorded a phrase for the available activity ('One' was used)
Launched Siri and said
OneSiri was able to launch the user Activity in the application ('Hello world' popup was seen)
*Environment*