Overview
To simplify your application logic and integration with the Knot React Native SDK, Version 1.0 includes a number of breaking changes that may affect the way your integration works or behaves. The new version includes a number of significant improvements:- Enhanced speed and stability in loading merchant flows.
- More streamlined initialization of the SDK.
- Simplified event handling, more informative event messaging, and uniform naming conventions for easier debugging.
- Improved maintainability and foundations for new feature compatibility.
Breaking Changes
Configuring and opening a Knot SDK has changed significantly in React Native Version 1.0 and will requires some refactoring in order to initialize the SDK with a session, receive (KnotEvent) events, and handle errors. Errors are now encapsulated in a KnotError object which provides an enumerated value to debug with.
Session Initialization
ChangesopenCardOnFileSwitcher,addCardSwitcherListener, andeventNamesfrom “react-native-knotapi” are replaced withKnotandaddKnotListener.- The new interface allows configuration of additional properties such as
useCategories,useSearch, andmerchantIds. - The
openaction now requires configuration values that are required to initialize with a session.
Event Handling
Changes- Event handling is now managed through
addKnotListenerinstead of closures. - Events like
onSuccess,onError, andonExitare now product agnostic. - The
onEventmethod introduces theKnotEventobject to better handle Knot emitted events. - The
KnotErrortype provides improved error descriptions. - The
sendCardparameter is deprecated and its functionality incorporated into themetaDatadictionary withinKnotEventwhenKnotEvent.eventequalsAUTHENTICATED.
JavaScript
sendCard parameter has been deprecated and its functionality has been incorporated into the metaData dictionary within KnotEvent when the KnotEvent.event equals AUTHENTICATED. This change enhances flexibility by allowing additional contextual data to be included in events without requiring separate parameters. Previously, sendCard was accessed as a standalone value, but now developers can retrieve it from the metaData dictionary in the event callback. This approach ensures better extensibility and consistency across different event types. To access the sendCard value, simply extract it from the event’s metaData dictionary.
Error Handling
Error handling has been improved with more structured and meaningful error messages. Changes- Errors are now encapsulated in the
KnotErrorenum. - Each error has a human-readable description (
errorDescription) and a unique error code (errorCode). - Improved clarity and consistency across error messages.
JavaScript
JavaScript
Closing the SDK
Changes- Closing the SDK is now statically accessed via
Knot.close()as opposed to being bound to the session object.
JavaScript
JavaScript