FinClip为企业提供小程序生态圈技术产品,开发者可在FinClip小程序开发帮助中心找到相关FinClip小程序指引

# 1. 启动小程序

int finclip_start_applet(const char *appstore, const char *appid);
int finclip_start_applet_params(const char *appstore, const char *appid, FinclipParams *params);
int finclip_start_applet_embed(const char *appstore, const char *appid, FinclipParams *params, HWND container);

根据appstore指定对应的全局配置, 您也可以增加ui参数

# 1.1 参数

appstore

        服务器配置的appstore

appid

        小程序对应的appid

params

        使用finclip_create_params创建的参数

container

        嵌入的目标窗口句柄 (仅windows支持)

# 1.2 可选参数

属性 类型 参数值 说明
window_type string (默认值) 独立模式: 0
嵌入模式: 1
窗口类型, 仅支持windows, 每个小程序独立设置
show_loading string (默认值) 展示: 1
不展示: 0
是否展示loading动画
force_applet_update string (默认值) 不强制: 0
强制: 1
是否强制小程序更新,
title_bar_back_button string (默认值) 隐藏: hidden
显示: normal
是否展示返回按钮
title_bar_close_button string (默认值) 显示: normal
隐藏: hidden
是否展示关闭按钮
title_bar_more_button string (默认值) 显示: normal
隐藏: hidden
是否展示关闭按钮
title_bar.style string (默认值) 完整显示: default
自定义导航栏,只保留右上角胶囊按钮。: custom
隐藏。: hide
顶栏演示
title_bar.height string 顶栏高度,默认值44
title_bar.back.url.normal string 顶栏返回按钮图片
title_bar.back.url.hover string 顶栏返回按钮图片
title_bar.back.url.pressed string 顶栏返回按钮图片
title_bar.home.width string 返回首页按钮的宽度
title_bar.home.height string 返回首页按钮的高度
title_bar.home.left_margin string 返回首页按钮的左边距,默认值为10
title_bar.home.corner_radius string 返回首页按钮的圆角半径,默认值为5
title_bar.home.dark_image string 返回首页按钮的图片对象,如果不传,会使用默认图标(暗黑模式)
title_bar.home.light_image string 返回首页按钮的图片对象,如果不传,会使用默认图标(明亮模式)
title_bar.home.border_light_color string 返回首页按钮的边框浅色颜色(明亮模式)
title_bar.home.border_dark_color string 返回首页按钮的边框浅色颜色(暗黑模式)
title_bar.home.bg_light_color string 返回首页按钮的背景浅色颜色(明亮模式)
title_bar.home.bg_dark_color string 返回首页按钮的背景浅色颜色(暗黑模式)
title_bar.font.families string 顶栏标题文字
title_bar.font.height string 顶栏标题文字大小
title_bar.font.align string 顶栏标题文字对其
more_menu.forward.visiable string (默认值) 显示: normal
隐藏: hidden
更多菜单是否展示转发按钮
more_menu.setting.visiable string (默认值) 显示: normal
隐藏: hidden
更多菜单是否展示设置按钮
more_menu.feedback.visiable string (默认值) 显示: normal
隐藏: hidden
更多菜单是否展示回到反馈按钮
more_menu.refresh.visiable string (默认值) 显示: normal
隐藏: hidden
更多菜单是否展示新进入按钮
more_menu.maximize.visiable string (默认值) 显示: normal
隐藏: hidden
更多菜单是否展示最大化按钮
more_menu.minimize.visiable string (默认值) 显示: normal
隐藏: hidden
更多菜单是否展示最小化按钮
capsule.width string 右上角胶囊视图的宽度,默认值为88
capsule.height string 右上角胶囊视图的高度,默认值为32
capsule.right_margin string 右上角胶囊视图的右边距,默认值为10
capsule.radius string 右上角胶囊视图的圆角半径,默认值为4
capsule.border.width string 右上角胶囊视图的边框宽度,默认值为1
capsule.border.light_color string 右上角胶囊视图的边框浅色颜色
capsule.border.dark_color string 右上角胶囊视图的边框深色颜色
capsule.background.light_color string 右上角胶囊视图的背景浅色颜色
capsule.background.dark_color string 右上角胶囊视图的背景深色颜色
capsule.more.light_image string 胶囊里的浅色更多按钮的图片路径
capsule.more.dark_image string 胶囊里的深色更多按钮的图片路径
capsule.more.width string 胶囊里的更多按钮的宽度,高度与宽度相等
capsule.more.left_margin string 胶囊里的更多按钮的左边距
capsule.close.light_image string 胶囊里的浅色关闭按钮的图片路径
capsule.close.dark_image string 胶囊里的深色色关闭按钮的图片路径
capsule.close.width string 胶囊里的关闭按钮的宽度,高度与宽度相等
capsule.close.left_margin string 胶囊里的关闭按钮的左边距
capsule.hide_before_open string 打开动画时,隐藏关闭胶囊
window_height string 初始窗口高度
window_width string 初始窗口宽度
window_scale_factor string 初始缩放倍率,默认1,合法值介于1-5
window_min_height string 最小窗口高度
window_min_width string 最小窗口宽度
title_bar_close_button_hide string (默认值) 关闭: 0
隐藏: 1
右上角关闭按钮功能, 可以选择关闭或者隐藏小程序窗口
title_bar.back_button.url string (默认值) 显示: normal
隐藏: hidden
顶栏返回按钮图片
page_path string 小程序首屏路径
start_params string 传给小程序的启动参数
start_flag string 启动设置
host.window.hwnd string 宿主的顶层窗口句柄, 仅windows有效
webview.user_agent string h5自定义USER AGENT
authorize_reject_button_radius_light string 权限弹框拒绝按钮圆角半径(浅色模式)
authorize_reject_button_background_light string 权限弹框拒绝按钮背景色(浅色模式)
authorize_reject_button_background_pressed_light string 权限弹框拒绝按钮按下背景色(浅色模式)
authorize_reject_button_border_light string 权限弹框拒绝按钮边框色(浅色模式)
authorize_reject_button_border_pressed_light string 权限弹框拒绝按钮按下边框色(浅色模式)
authorize_reject_button_text_light string 权限弹框拒绝按钮文字颜色(浅色模式)
authorize_reject_button_text_pressed_light string 权限弹框拒绝按钮按下文字颜色(浅色模式)
authorize_allow_button_radius_light string 权限弹框允许按钮圆角半径(浅色模式)
authorize_allow_button_background_light string 权限弹框允许按钮背景色(浅色模式)
authorize_allow_button_background_pressed_light string 权限弹框允许按钮按下背景色(浅色模式)
authorize_allow_button_border_light string 权限弹框允许按钮边框色(浅色模式)
authorize_allow_button_border_pressed_light string 权限弹框允许按钮按下边框色(浅色模式)
authorize_allow_button_text_light string 权限弹框允许按钮文字色(浅色模式)
authorize_allow_button_text_pressed_light string 权限弹框允许按钮按下文字色(浅色模式)
authorize_applet_name_size string 权限弹框小程序名称字号
authorize_applet_name_color_light string 权限弹框小程序名称颜色(浅色模式)
authorize_title_size string 权限弹框标题字号
authorize_title_color_light string 权限弹框标题文字颜色(浅色模式)
authorize_description_size string 权限弹框描述字号
authorize_description_color_light string 权限弹框描述文字颜色(浅色模式)
authorize_agreement_title_size string 权限弹框协议标题字号
authorize_agreement_title_color_light string 权限弹框协议标题文字颜色(浅色模式)
authorize_agreement_description_size string 权限弹框协议描述字号
authorize_agreement_description_color_light string 权限弹框协议描述文字颜色(浅色模式)
authorize_agreement_link_color_light string 权限弹框协议链接文字颜色(浅色模式)
authorize_agreement_icon_light string 权限弹框协议图标(浅色模式)
custom_about_page string 自定义关于页面地址

