I am implementing a couple custom intents in my app. Having completed the implementation of the custom intent definitions and the intent handlers which presumably should be called on voice command based on the suggestedInovocationPhrase, I am getting stumped with just getting IOS to recognize my shortcut donation. While the shortcut donation is executed multiple times from the view that I am trying to create the shortcut for, it is never being displayed in the shortcut app or on my lock screen as having been donated. In my settings App, I have turned on (under Developer) "Display Recent Shortcuts" and "Display Donations on Lock Screen". Here is the code that is executing each time I think I am making a donation:
- (NSUserActivity *) CreateMyShortcut {
NSUserActivity *newActivity = [[NSUserActivity alloc] initWithActivityType: kMyShortCutActivityType];
if (@available(iOS 12.0, *)) {
newActivity.persistentIdentifier = kMyShortCutActivityType;
newActivity.eligibleForSearch = TRUE;
newActivity.eligibleForPrediction = TRUE;
CSSearchableItemAttributeSet *attributeSet = [[CSSearchableItemAttributeSet alloc] initWithContentType: UTTypeImage];
newActivity.title = @"My Shortcut";
attributeSet.contentDescription = @"description";
newActivity.suggestedInvocationPhrase = @"Create Widget";
UIImage *image = [UIImage imageNamed:@"MyApp_Icon.jpg"];
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)];
attributeSet.thumbnailData = imageData;
newActivity.contentAttributeSet = attributeSet;
}
return newActivity;
}
This is called from the view that I want to create the shortcut for with the following code:
// Donate a shortcut to allow Siri to assist with creating a parts list
NSUserActivity *activity = [[MyDonationManager sharedInstance] CreateMyShortcut];
NSLog(@"Donating Siri Shortcut");
[activity becomeCurrent];
Is there something else I need to do?