0

I created siri extension include UI, because the way that open my app via url scheme only works in UI extension but not in siri extension. Like this:

func configure(with interaction: INInteraction!, context: INUIHostedViewContext, completion: ((CGSize) -> Void)!) {
    // Do configuration here, including preparing views and calculating a desired size for presentation.
    let finIntent = interaction.intent as? INSendMessageIntent
    if finIntent?.content != nil{
        open(scheme: "fin://ju/"+(finIntent?.content)!)
    }
    else{
        open(scheme: "fin://ju/open")
    }

    if let completion = completion {
        completion(self.desiredSize)
    }
}
func open(scheme: String) {
    if let url = URL(string: scheme) {
        if #available(iOS 10, *) {
            UIApplication.shared.open(url, options: [:],
                                      completionHandler: {
                                        (success) in
                                        print("Open \(scheme): \(success)")
            })
        } else {
            let success = UIApplication.shared.openURL(url)
        }
    }
}

It works but next time when open siri , it will automatically load extension UI and call this configure method again so will open my app again without parameters. I think maybe this is because the UI extension didn't get user action so I need to close it after open my app programmatically. But anyone knows how to do it ? Thanks !

  • Are you sure this is the correct way of doing this? You shouldn't open your app by yourself. Especially by UI Extension's configure method – qwerty Apr 12 '17 at 08:32
  • I am not sure and can you please teach me the right way, thanks ! – user1247306 Jun 28 '17 at 09:29
  • You shouldn't open your application from UI extension. Siri Extension's https://developer.apple.com/documentation/sirikit/insendmessageintenthandling/1639338-handle method will open the application automatically. You should prepare your parameterse inside that method – qwerty Jul 11 '17 at 08:44

0 Answers0