iOS library

This renderer which targets iOS native controls.

Add a renderer

This is available as a pod.

 pod 'AdaptiveCards'

Add header

#import <AdaptiveCards/ACFramework.h>

Create a card from a JSON string

AdaptiveCard is generated from JSON string

ACOParseResult *cardParseResult = [ACOAdaptiveCards FromJson:jsonStr];
/// access for parse warnings and errors
NSArray<NSError *> errors = cardParseResult.parseErrors;
NSArray<ACRParseWarning *> warnings = cardPraseResult.parseWarnings;


Host can be configured through HostConfig which can be generated by JSON string

ACOParseResult *hostconfigParseResult = [ACOHostConfig FromJson:self.hostconfig];

Render a Card

Rederer takes adaptive card and host config. HostConfig can be nil, and if nil, default value will be used.

ACRRenderResult *renderResult;
renderResult = [ACRRenderer render:cardParseResult.card
                             frame:CGRectMake(20, 250, 300, 1250)];


ACRRenderResult *renderResult;
ACOHostConfigParseResult *hostconfigParseResult = [ACOHostConfig FromJson:self.hostconfig];
ACOAdaptiveCardsParseResult *cardParseResult       = [ACOAdaptiveCards FromJson:jsonStr];

// checking parse result
if(hostconfigParseResult.IsValid == YES && cardParseResult.IsValid == YES)
    renderResult = [ACRRenderer render:cardParseResult.card
                                 frame:CGRectMake(20, 250, 300, 1250)];

if(renderResult.Suceeded == YES)
    // returns a ViewController
    ACRViewController *adcVc = renderResult.viewcontroller;
    [self addChildViewController:adcVc];
    [self.view addSubview:adcVc.view];
    [adcVc didMoveToParentViewController:self];

Changing per element rendering

Developers can customize the look of renderred AdaptiveCards elements such as TextBlock. Following example shows how one can change background color of NumberInput.

ACRRegistration *registration = [ACRRegistration getInstance];
// register custom renderer with registration
// custom renderer must implement ACRIBaseCardElementRenderer protocol
// for more information, please refer to
 [registration setBaseCardElementRenderer:[CustomInputNumberRenderer getInstance] cardElementType:ACRNumberInput];
- (UIView *)render:(UIView<ACRIContentHoldingView> *)viewGroup
              rootViewController:(UIViewController *)vc
              inputs:(NSArray *)inputs
     baseCardElement:(ACOBaseCardElement *)acoElem
          hostConfig:(ACOHostConfig *)acoConfig
      ACRInputNumberRenderer *defaultRenderer = [ACRInputNumberRenderer getInstance];

      UIView *input = [defaultRenderer render:viewGroup
          // customize background color of input
          [input setBackgroundColor: [UIColor colorWithRed:1.0
      return input;

Additional Property

Developers can also send in additional properties as part of json payload. For example, in addition to "spacing" and "id" of json payload for BaseCardElement, one can add radius for corners of TextBlock to its json payload.

        NSData *additionalProperty = [acoElem additionalProperty];
         if(additionalProperty) {
             NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:additionalProperty options:NSJSONReadingMutableLeaves error:nil];
             radiusForMyTextBlock = dictionary[@"radius"];

Custom Parsing

Developers can also have custom parsing and have new UI element added to adpative card such as progress bar. Please check for detail. Custom parser must implement ACOIBaseCardElementParser protocol. deserializeToCustomElement method should parses given json payload given as NSData and return a pointer to UIView object that will be added to AdaptiveCard rendered object.

      CustomProgressBarRenderer *progressBarRenderer = [[CustomProgressBarRenderer alloc] init];
      [registration setCustomElementParser:progressBarRenderer];

Action Handling

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 AdaptiveCard instance
adcVc.acrActionDelegate = self;