# 1.3 返回值

  1. 0 成功
  2. <0 失败

# 2. 关闭所有小程序


int finclip_close_all_applet();

# 2.1 返回值

  1. 0 成功
  2. <0 失败

# 3. 关闭指定小程序


int finclip_close_applet(const char *appid);

# 3.1 参数

appid

        小程序id

# 3.2 返回值

  1. 0 成功
  2. <0 失败

# 4. 隐藏指定小程序


int finclip_hide_applet(const char *appid);

# 4.1 参数

appid

        小程序id

# 4.2 返回值

  1. 0 成功
  2. <0 失败

# 5. 显示指定小程序


int finclip_show_applet(const char *appid);

# 5.1 参数

appid

        小程序id

# 5.2 返回值

  1. 0 成功
  2. <0 失败

# 6. 注册小程序状态事件回调


int finclip_register_lifecycle(const char *appid, LifecycleType lifecycle, FinclipLifecycleHandle handle, void *input);

如果同时注册了all和具体的回调类型, 会触发回调2次

同一类型的回调注册多次, 只有最后一次生效

# 6.1 参数

appid

        小程序id

lifecycle

        需要监听的事件

handle

        回调函数

input

        透传给回调函数

# 6.2 生命周期类型

名称 说明
kLifecycleAll 0 所有事件
kLifecycleStarted 1 小程序启动
kLifecycleClosed 2 小程序关闭
kLifecycleHide 3 小程序窗口隐藏
kLifecycleShow 4 小程序窗口显示
kLifecycleDomReady 5 小程序首屏渲染完毕

