Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SiriKit extension not called

I'm using a test app and extension to attempt a SiriKit exorcism. My extension isn't being called at all and I can't figure out why. I have had a working SiriKit extension in a different app, which has inexplicably stopped responding - hence this test app.

Here's what I've done to set up SiriKit in the test app:

1) Added Siri entitlement to app target: enter image description here

2) Added Siri usage description to the app's info.plist: enter image description here

3)Added a new Intents Extension test target, and added my desired Intent to the extension info.plist: enter image description here

4) Wired up the IntentHandler class:

class IntentHandler: INExtension {
override func handler(for intent: INIntent) -> Any {
    print("IntentHandler.handle")
    switch intent {
        case is INAddTasksIntent: return AddIntentHandler()
        default: break
    }
    return self
}
}

5) Created my handler class:

class AddIntentHandler: NSObject, INAddTasksIntentHandling {
func handle(intent: INAddTasksIntent, completion: @escaping (INAddTasksIntentResponse) -> Void) {
    print("AddIntentHandler.handle")
    return completion(INAddTasksIntentResponse(code: .success, userActivity: nil))
}
}

6) In AppDelegate get permission to use Siri:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    INPreferences.requestSiriAuthorization({ status in
        if status == .authorized {
            print("Ok - authorized")
        }
    })
    return true
}

7) Added an AppIntentVocabulary.plist file to the app (I also tested adding it to the extension instead): enter image description here

8) I double-checked that the extension is embedded in the app target: enter image description here

9) And that the extension target shows the correct supported intent: enter image description here

10) Double checked that the app and extension targets require at least iOS version 13.2 in the target deployment info area: enter image description here

11) I then install the app on an iPhone running iOS 13.3, give Siri permission after it launches, and try to add bacon using Siri. It doesn't call my extension at all, and adds it to the built in reminders app.

12) I launch the extension directly from XCode on the device, same deal - my extension is never called.

I understand it can take a while to register Siri language, but I've been messing with this for days: enter image description here

Not sure it is related, but like I said I have had Siri working in a different app - not deployed to the app store. I took some time to work on other features in the app and have come back to Siri integration now, only to find out it isn't responding any more. I've rolled back to my last known commit with Siri working only to find it now doesn't work in that (known good) commit either.

Help! I've lost days to this! What is going on or what did I miss?!

like image 700
Brian M Avatar asked Dec 12 '19 15:12

Brian M


People also ask

How do I add SiriKit?

Choose File > New > File to add a new SiriKit Intent Definition File to your Xcode project. Make sure that you select your app target.

What is Intents Extension?

In iOS 14 you can use intents to add configuration and intelligence to widgets. An Intents UI app extension displays custom UI in the Siri shortcuts or maps interface. An Intents app extension receives user requests from surrogate and turns them into app specific actions such as sending the message.

What can SiriKit do?

SiriKit allows an iOS app to provide services that are accessible to the user using Siri and the Maps app on an iOS device using App Extensions and the new Intents and Intents UI frameworks. Siri works with the concept of Domains, groups of know actions for related tasks.

What is Intent in iOS?

IntentKit is an open-source iOS library that makes it easier to link to other apps.


1 Answers

So after all that it turns out the problem is 100% the language I'm trying to use to invoke my app extension.

Who knew this won't work, "Appname, add bacon to the list", but this will: "Add bacon to the list in AppName". If you lead with the app name, Reminders captures it and puts it in a reminders list.

I'll start a new question about triggering Intents. Sorry for the confusion.

like image 158
Brian M Avatar answered Oct 01 '22 03:10

Brian M