vn-jsbridge-sdk
v0.1.10
Published
vn flultter and web communication sdk
Downloads
581
Readme
VN JSBridge API Specification
1 - Init JSBridge
// Implement callback handlers
const registerCallbackHandlers = [
{
id: VNEventName.Token,
func: function(token: string) {
showMessage("token: " + token);
}
},
{
id: VNEventName.UserInfo,
func: function(info: { token: string }) {
showMessage("info: " + info.token);
}
}
];
// init VNJSBridge
const bridge = new VNJSBridge(registerCallbackHandlers);
// send get token event action
bridge.callGetToken();
// send get user info event action
bridge.callGeUserInfo();
2 - Enum
VNEventName
- Token: Get
token
event id - UserInfo:get vn
user info
event id
3 - Constant
VN_FLUTTER_CHANNEL
The key of Javascript Channel, Flutter will auto register before page loaded.
VN_JS_BRIDGE
The key of callback handlers collection, provided by web application to receive event
data.
VN_JS_BRIDGE_TOKEN_FUNC
The handler of get token
evnet, should register by user when initialize VNJSBridge.
VN_JS_BRIDGE_USERINFO_FUNC
The handler of get user info
evnet, should register by user when initialize VNJSBridge.