接入真机预览和调试功能步骤如下:
custom_config.json
)中加入 h5_remote_debug_host
的值,此值为调试通信的服务器地址。config.json
的 小程序 IDE 配置文件,找到 debug_url
字段。配置文件示例如下:
{
"login_url":"https://mappcenter.cloud.alipay.com/ide/login",
"uuid_url":"http://cn-hangzhou-mproxy.cloud.alipay.com/switch/uuid",
"debug_url":"wss://cn-hangzhou-mproxy.cloud.alipay.com",
"sign":"3decfd66c2924489204b4b0f38a9c228",
"upload_url":"https://mappcenter.cloud.alipay.com/ide/mappcenter/mds"
}
custom_config.json
中添加 h5_remote_debug_host
。key
为 h5_remote_debug_host
,value
为 上方配置文件中的 debug_url
字段,并在末尾加上 /host/
,示例如下:
[
{
"key": "h5_remote_debug_host",
"value": "wss://cn-hangzhou-mproxy.cloud.alipay.com/host/"
}
]
MyApplication
,在应用启动或启动小程序前调用 tinyHelper.setTinyAppVHost
方法设置小程序所使用的虚拟域名,代码示例如下:demo.com
替换为您所设置的虚拟域名。
MPTinyHelper tinyHelper = MPTinyHelper.getInstance();
tinyHelper.setTinyAppVHost("demo.com");
MPLogger.setUserId("your userId");
//第一个参数为二维码的 uri,第二个参数为自定义启动参数。若无自定义启动参数则填 new Bundle()。
MPTinyHelper.getInstance().launchIdeQRCode(uri, new Bundle());
// uri 是二维码对应的内容
String scheme = uri.getScheme();
if ("mpaas".equals(scheme)) {
Bundle params = new Bundle();
String appId = uri.getQueryParameter("appId");
for (String key : uri.getQueryParameterNames()) {
if (!"appId".equalsIgnoreCase(key)) {
params.putString(key, uri.getQueryParameter(key));
}
}
LauncherApplicationAgent.getInstance().getMicroApplicationContext()
startApp(null, appId, params);
}
在文档使用中是否遇到以下问题
更多建议
匿名提交