# 6.3 返回值

  1. 0 成功
  2. <0 失败

# 7. 设置小程序窗口位置


int finclip_set_position(const char *appid, int left, int top, int width, int height);

# 7.1 参数

appid

        小程序appid

left

        left

top

        top

width

        width

height

        height

# 7.2 返回值

  1. 0 成功
  2. <0 失败

# 8. 注册自定义api


int finclip_register_api(FinClipApiType type, const char *apis, FinclipApiHandle handle, void *input);

供小程序或h5调用

自定api对所有小程序都生效

重复注册api会覆盖

小程序启动后注册的api将不会生效

# 8.1 参数

type

        自定义api类型

apis

        api名称, 以,分割的字符串

handle

        处理函数

input

        自定义参数, 透传给handle

# 8.2 自定义api类型

名称 说明
kApplet 0 供小程序调用的api
kWebView 1 供h5调用的api

# 8.3 返回值

  1. 0 成功
  2. <0 失败

# 9. 设置自定义api的返回值


int finclip_callback_res(int callback_id, void *result);

小程序和宿主的api调用是异步, 通过此函数将返回值传回

此api只为做兼容性处理,请使用finclip_callback_success替代

# 10. 设置自定义api的成功返回值


int finclip_callback_success(int callback_id, void *result);

小程序和宿主的api调用是异步, 通过此函数将返回值传回

# 10.1 参数

callback_id

        回调id

result

        调用finclip_create_params获取的参数对象

# 10.2 返回值

  1. 0 成功
  2. <0 失败

# 11. 设置自定义api的失败返回值


int finclip_callback_failure(int callback_id, void *result);

小程序和宿主的api调用是异步, 通过此函数将返回值传回

# 11.1 参数

callback_id

        回调id

result

        调用finclip_create_params获取的参数对象

# 11.2 返回值

  1. 0 成功
  2. <0 失败

# 12. 初始化sdk

int finclip_init_with_json(const char *appstore, const char *json_str);
int finclip_init_with_config(const char *appstore, const FinclipParams *config);

# 12.1 参数

appstore

        服务器配置的appstore, 作为这套全局配置的唯一id

json_str

        json字符串

config

        使用finclip_create_params生成的FinclipParams对象

# 12.2 可选参数

属性 类型 参数值 说明
appstore string 这组参数的唯一标识
appkey string 从凡泰小程序开放平台获取的appkey
secret string 从凡泰小程序开放平台获取的secret
domain string 服务器地址
exe_path string 可执行文件位置
cef_path string 浏览器内核地址
current_user_id string 用户表示, 用于分离不同用户的userdata
web_path string
web_port string
net_proxy string (默认值)无代理: NoProxy
默认代理: DefaultProxy
网络代理类型

# 12.3 返回值

  1. 0 成功
  2. <0 失败

# 13. 创建参数容器


FinclipParams *finclip_create_params(void);

FinclipParams是一个json对象的简单封装

目的为了方便各种语言有统一的参数容器

使用完毕后, 请调用finclip_destory_params销毁 FinclipParams

# 14. 从json字符串创建启动参数


FinclipParams *finclip_build_params(const char *json_str);

FinclipParams是一个json对象的简单封装

目的为了方便各种语言有统一的参数容器

使用完毕后, 请调用finclip_destory_params销毁 FinclipParams

# 14.1 参数

json_str

        json格式的启动参数

# 15. 销毁启动参数


int finclip_destory_params(FinclipParams *params);

方便不同语言统一使用 对nlohmann/json做的封装

# 15.1 参数

params

        调用finclip_create_params获取的参数对象

# 15.2 返回值

  1. 0 成功
  2. <0 失败

# 16. 设置参数


int finclip_params_set(FinclipParams *params, const char *key, const char *value);

设置一个配置项, 具体配置项参见相应的api

# 16.1 参数

params

        调用finclip_create_params获取的参数对象

key

        配置项的key

value

        配置项的value

# 16.2 返回值

  1. 0 成功
  2. <0 失败

# 17. 删除指定参数


int finclip_params_del(FinclipParams *params, const char *key);

# 17.1 参数

params

        调用finclip_create_params获取的参数对象

key

        需要删除的配置项

# 17.2 返回值

  1. 0 成功
  2. <0 失败

# 18. 调用自定义api


int finclip_invoke_api(FinClipApiType type, const char *app_id, const char *api_name, const char *params, FinclipApiCallback callback, void *input);

