mPaaS
mPaaS copied to clipboard
iOS打开本地预置离线包,一直打开失败。
参考官网代码链接:https://tech.antfin.com/docs/2/133648
1、初始化容器代码:
// 自定义jsapi路径和预置离线包信息
let presetApplistPath = Bundle.main.path(forResource: "BCSCustomPresetApps.bundle/h5_json.json", ofType: nil)
let appPackagePath = Bundle.main.path(forResource: "BCSCustomPresetApps.bundle", ofType: nil)
let pluginsJsapisPath = Bundle.main.path(forResource: "BCSCustomPlugins.bundle/Poseidon-UserDefine-Extra-Config.plist", ofType: nil)
MPNebulaAdapterInterface.initNebula(withCustomPresetApplistPath: presetApplistPath!, customPresetAppPackagePath: appPackagePath!, customPluginsJsapisPath: pluginsJsapisPath!)
// 定制容器
MPNebulaAdapterInterface.shareInstance().nebulaVeiwControllerClass = H5WebViewController.self
MPNebulaAdapterInterface.shareInstance().nebulaUserAgent = "mPaaS/Portal"
MPNebulaAdapterInterface.shareInstance().nebulaNeedVerify = false
// 更新离线包
MPNebulaAdapterInterface.shareInstance().requestAllNebulaApps { (data, error) in
// debugPrint("[mpaas] nebula rpc data : \(data)")
debugPrint(data)
}
2、预置离线包配置Bundle信息:
3、打开预置离线包代码:
// MARK: 预置离线包i
@objc func openPresetPackage(_ sender: UIButton) {
MPNebulaAdapterInterface.shareInstance().startH5ViewController(withNebulaApp: ["appId": "20190901"])
}
4、报错页面
预置资源包加载失败一般为预置包版本和包信息不匹配,测试本地预置离线包时,请先断开网络,避免离线包有更新,确保加载的是客户端本地预置的版本。
检查本地预置的离线包信息与 Plist 中配置的包信息是否一致,包括 appID、version、main_url 等信息。