Thanks for your suggestion, but I am still stumped. It's a little difficult to compare since my code is objective C, but as near as I can tell my code is functionally the same. I have a table view controller in which I am creating a NSUserActivity similar to the sample code project. What surprises me about the sample code project is that there is no where in the code where a call is made to activity.becomeCurrent(). My read on the documentation (even the README in the sample code project is that this is necessary to register the activity with the system.
Is there more to this than the code (from sample code project) private func configureUserActivity() of the LocationViewController? This is what I have implemented. This is what the tutorials all suggest is all you need to do. But there must be something else that I am missing.
Is there something in the build configuration or settings that I need to activate? I am also including NSUserActivityTypes in my info.plist that correspond to the 2 activities I am trying to create shortcuts for. Is there something else needed in the info.plist?
Any suggestions would be appreciated.
Post
Replies
Boosts
Views
Activity
@ricob I have done this. The problem is that the handlerForIntent is not being called (neither are any of the resolve, confirm, or handle methods). The only thing that is being called is the application:continueUserActivity:restorationHandler in my app delegate. The userActivity being called is my customIntent. What might be the reason that the handlerForIntent is not being called? According to the discussion in the documentation for application:continueUserActivity:restorationHandler: (under Handling Activities from SiriKit), the
"Intents may launch your app under the following circumstances:
Some intents always launch the app after the intent is successfully handled (for example, intents with a continueInApp response code).
Your intent's handle and confirm methods launch the app when you resolve the intent with a failureRequiringAppLaunch (or similar) response code."
But I have breakpoints set in the handlerForIntents and each of the resolve, confirm, and handle methods. Is there some other entry point I should look for?
@edford - Thanks for your reply. You are absolutely correct about the error you found. However, I am so disappointed that I input an out of date implementation in my problem statement. After working through the SoupChef code, I had previously seen error you described and updated my code to remove the line of code you mentioned where an NSUserActivity is used to create a parts list shortcut. Then I replaced the INShortcut *shortcut line with the following:
CreatePartsListIntent *intentWithData = [[WoodPickerDonationManager sharedInstance] prepareCreatePartsListIntent : @"" withNumberOfAssemblies : 1];
INShortcut *shortcut = [[INShortcut alloc] initWithIntent:intentWithData];
The call to prepareCreatePartsListIntent does the following:
`-(CreatePartsListIntent *) prepareCreatePartsListIntent : (NSString *) partsListName withNumberOfAssemblies : (NSInteger) quantity {
CreatePartsListIntent *intentWithData = [[CreatePartsListIntent alloc] init];
intentWithData.projectName = partsListName;
intentWithData.quantity = [NSNumber numberWithInteger: quantity];
intentWithData.suggestedInvocationPhrase = @"Create Parts List";
return intentWithData;
}`
Sadly, even with this change, the intentHandler in my Intents Extension is not called. In your answer, you indicated that if I switch my implementation to using an intent, that my intentHandler in the app delegate will be called. That confuses me. Is there supposed to be an intentHandler in the app delegate in addition to the Intents Extension? Is there any thing else you see that might be wrong?