调用h5中的自定义api, 小程序不支持自定义api

# 18.1 参数

type

        调用finclip_create_params获取的参数对象

app_id

        小程序id

api_name

        自定义api名称

params

        参数, json字符串

callback

        回调函数

input

        自定义参数, 透传给回调函数

# 18.2 返回值

  1. 0 成功
  2. <0 失败

# 19. 小程序是否打开


bool finclip_is_applet_open(const char *app_id);

# 19.1 参数

app_id

        小程序id

# 19.2 返回值

  1. true 已打开
  2. false 未打开

# 20. 注册系统协议


int finclip_register_protocol(const char *protocol, const char *exe);

仅支持windows, 供调试用. 注册后可以使用自定义协议打开程序

# 20.1 参数

protocol

        协议名

exe

        可执行程序位置

# 20.2 返回值

  1. 0 成功
  2. <0 失败

# 21. 获取配置工厂


IPackerFactory *finclip_get_packer_factory();

deprecated

请参考finclip_init_with_json, finclip_init_with_config

# 21.1 返回值

  1. NULL 调用失败
  2. 非空 调用成功

# 22. SDK初始化


int finclip_initialize(IFinConfigPacker *configpacker);

deprecated

请参考finclip_init_with_json, finclip_init_with_config

# 22.1 参数

configpacker

        由finclip_config_packer_new_config创建的IFinConfigPacker对象

# 22.2 返回值

  1. 0 成功
  2. <0 失败

# 23. 获取packer


IFinConfigPacker *finclip_packer_factory_get_config_packer(IPackerFactory *factory);

deprecated

请参考finclip_init_with_json, finclip_init_with_config

# 23.1 参数

factory

        由finclip_get_packer_factory创建的IPackerFactory对象

# 23.2 返回值

  1. NULL 调用失败
  2. 非空 调用成功

# 24. 新建配置


FinclipParams *finclip_config_packer_new_config(IFinConfigPacker *packer);

deprecated

请参考finclip_init_with_json, finclip_init_with_config

# 24.1 返回值

  1. NULL 调用失败
  2. 非空 调用成功

# 25. 获取配置


FinclipParams *finclip_config_packer_get_config(IFinConfigPacker *packer, char *appstore);

deprecated

请参考finclip_init_with_json, finclip_init_with_config

# 25.1 参数

packer

        由finclip_get_packer_factory创建的IPackerFactory对象

appstore

        服务器配置的appstore

# 25.2 返回值

  1. NULL 调用失败
  2. 非空 调用成功

# 26. 增加配置


int finclip_config_packer_add_config(IFinConfigPacker *packer, FinclipParams *config);

deprecated

请参考finclip_init_with_json, finclip_init_with_config

# 26.1 参数

packer

        IFinConfigPacker对象

config

        FinclipParams对象

# 26.2 返回值

  1. 0 成功
  2. <0 失败

# 27. 注册右上角更多菜单回调


int finclip_register_more_btn_handler(const char *appid, const char *menu_id, const char *title, const char *icon, FinClipMoreMenuBtnType type, FinclipMoreHandle handle, void *input);

# 27.1 参数

appid

        小程序对应的appid

menu_id

        菜单id,如果是右上角的更多按钮,填nullptr

title

        菜单item标题,如果是右上角的更多按钮,填nullptr

icon

        菜单item图标路径,如果是右上角的更多按钮,填nullptr

type

        按钮类型,如果是右上角的更多按钮,填kMoreBtnCommon

handle

        回调handler

input

        透传给回调函数

# 27.2 返回值

  1. 0 成功
  2. <0 失败

# 28. 原生给小程序发送消息


int finclip_send_custom_event(const char *app_id, const char *params);

# 28.1 参数

app_id

        小程序id

params

        事件参数

# 28.2 返回值

  1. 0 成功
  2. <0 失败
© 2022 FinClip with ❤

👋🏻 嘿,你好!

「FinClip」是一套基于云原生框架设计的小程序容器。能够让任何移动应用在集成小程序SDK之后,获得可用、安全的小程序运行能力。

>> 点我免费注册体验

查看产品文档
了解与 FinClip 相关的一切信息

产品博客 👈  了解产品更新与核心功能介绍
资源下载 👈  获取小程序 SDK 与开发工具
文档中心 👈  查询 FinClip 小程序开发指南与答疑

商务咨询热线
预约 FinClip 产品介绍,咨询商务报价或私有化部署事宜

0755-86967467

获取产品帮助
联系 FinClip 技术顾问,获取产品资料或加入开发者社群

联系线上
人工客服

或 👉  点击这里,提交咨询工单