How chaymankala/cordova-plugin-ttlock works
Main Components
• Cordova Integration Layer – this is the heart of the plugin and is defined by the plugin.xml and package.json files. It serves as the configuration and entry point for incorporating native functionalities in the web-based Cordova app.
• Android Native Module – located in “src/android”, this includes Java files (like TTLockPlugin.java and ChannelCreator.java) and embedded dependency libraries (e.g., gson-2.8.6.jar). This module wraps the TTLock functionalities for Android.
• iOS Native Module – contained in “src/ios”, this includes Objective-C files (e.g., TTLockPlugin.m, TTLockPlugin.h, and modifications in AppDelegate) and the linked frameworks (TTLock.framework and TTLockGateway.framework). This module wraps the TTLock functionalities for iOS.
• Browser/Development Fallback – found in “src/browser” (with the ttlock.coffee file) which may provide simulated functionality or debugging support when not on a native mobile platform.
• Web Assets / JavaScript Bridge – contained in “www” (ttlock.js), which acts as the primary interface for a Cordova app to call the underlying native SDK functionalities.
– TTLockPlugin.java (the bridge itself)
– ChannelCreator.java (possibly managing multi-channel integration)
– External dependency “gson-2.8.6.jar” for JSON operations.
– TTLockPlugin.m/h files and AppDelegate modifications.
– TTLock.framework and TTLockGateway.framework, showing their headers and internal structure.
Architectural Patterns and Integration Flow
• “bridge” design pattern: the plugin layer exposes a JavaScript interface (in www/ttlock.js) that calls into the native code via platform-specific channels.
• Separation of concerns: web (JavaScript) vs. platform-specific plugins (Android and iOS).
• The plugin.xml file is key – include a note that it defines the wiring between the Cordova application and the native modules.