アクション-iOSActions - iOS
開発者は、ACRActionDelegate を実装することによって、SubmitAction や OpenUrl などのアクションを受信し、AdaptiveCard のインスタンスに設定できます。Developers can receive actions such SubmitAction and OpenUrl by implementing ACRActionDelegate, and set it to instance of AdaptiveCard.
//// delegate implementation
- (void) didFetchUserResponses:(ACOAdaptiveCard *)card action:(ACOBaseActionElement *)action
{
if(action.type == ACROpenUrl){
NSURL *url = [NSURL URLWithString:[action url]];
SFSafariViewController *svc = [[SFSafariViewController alloc] initWithURL:url];
[self presentViewController:svc animated:YES completion:nil];
}
else if(action.type == ACRSubmit){
/// inputs can be examined by method inputs
NSData * userInputsAsJson = [card inputs];
NSString *str = [[NSString alloc] initWithData:userInputsAsJson encoding:NSUTF8StringEncoding];
NSLog(@"user response fetched: %@ with %@", str, [action data]);
}
}
/// register the delegate with ACRView instance
adaptiveView.acrActionDelegate = self;
/// if using ACRViewController, pass delegate as argument
ACRRenderResult *renderResult = [ACRRenderer renderAsViewController:card config:config frame:frame delegate:acrActionDelegate];