Can't handle Siri messages in core/main application

Hi,


I am trying to integrate Siri with my existing core application, but currently have trouble handling message intent in core application - actually the handler methods are not called after Siri says "Ok, it's sent".


Neither:

===

- (void)application:(UIApplication *)application handleIntent:(INIntent *)intent completionHandler:(void(^)(INIntentResponse *intentResponse))completionHandler NS_AVAILABLE_IOS(11_0)

{}

===


Nor:

===

- (BOOL)application:(UIApplication*)application continueUserActivity:(NSUserActivity*)userActivity restorationHandler:(void (^)(NSArray* restorableObjects))restorationHandler

{}

===


Here is the IntentHandler for sendMessage I am using:

===

- (void)handleSendMessage:(INSendMessageIntent *)intent completion:(void (^)(INSendMessageIntentResponse *response))completion {

// Implement your application logic to send a message here.

NSUserActivity *userActivity = [[NSUserActivity alloc] initWithActivityType:NSStringFromClass([INSendMessageIntent class])];

INSendMessageIntentResponse *response = [[INSendMessageIntentResponse alloc] initWithCode:INSendMessageIntentResponseCodeSuccess userActivity:userActivity];

completion(response);}

===


Has anyone experienced such behavior, or knows how to resolve this problem ? I need to catch the Siri message in main application and process it appropriately.


Note, that:

1) Siri capability is enabled for both main app/Siri extension app in developer portal.

2) All required intents are included in info.plist file.

3) Added "com.apple.developer.siri" in entitlements file.

4) All (for both main app and Siri extension app) provisioning profiles are generated/used as expected.


Any help would be highly appreciated. Thanks in advance.

Your app is expected to handle sending the message through your service from the intents extension. `application:handleIntent:completionHandler:` is only used by intents in the workout and media domains. `application:continueUserActivity:restorationHandler` is used when a user tries to continue in the main app by tapping on a custom UI in Siri, or if you have errors (like not being logged in) that can't be handled within Siri.


You mention you need to process the message in your application - what are you trying to do in the main application that you can't do from the intents extension?

Thanks for your answer.


I am trying to send the Siri message through my application (which is like chat messenger). Actually I expected that Siri would pass the handling to main application when everything goes successfully in intentHandler - i.e. when returning response with success code. Isn't my expectation correct ?


So, you are suggesting to send a message directly from the Siri intent extension (and not from the app) ?


Just to be sure - it isn't possible to pass the handling to main app (automatically) when using message intent without tapping on message intent UI in Siri ?

At the time you return the success response from the handle method in your intent handler, you should have sent the message. The main app only comes into the picture for exceptional conditions that need deeper user interaction to resolve, such as the user not being logged in.


If you haven't seen the introductory videos on SiriKit yet, check out the SiriKit content from WWDC 2016 to understand how interactions with messaging are intended to work.

Can't handle Siri messages in core/main application
 
 
Q