Common SDK Guide
Started
This is a guide on how to integrate the OneKey SDK for iOS, Android, and Flutter.
The following content requires you to have a basic understanding of NodeJS, Android, iOS, and Flutter.
Below are the links to the relevant demos.
JavaScript Runtime Environment
For iOS, there are two options for the JavaScript runtime environment:
JavaScriptCore, recommended by iOS, with relevant documentation available at Apple Developer Website.
The WebView approach.
In the demo, the WebView solution is used.
After determining the runtime environment, a communication solution with WebView is also needed. In the demo, WKWebViewJavascriptBridge is used for communication with the iOS native side.
Create JavaScript Code
Create a folder and use yarn init
to initialize a NodeJS project.
It's necessary to install both @noble/hashes
and ripple-keypairs
as these libraries are dependencies required by the OneKey SDK.
Create index.html
and index.js
and package the JavaScript code. Since only simple JavaScript packaging is needed, Parcel is chosen over WebPack due to its simplicity and lack of complex configuration.
For detailed configuration, you can refer to the web settings in the demo.
These steps will help set up the JavaScript environment and integrate the necessary SDK and dependencies for the OneKey integration on iOS and Android platforms.
Cnfigure the LowlevelPlugin
Next, configure the LowlevelPlugin. There is a document you can refer to for more information Read more>>>
To forward LowlevelPlugin
functionality to the Native side and return related results, follow these steps:
Define Interface: Define an interface in
LowlevelPlugin
for calling Native functionality.Implement Forwarding Mechanism:
Capture the calls in
LowlevelPlugin
that need to be forwarded.Forward the details of the call (such as method name, parameters, etc.) to the Native side.
Native Side Processing:
On the Native side, receive the request, parse the method name and parameters.
Execute the corresponding Native functionality.
Return Results:
Once the Native side has completed execution, return the results or error information back to
LowlevelPlugin
.LowlevelPlugin
then returns this information to the caller.
If unclear, you can refer to the related demos for guidance.
Connection Device
The provided pseudocode outlines the steps for handling Bluetooth communication within a WebView environment in an Android or iOS application. Here's a breakdown of the key components:
Bluetooth Parameters
serviceUuid
: 00000001-0000-1000-8000-00805f9b34fbwriteCharacteristic
: 00000002-0000-1000-8000-00805f9b34fbnotifyCharacteristic
: 00000003-0000-1000-8000-00805f9b34fb
Handling Bluetooth Scanning
Handling Bluetooth Connection
This method will be called each time an SDK method is invoked.
Listening to notifyCharacteristic
Data:
Handling Bluetooth Data Sending:
Handling Bluetooth Disconnection:
This pseudocode provides a framework for integrating Bluetooth functionalities within a WebView environment, allowing for communication between the web content and the native platform's Bluetooth capabilities. The actual implementation will depend on the specific requirements of the application and the characteristics of the connected Bluetooth device.
Next, you can return to Quickstart to view the relevant documentation for Config Event. Then, configure the Event in your JavaScript code.
Last updated