To simplify your application logic and integration with the Knot Android SDK, Version 2.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.
Configuring and opening the Knot SDK has changed significantly in Android Version 2.0 and requires some refactoring in order to initialize the SDK with a session. Errors are now encapsulated in a KnotError object which provides an enumerated value to debug with.
CardOnFileSwitcher.getInstance(); and Configuration(environment, clientId, sessionId); are replaced with a more flexible KnotConfiguration.
The new interface allows configuration of additional properties such as useCategories, useSearch, and merchantIds.
The open action now requires a KnotConfiguration and an optional KnotEventDelegate which is now Knot.open(context, knotConfiguration, knotEventDelegate).
Event handling is now managed through KnotEventDelegate instead of closures.
Events like onSuccess, onError, and onExit are now explicit methods inside a delegate.
The onEvent method introduces the KnotEvent object to better handle Knot emitted events.
The KnotError type provides improved error descriptions.
The sendCard parameter is deprecated and its functionality incorporated into the metaData dictionary within KnotEvent when KnotEvent.event equals AUTHENTICATED.
KnotEventDelegate knotEventDelegate = new KnotEventDelegate() { @Override public void onSuccess(String merchant) { // Handle successful operation } @Override public void onError(KnotError knotError) { // Handle error operation using knotError } @Override public void onExit() { // Handle SDK exit event } @Override public void onEvent(KnotEvent knotEvent) { // Extract and process event details from KnotEvent }};
val eventDelegate = object : KnotEventDelegate { override fun onSuccess(merchant: String) { // Handle successful operation } override fun onError(knotError: KnotError) { // Handle error operation using knotError } override fun onExit() { // Handle SDK exit event } override fun onEvent(knotEvent: KnotEvent) { // Extract and process event details from KnotEvent }}
SendCard
Most apps do not use the explicit sendCard method, as it is rarely applicable to the integration with the Knot SDK.
The sendCard parameter has been deprecated and its functionality is incorporated into the metaData object 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 you can retrieve it from the metaData object 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 object.
@Overridepublic void onEvent(KnotEvent knotEvent) { // Extract the metadata map from the KnotEvent Map<String, Object> metaData = knotEvent.getMetaData(); // Check if the metadata contains a sendCard flag if (knotEvent.getEvent().equalsIgnoreCase("AUTHENTICATED") && metaData != null && metaData.containsKey("sendCard")) { Boolean sendCard = (Boolean) metaData.get("sendCard"); Log.d("KnotEvent", "sendCard: " + sendCard); } }
override fun onEvent(knotEvent: KnotEvent) { val metaData = knotEvent.metaData if (knotEvent.event.equals("AUTHENTICATED", ignoreCase = true) && metaData != null && metaData.containsKey("sendCard")) { val sendCard = metaData["sendCard"] as? Boolean Log.d("KnotEvent", "sendCard: $sendCard") }}
Event NamesThe SDK now maps raw event names to standardized event names for easier handling.