Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26312] iOS 12 : Expose new NSUserActivity APIs for Siri Intents

GitHub Issuen/a
TypeNew Feature
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2018-08-28T15:52:18.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.4.0
ComponentsiOS
Labelsn/a
ReporterVijay Singh
AssigneeVijay Singh
Created2018-08-17T08:35:05.000+0000
Updated2018-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.

Comments

  1. Vijay Singh 2018-08-26

    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();
       
  2. Samir Mohammed 2018-08-31

    *Closing ticket.* Verified fix in SDK version: 7.4.0.v20180829013317 and SDK Version: 7.5.0.v20180829030547 Able 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 One

    Siri was able to launch the user Activity in the application ('Hello world' popup was seen)

    *Environment*
       APPC Studio:  5.1.0.201808080937
       APPC CLI: 7.0.6
       iphone 6 (12.0)
       Operating System Name: Mac OS High Sierra
       Operating System Version: 10.13.6
       Node.js Version: 8.9.1
       Xcode 10.0 beta 6
       

JSON Source