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 !