更新记录
1.1.2(2025-07-23)
调整selectOutbound接口参数名称。
1.1.1(2025-07-22)
修复处理iOS流量事件监听不生效的bug。
1.1.0(2025-07-21)
优化调整iOS插件内部逻辑。
查看更多平台兼容性
云端兼容性
阿里云 | 腾讯云 | 支付宝云 |
---|---|---|
√ | √ | √ |
uni-app(4.75)
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | iOS插件版本 | 鸿蒙 |
---|---|---|---|---|---|---|---|---|---|
× | × | × | × | × | × | 5.0 | 15 | 1.0.3 | × |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
× | × | × | × | × | × | × | × | × | × | × |
uni-app x(4.75)
Chrome | Safari | Android | iOS | iOS插件版本 | 鸿蒙 | 微信小程序 |
---|---|---|---|---|---|---|
× | × | 5.0 | 15 | 1.0.3 | × | × |
概述
XF-singBoxVPNUTS实现了iOS、Android集成sing-box实现VPN功能。
iOS插件必须看的说明
权限配置
"app-ios": {
"distribute": {
"modules": {},
"icons": {},
"splashScreens": {},
"privacyDescription": {
"NSSystemExtensionUsageDescription": "权限申请描述信息"
}
}
}
appIdxxx.PacketTunnel : 扩展ID格式 group.appIdxxx : 组名称格式
根目录下创建:nativeResources\ios 并放置ios-extension.json、ios-PacketTunnelExt.mobileprovision文件
ios-extension.json 内容如下:
{
"PacketTunnel.appex": {
"identifier":"com.app.xiaofei.001.PacketTunnel",
"profile":"ios-PacketTunnelExt.mobileprovision",
"entitlements":{
"com.apple.developer.networking.networkextension":["packet-tunnel-provider"],
"com.apple.security.application-groups":["group.com.app.xiaofei.001"]
}
}
}
ios-PacketTunnelExt.mobileprovision 文件为扩展appIdxxx.PacketTunnel的描述文件(请不要修改文件名称只替换描述文件)
调整插件内部的UTS.entitlements文件内容
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.networking.networkextension</key>
<array>
<string>packet-tunnel-provider</string>
</array>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.app.xiaofei.001</string>
</array>
</dict>
</plist>
插件接口
installVPN
安装或者授权VPN
uni-app项目中(nvue)调用示例:
import { installVPN } from "@/uni_modules/XF-singBoxVPNUTS"
installVPN({
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { installVPN } from "@/uni_modules/XF-singBoxVPNUTS";
import { ConfigOptions } from "@/uni_modules/XF-singBoxVPNUTS/utssdk/interface.uts";
let options = {
complete: (res : any) => {
console.log(res)
}
} as ConfigOptions;
installVPN(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
setConfig
配置VPN参数
uni-app项目中(nvue)调用示例:
import { setConfig } from "@/uni_modules/XF-singBoxVPNUTS"
setConfig({
conf: "",
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { setConfig } from "@/uni_modules/XF-singBoxVPNUTS";
import { ConfigOptions } from "@/uni_modules/XF-singBoxVPNUTS/utssdk/interface.uts";
let options = {
conf: "",
complete: (res : any) => {
console.log(res)
}
} as ConfigOptions;
setConfig(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
startVPN
开启VPN服务
uni-app项目中(nvue)调用示例:
import { startVPN } from "@/uni_modules/XF-singBoxVPNUTS"
startVPN({
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { startVPN } from "@/uni_modules/XF-singBoxVPNUTS";
import { VPNOptions } from "@/uni_modules/XF-singBoxVPNUTS/utssdk/interface.uts";
let options = {
complete: (res : any) => {
console.log(res)
}
} as VPNOptions;
startVPN(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
stopVPN
停止VPN服务
uni-app项目中(nvue)调用示例:
import { stopVPN } from "@/uni_modules/XF-singBoxVPNUTS"
stopVPN({
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { stopVPN } from "@/uni_modules/XF-singBoxVPNUTS";
import { VPNOptions } from "@/uni_modules/XF-singBoxVPNUTS/utssdk/interface.uts";
let options = {
complete: (res : any) => {
console.log(res)
}
} as VPNOptions;
stopVPN(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
addStatusCallback
监听VPN状态通知
uni-app项目中(nvue)调用示例:
import { addStatusCallback } from "@/uni_modules/XF-singBoxVPNUTS"
addStatusCallback({
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { addStatusCallback } from "@/uni_modules/XF-singBoxVPNUTS";
import { VPNOptions } from "@/uni_modules/XF-singBoxVPNUTS/utssdk/interface.uts";
let options = {
complete: (res : any) => {
console.log(res)
}
} as VPNOptions;
addStatusCallback(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
isConnected
是否已连接
uni-app项目中(nvue)调用示例:
import { isConnected } from "@/uni_modules/XF-singBoxVPNUTS"
isConnected({
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { isConnected } from "@/uni_modules/XF-singBoxVPNUTS";
import { VPNOptions } from "@/uni_modules/XF-singBoxVPNUTS/utssdk/interface.uts";
let options = {
complete: (res : any) => {
console.log(res)
}
} as VPNOptions;
isConnected(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
getConfig
获取正在运行的配置文件内容
uni-app项目中(nvue)调用示例:
import { getConfig } from "@/uni_modules/XF-singBoxVPNUTS"
getConfig({
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { getConfig } from "@/uni_modules/XF-singBoxVPNUTS";
import { VPNOptions } from "@/uni_modules/XF-singBoxVPNUTS/utssdk/interface.uts";
let options = {
complete: (res : any) => {
console.log(res)
}
} as VPNOptions;
getConfig(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
getLog
获取日志信息
uni-app项目中(nvue)调用示例:
import { getLog } from "@/uni_modules/XF-singBoxVPNUTS"
getLog({
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { getLog } from "@/uni_modules/XF-singBoxVPNUTS";
import { VPNOptions } from "@/uni_modules/XF-singBoxVPNUTS/utssdk/interface.uts";
let options = {
complete: (res : any) => {
console.log(res)
}
} as VPNOptions;
getLog(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
setClashMode
切换模式
uni-app项目中(nvue)调用示例:
import { setClashMode } from "@/uni_modules/XF-singBoxVPNUTS"
setClashMode({
mode: "",
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { setClashMode } from "@/uni_modules/XF-singBoxVPNUTS";
import { SetClashModeOptions } from "@/uni_modules/XF-singBoxVPNUTS/utssdk/interface.uts";
let options = {
mode: "",
complete: (res : any) => {
console.log(res)
}
} as SetClashModeOptions;
setClashMode(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
setGroupExpand
设置组是否展开
uni-app项目中(nvue)调用示例:
import { setGroupExpand } from "@/uni_modules/XF-singBoxVPNUTS"
setGroupExpand({
tag: "urltest",
isExpand: true,
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { setGroupExpand } from "@/uni_modules/XF-singBoxVPNUTS";
import { SetGroupExpandOptions } from "@/uni_modules/XF-singBoxVPNUTS/utssdk/interface.uts";
let options = {
tag: "urltest",
isExpand: true,
complete: (res : any) => {
console.log(res)
}
} as SetGroupExpandOptions;
setGroupExpand(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本
selectOutbound
选择组输出
uni-app项目中(nvue)调用示例:
import { selectOutbound } from "@/uni_modules/XF-singBoxVPNUTS"
selectOutbound({
groupTag: "urltest",
outboundTag: "",
complete: (res) => {
console.log(res)
}
});
uni-app x项目(uvue)中调用示例:
import { selectOutbound } from "@/uni_modules/XF-singBoxVPNUTS";
import { SelectOutboundOptions } from "@/uni_modules/XF-singBoxVPNUTS/utssdk/interface.uts";
let options = {
groupTag: "urltest",
outboundTag: "",
complete: (res : any) => {
console.log(res)
}
} as SelectOutboundOptions;
selectOutbound(options);
可用性
iOS、Android系统
可提供的1.0.0及更高版本