persistentIdentifier not saved for Siri Shortcuts using NSUserActivity

Number:rdar://45809778 Date Originated:11/5/18
Status:Open Resolved:
Product:iOS + SDK Product Version:12.1
Classification:Serious Bug Reproducible:Always
I'm adding Siri Shortcuts to my app using INUIAddVoiceShortcutViewController and things are working fine, except when I try to delete a shortcut using NSUserActivity.deleteSavedUserActivities(withPersistentIdentifiers:)

I verified the persistentIdentifier is not being saved for the NSUserActivity. Below is the code that I used to create the NSUserActivity:
func createUserActivityForShortcut(workoutName: String, timerID: String) -> NSUserActivity? {  

    let userActivity = NSUserActivity(activityType: "com.fourthframe.intervals.start-timer")  
    userActivity.isEligibleForSearch = true  

    userActivity.isEligibleForPrediction = true  
    userActivity.suggestedInvocationPhrase = "Start \(workoutName)"  

    userActivity.title = "Start \(workoutName)"  
    userActivity.userInfo = ["timerID": timerID]  
    userActivity.persistentIdentifier = timerID  
    userActivity.needsSave = true  
    userActivity.requiredUserInfoKeys = ["timerID"]  

    return userActivity  


Steps to Reproduce:
1) Create NSUserActivity
2) Add a voice shortcut using INUIAddVoiceShortcutViewController
3) Retrieve list of voice shortcuts using INVoiceShortcutCenter.shared.getAllVoiceShortcuts
4) Verify that voiceShortcut.shortcut.userActivity?.persistentIdentifier is nil

Expected Results:
voiceShortcut.shortcut.userActivity?.persistentIdentifier is not nil

Actual Results:
voiceShortcut.shortcut.userActivity?.persistentIdentifier is nil

iOS 12.1

I’ve had others on stackoverflow and dev forum confirm this behavior



Verified and Duplicated

Can verify that this still occurs on iOS 13. Duplicated & reported in Feedback Assistant:

By spencer.samuel1 at May 27, 2020, 9:11 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!