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:
-
Download the DivKit Playground source files from the repository, compile and install the app on the device.
-
Select demo.
-
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.
-
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:
DivActionHandlingContextis 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.