iOS

To test your code and see a preview of the card on an iOS device, use the DivKit Playground app. You can add the card code in JSON format to the app or open a link to it:

  1. Download the DivKit Playground source files from the repository, compile and install the app on the device.

  2. Select demo.

  3. Add a card using one of the following methods:

    • Insert the code in JSON format or a link to the card prototype in the input field.
    • Open the link from the DivKit Web Playground editor.

    Tip

    To create a card code, you can use the DivKit Web Playground sample library.

  4. To view the result, click show the result.

Enhanced Action Reporting

DivKit iOS now provides enhanced context for action reporting through a new method in the DivReporter protocol:

func reportAction(context: DivActionHandlingContext)

New Features

  • Enhanced Context: Access to additional information about card state and variables
  • Public Structure: DivActionHandlingContext is now available for custom implementations
  • Backward Compatibility: The old method reportAction(cardId:info:) continues to work

Usage Example

class CustomReporter: DivReporter {
    func reportAction(context: DivActionHandlingContext) {
        // Access to extended context
        let cardId = context.cardId
        let info = context.info
        let resolver = context.expressionResolver
        
        // Your reporting logic
        print("Action reported for card: \(cardId)")
    }
}

Backward Compatibility

Existing DivReporter implementations continue to work without changes thanks to the default implementation of the new method.

Learn more

You can discuss topics of interest in the DivKit user community in Telegram: https://t.me/divkit_community_en.

DivKit Repository