Can SiriKit pass the INSendPaymentIntent to my app? The intent has to be handled by my app, instead of in the Siri extension. But the INSendPaymentIntentResponse does not have the .continueInApp like INStartAudioCallIntentResponseCode. There is .failureRequiringAppLaunch, but that behavior is not the preferred one. Have any idea? How to pass object to my app ?
In IntentHandler Extension, there is a handle method which works when user clicks "Send" button in Siri UI Extension. (Swift 3, iOS 10 and 11)
class IntentHandler: INExtension, INSendPaymentIntentHandling {
func handle(intent: INSendPaymentIntent, completion: @escaping (INSendPaymentIntentResponse) -> Void) {
if let _ = intent.payee, let currencyAmount = intent.currencyAmount {
// Handle the payment here!
// Create a user activity to pass it to our application
let userActivity = NSUserActivity(activityType:"myActivityName")
// Pass parameter dictionary to the userinfo
userActivity.userInfo = ["amount": Int(truncating: currencyAmount.amount!)]
// By providing a userActivity to the intent response, Siri will open up the app and continue the payment there
completion(INSendPaymentIntentResponse.init(code: .inProgress, userActivity: userActivity))
}
}
}
After that continueUserActivity is called in our application
-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
{
// Parse userActivity.userInfo parameter to get the amount etc.
return YES;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With